Skip to content
This repository has been archived by the owner on Dec 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #25 from MatthiWare/development
Browse files Browse the repository at this point in the history
Rollback and registry updater feature
  • Loading branch information
Matthiee authored Aug 1, 2017
2 parents a75ddba + dae58bb commit 2b89a5f
Show file tree
Hide file tree
Showing 86 changed files with 3,361 additions and 646 deletions.
40 changes: 7 additions & 33 deletions UpdateLib/TestApp/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions UpdateLib/TestApp/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Form1()

private void Instance_CheckForUpdatesCompleted(object sender, CheckForUpdatesCompletedEventArgs e)
{
this.InvokeOnUI(() => checkForUpdatesToolStripMenuItem.Enabled = true);
checkForUpdatesToolStripMenuItem.Enabled = true;

//if (e.Cancelled || e.Error != null)
//{
Expand Down Expand Up @@ -99,17 +99,5 @@ private string ReadFileAndKeepStreamOpen(string file)

return text;
}

private void button1_Click(object sender, EventArgs e)
{
DummyTask task = new DummyTask();
task.TaskCompleted += (o, ex) => Updater.Instance.Logger.Debug(nameof(DummyTask), "Callback task completed!");
task.Start();
}

private void button2_Click(object sender, EventArgs e)
{
//Updater.Instance.RestartApp(false, false, true, true);
}
}
}
49 changes: 25 additions & 24 deletions UpdateLib/TestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using MatthiWare.UpdateLib.Utils;
using MatthiWare.UpdateLib.Files;
using Microsoft.Win32;

namespace TestApp
{
Expand All @@ -16,33 +19,31 @@ static class Program
[STAThread]
static void Main()
{
try
{
// we still want our updater to have visual styles in case of update cmd argument switch
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

// we still want our updater to have visual styles in case of update cmd argument switch
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Updater.Instance
.ConfigureUpdateUrl("https://raw.githubusercontent.com/MatthiWare/UpdateLib.TestApp.UpdateExample/master/Dev/updatefile.xml")
//.ConfigureUpdateUrl("http://matthiware.dev/UpdateLib/Dev/updatefile.xml")
.ConfigureLogger((logger) => logger.LogLevel = LoggingLevel.Debug)
.ConfigureLogger((logger) => logger.Writers.Add(new ConsoleLogWriter()))
.ConfigureLogger((logger) => logger.Writers.Add(new FileLogWriter()))
.ConfigureUnsafeConnections(true)
.ConfigureCacheInvalidation(TimeSpan.FromSeconds(30))
.ConfigureNeedsRestartBeforeUpdate(true)
.ConfigureInstallationMode(InstallationMode.Shared)
.Initialize();

Updater.Instance
.ConfigureUpdateUrl("https://raw.githubusercontent.com/MatthiWare/UpdateLib.TestApp.UpdateExample/master/Dev/updatefile.xml")
//.ConfigureUpdateUrl("http://matthiware.dev/UpdateLib/Dev/updatefile.xml")
.ConfigureLogger((logger) => logger.LogLevel = LoggingLevel.Debug)
.ConfigureLogger((logger) => logger.Writers.Add(new ConsoleLogWriter()))
.ConfigureLogger((logger) => logger.Writers.Add(new FileLogWriter()))
.ConfigureUnsafeConnections(true)
.ConfigureCacheInvalidation(TimeSpan.FromSeconds(30))
.ConfigureUpdateNeedsAdmin(false)
.ConfigureInstallationMode(InstallationMode.Shared)
.Initialize();
Application.Run(new Form1());

Application.Run(new Form1());
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
MessageBox.Show(e.ToString());
}


}

private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
Console.WriteLine(e.Exception.ToString());
MessageBox.Show(e.Exception.ToString());
}
}
}
4 changes: 2 additions & 2 deletions UpdateLib/TestApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.4.0.0")]
[assembly: AssemblyFileVersion("0.4.0.0")]
2 changes: 1 addition & 1 deletion UpdateLib/TestApp/Testing/DummyTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private void ChildWorkStuff(int id)

Thread.Sleep(waitTime);

