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

Commit 7b6c493

Browse files
authored
Merge pull request #16 from MatthiWare/development
[UI] Update Generator
2 parents d083dde + dcec845 commit 7b6c493

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3505
-325
lines changed

UpdateLib/TestApp/Form1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private void button2_Click(object sender, EventArgs e)
7171

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

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

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

9393
}

UpdateLib/TestApp/Program.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
using MatthiWare.UpdateLib;
2+
using MatthiWare.UpdateLib.Logging;
3+
using MatthiWare.UpdateLib.Logging.Writers;
4+
using System;
25
using System.Collections.Generic;
36
using System.Linq;
47
using System.Windows.Forms;
@@ -13,9 +16,23 @@ static class Program
1316
[STAThread]
1417
static void Main()
1518
{
19+
SetupLogging();
20+
InitializeUpdater();
21+
1622
Application.EnableVisualStyles();
1723
Application.SetCompatibleTextRenderingDefault(false);
1824
Application.Run(new Form1());
1925
}
26+
27+
private static void InitializeUpdater()
28+
{
29+
Updater.Instance.Initialize();
30+
}
31+
32+
private static void SetupLogging()
33+
{
34+
Logger.Writers.Add(new ConsoleLogWriter());
35+
Logger.Writers.Add(new FileLogWriter());
36+
}
2037
}
2138
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace MatthiWare.UpdateLib.Generator.Data.FilesPage
8+
{
9+
public class GenFile
10+
{
11+
private FileInfo m_file;
12+
13+
public string Name { get { return m_file.Name; } }
14+
public string RealPath { get { return m_file.FullName; } }
15+
public string Extension { get { return m_file.Extension; } }
16+
public string Size { get { return ConvertBytesToSizeString(m_file.Length); } }
17+
18+
public GenFolder ParentFolder { get; set; }
19+
20+
public ListViewItemFile FileListView { get; set; }
21+
22+
public GenFile(FileInfo file)
23+
{
24+
m_file = file;
25+
26+
FileListView = new ListViewItemFile(file);
27+
}
28+
29+
private static string ConvertBytesToSizeString(long size)
30+
{
31+
size = Math.Max(0, size);
32+
33+
double kb = Math.Ceiling(size / 1024.0);
34+
35+
return $"{kb.ToString("N0")} kB";
36+
}
37+
}
38+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace MatthiWare.UpdateLib.Generator.Data.FilesPage
7+
{
8+
public class GenFolder
9+
{
10+
public string Name { get; set; }
11+
public List<GenFile> Files { get; private set; } = new List<GenFile>();
12+
public List<GenFolder> Directories { get; private set; } = new List<GenFolder>();
13+
public GenFolder ParentFolder { get; set; }
14+
public bool IsRoot { get { return ParentFolder == null; } }
15+
16+
17+
public ListViewItemFolder FolderListView { get; set; }
18+
public TreeViewFolderNode FolderTreeView { get; set; }
19+
20+
21+
public GenFolder(string name)
22+
{
23+
Name = name;
24+
}
25+
26+
}
27+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using MatthiWare.UpdateLib.Generator.Data.FilesPage;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Windows.Forms;
8+
9+
namespace MatthiWare.UpdateLib.Generator.Data
10+
{
11+
public class ListViewItemFile : ListViewItem
12+
{
13+
public GenFile File { get; set; }
14+
15+
private ListViewItemFile(string[] items, string imageKey)
16+
: base(items, imageKey)
17+
{ }
18+
19+
public ListViewItemFile(FileInfo file)
20+
: this(new string[] { "", file.Name, file.LastWriteTime.ToString(), "File", ConvertBytesToSizeString(file.Length)}, file.Extension)
21+
{
22+
}
23+
24+
private static string ConvertBytesToSizeString(long size)
25+
{
26+
size = Math.Max(0, size);
27+
28+
double kb = Math.Ceiling(size / 1024.0);
29+
30+
return $"{kb.ToString("N0")} kB";
31+
}
32+
}
33+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using MatthiWare.UpdateLib.Generator.Data.FilesPage;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Windows.Forms;
7+
8+
namespace MatthiWare.UpdateLib.Generator.Data
9+
{
10+
public class ListViewItemFolder : ListViewItem
11+
{
12+
internal const string FOLDER_KEY = "folderimagekey";
13+
14+
public GenFolder Folder { get; set; }
15+
16+
private ListViewItemFolder(string[] items, string imageKey)
17+
: base(items, imageKey)
18+
{ }
19+
20+
public ListViewItemFolder(string folderName, GenFolder folder)
21+
: this(new string[] { "", folderName, "", "Folder", "" }, FOLDER_KEY)
22+
{
23+
Folder = folder;
24+
}
25+
}
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using MatthiWare.UpdateLib.Generator.Data.FilesPage;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Windows.Forms;
7+
8+
namespace MatthiWare.UpdateLib.Generator.Data
9+
{
10+
public class TreeViewFolderNode : TreeNode
11+
{
12+
internal const string FOLDER_KEY = "folderimagekey";
13+
14+
public GenFolder Folder { get; set; }
15+
16+
public TreeViewFolderNode(string folderName, GenFolder folder)
17+
{
18+
Text = folderName;
19+
ImageKey = FOLDER_KEY;
20+
SelectedImageKey = FOLDER_KEY;
21+
Folder = folder;
22+
}
23+
24+
}
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace MatthiWare.UpdateLib.Generator.Files
7+
{
8+
[Serializable]
9+
public class ProjectFile
10+
{
11+
12+
#region General Info
13+
#endregion
14+
15+
#region Files
16+
#endregion
17+
18+
#region Registry
19+
#endregion
20+
21+
}
22+
}

UpdateLib/UpdateLib.Generator/MainForm.Designer.cs

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)