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 #16 from MatthiWare/development
Browse files Browse the repository at this point in the history
[UI] Update Generator
  • Loading branch information
Matthiee authored Apr 23, 2017
2 parents d083dde + dcec845 commit 7b6c493
Show file tree
Hide file tree
Showing 70 changed files with 3,505 additions and 325 deletions.
4 changes: 2 additions & 2 deletions UpdateLib/TestApp/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void button2_Click(object sender, EventArgs e)

private void button3_Click(object sender, EventArgs e)
{
UpdateFile file = UpdateFile.Load("../../../UpdateLib.Generator/bin/Debug/Output/updatefile.xml");
UpdateFile file = UpdateFile.Load("../../../MatthiWare.UpdateLib.Generator/bin/Debug/Output/updatefile.xml");
UpdaterForm updaterForm = new UpdaterForm(file);
updaterForm.ShowDialog(this);
}
Expand All @@ -87,7 +87,7 @@ private void Form1_Load(object sender, EventArgs e)

Func<int, bool> test2 = new Func<int, bool>((i) => { return i%2==0; });

AsyncTaskBase<bool> task = AsyncTaskFactory.StartNew<bool>(test2, 2);
AsyncTask<bool> task = AsyncTaskFactory.StartNew<bool>(test2, 2);
Console.WriteLine(task.GetType().FullName);

}
Expand Down
19 changes: 18 additions & 1 deletion UpdateLib/TestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
using MatthiWare.UpdateLib;
using MatthiWare.UpdateLib.Logging;
using MatthiWare.UpdateLib.Logging.Writers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
Expand All @@ -13,9 +16,23 @@ static class Program
[STAThread]
static void Main()
{
SetupLogging();
InitializeUpdater();

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}

private static void InitializeUpdater()
{
Updater.Instance.Initialize();
}

private static void SetupLogging()
{
Logger.Writers.Add(new ConsoleLogWriter());
Logger.Writers.Add(new FileLogWriter());
}
}
}
38 changes: 38 additions & 0 deletions UpdateLib/UpdateLib.Generator/Data/FilesPage/GenFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace MatthiWare.UpdateLib.Generator.Data.FilesPage
{
public class GenFile
{
private FileInfo m_file;

public string Name { get { return m_file.Name; } }
public string RealPath { get { return m_file.FullName; } }
public string Extension { get { return m_file.Extension; } }
public string Size { get { return ConvertBytesToSizeString(m_file.Length); } }

public GenFolder ParentFolder { get; set; }

public ListViewItemFile FileListView { get; set; }

public GenFile(FileInfo file)
{
m_file = file;

FileListView = new ListViewItemFile(file);
}

private static string ConvertBytesToSizeString(long size)
{
size = Math.Max(0, size);

double kb = Math.Ceiling(size / 1024.0);

return $"{kb.ToString("N0")} kB";
}
}
}
27 changes: 27 additions & 0 deletions UpdateLib/UpdateLib.Generator/Data/FilesPage/GenFolder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

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


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


public GenFolder(string name)
{
Name = name;
}

}
}
33 changes: 33 additions & 0 deletions UpdateLib/UpdateLib.Generator/Data/ListViewItemFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using MatthiWare.UpdateLib.Generator.Data.FilesPage;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MatthiWare.UpdateLib.Generator.Data
{
public class ListViewItemFile : ListViewItem
{
public GenFile File { get; set; }

private ListViewItemFile(string[] items, string imageKey)
: base(items, imageKey)
{ }

public ListViewItemFile(FileInfo file)
: this(new string[] { "", file.Name, file.LastWriteTime.ToString(), "File", ConvertBytesToSizeString(file.Length)}, file.Extension)
{
}

private static string ConvertBytesToSizeString(long size)
{
size = Math.Max(0, size);

double kb = Math.Ceiling(size / 1024.0);

return $"{kb.ToString("N0")} kB";
}
}
}
26 changes: 26 additions & 0 deletions UpdateLib/UpdateLib.Generator/Data/ListViewItemFolder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using MatthiWare.UpdateLib.Generator.Data.FilesPage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MatthiWare.UpdateLib.Generator.Data
{
public class ListViewItemFolder : ListViewItem
{
internal const string FOLDER_KEY = "folderimagekey";

public GenFolder Folder { get; set; }

private ListViewItemFolder(string[] items, string imageKey)
: base(items, imageKey)
{ }

public ListViewItemFolder(string folderName, GenFolder folder)
: this(new string[] { "", folderName, "", "Folder", "" }, FOLDER_KEY)
{
Folder = folder;
}
}
}
25 changes: 25 additions & 0 deletions UpdateLib/UpdateLib.Generator/Data/TreeViewFolderNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using MatthiWare.UpdateLib.Generator.Data.FilesPage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MatthiWare.UpdateLib.Generator.Data
{
public class TreeViewFolderNode : TreeNode
{
internal const string FOLDER_KEY = "folderimagekey";

public GenFolder Folder { get; set; }

public TreeViewFolderNode(string folderName, GenFolder folder)
{
Text = folderName;
ImageKey = FOLDER_KEY;
SelectedImageKey = FOLDER_KEY;
Folder = folder;
}

}
}
22 changes: 22 additions & 0 deletions UpdateLib/UpdateLib.Generator/Files/ProjectFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MatthiWare.UpdateLib.Generator.Files
{
[Serializable]
public class ProjectFile
{

#region General Info
#endregion

#region Files
#endregion

#region Registry
#endregion

}
}
66 changes: 33 additions & 33 deletions UpdateLib/UpdateLib.Generator/MainForm.Designer.cs

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

Loading

0 comments on commit 7b6c493

Please sign in to comment.