Updater.Instance.Logger.Debug(nameof(ChildWorkStuff), $"Task[{id.ToString("X2")}] Completed");
Updater.Instance.Logger.Debug(nameof(ChildWorkStuff), string.Empty, $"Task[{id.ToString("X2")}] Completed");
}


Expand Down
34 changes: 25 additions & 9 deletions UpdateLib/UpdateLib.Generator/Data/FilesPage/GenFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,31 @@

namespace MatthiWare.UpdateLib.Generator.Data.FilesPage
{
public class GenFile
public class GenFile : IGenItem
{
public FileInfo FileInfo { get; set; }
public event EventHandler Changed;

public string Name { get { return FileInfo.Name; } }
public string RealPath { get { return FileInfo.FullName; } }
public string Extension { get { return FileInfo.Extension; } }
public string Size { get { return ConvertBytesToSizeString(FileInfo.Length); } }
private FileInfo m_fileInfo;
public FileInfo FileInfo
{
get { return m_fileInfo; }
set { m_fileInfo = value; Changed?.Invoke(this, EventArgs.Empty); }
}

public GenFolder ParentFolder { get; set; }
public string Name { get { return FileInfo?.Name ?? string.Empty; } set { Changed?.Invoke(this, EventArgs.Empty); } }
public string RealPath { get { return FileInfo?.FullName ?? string.Empty; } }
public string Extension { get { return FileInfo?.Extension ?? string.Empty; } }
public string Size { get { return ConvertBytesToSizeString(FileInfo?.Length ?? 0); } }

public ListViewItemFile FileListView { get; set; }
public GenFolder Parent { get; set; }

public ListViewGenItem View { get; set; }

public GenFile(FileInfo file)
{
FileInfo = file;

FileListView = new ListViewItemFile(file);
View = new ListViewGenItem(this);
}

private static string ConvertBytesToSizeString(long size)
Expand All @@ -34,5 +41,14 @@ private static string ConvertBytesToSizeString(long size)

return $"{kb.ToString("N0")} kB";
}

public string[] GetListViewItems()
{
return new string[] { Name, "File", FileInfo.LastWriteTime.ToString(), Size };
}
public string GetListViewImageKey()
{
return Extension;
}
}
}
47 changes: 35 additions & 12 deletions UpdateLib/UpdateLib.Generator/Data/FilesPage/GenFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,66 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MatthiWare.UpdateLib.Generator.Data.FilesPage
{
public class GenFolder
{
public string Name { get; set; }
public string PathVariable { get; set; }
public List<GenFile> Files { get; private set; } = new List<GenFile>();
public List<IGenItem> Items { get; private set; } = new List<IGenItem>();
public List<GenFolder> Directories { get; private set; } = new List<GenFolder>();
public GenFolder ParentFolder { get; set; }
public bool IsRoot { get { return ParentFolder == null; } }
public bool ProtectedFolder { get; set; } = false;

public ListViewItemFolder FolderListView { get; set; }
public ListViewFolder FolderListView { get; set; }
public TreeViewFolderNode FolderTreeView { get; set; }

public int Count
{
get
{
int x = Files.Count;
foreach (GenFolder f in Directories)
x += f.Count;

return x;
return Items.Count + Directories.Sum(d => d.Count);
}
}

public GenFolder(string name, GenFolder parent)
public GenFolder(string name, ContextMenuStrip menu)
{
Name = name;
ParentFolder = parent;

ParentFolder?.Directories.Add(this);

FolderListView = new ListViewItemFolder(name, this);
FolderListView = new ListViewFolder(name, this);
FolderTreeView = new TreeViewFolderNode(name, this);

FolderTreeView.ContextMenuStrip = menu;

}

public void Add(IGenItem item)
{
item.Parent = this;
Items.Add(item);
}

public void Add(GenFolder folder)
{
folder.ParentFolder = this;
Directories.Add(folder);
FolderTreeView.Nodes.Add(folder.FolderTreeView);
}

public void Remove(IGenItem item)
{
Items.Remove(item);
item.View.Remove();
}

public void Remove(GenFolder folder)
{
Directories.Remove(folder);
FolderTreeView.Nodes.Remove(folder.FolderTreeView);
folder.FolderListView.Remove();
}

}
Expand Down
Loading

0 comments on commit 2b89a5f

Please sign in to comment.