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 #18 from MatthiWare/development
Browse files Browse the repository at this point in the history
v0.1.1 test release
  • Loading branch information
Matthiee authored Apr 30, 2017
2 parents 7b6c493 + 65b9011 commit c981c4a
Show file tree
Hide file tree
Showing 43 changed files with 1,600 additions and 364 deletions.
440 changes: 350 additions & 90 deletions UpdateLib/TestApp/Form1.Designer.cs

Large diffs are not rendered by default.

95 changes: 39 additions & 56 deletions UpdateLib/TestApp/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,91 +5,74 @@
using MatthiWare.UpdateLib.UI;
using System;
using System.Drawing;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace TestApp
{
public partial class Form1 : Form
{
private Updater updater;

public Form1()
{
InitializeComponent();

updater = Updater.Instance;
updater.UpdateURL = "http://matthiware.dev/UpdateLib/Dev/updatefile.xml";
updater.CheckForUpdatesCompleted += Updater_CheckForUpdatesCompleted;

updater.Initialize();
}

private void Updater_CheckForUpdatesCompleted(object sender, CheckForUpdatesCompletedEventArgs e)
{
if (e.Cancelled)
Logger.Debug(nameof(Updater), "Cancelled");

if (e.Error != null)
Logger.Error(nameof(Updater), e.Error);

Logger.Debug(nameof(Updater), $"Version: {e.LatestVersion}");
Logger.Debug(nameof(Updater), $"Update available: {e.UpdateAvailable}");
Updater.Instance.CheckForUpdatesCompleted += Instance_CheckForUpdatesCompleted;
}

private void button1_Click(object sender, EventArgs e)
private void Instance_CheckForUpdatesCompleted(object sender, CheckForUpdatesCompletedEventArgs e)
{
DialogResult result = new MessageDialog(
"Test title",
"Version 1.0.0.0 available",
"Download update now?\nPress yes to download or no to cancel.", SystemIcons.Question, MessageBoxButtons.YesNoCancel).ShowDialog(this);
this.InvokeOnUI(() => checkForUpdatesToolStripMenuItem.Enabled = true);

if (result == DialogResult.Yes)
if (e.Cancelled || e.Error != null)
{
UpdateFile updateFile = new UpdateFile();
updateFile.VersionString = "1.0.0.0";
updateFile.ApplicationDirectory.Files.Add(new FileEntry("test"));
updateFile.ApplicationDirectory.Files.Add(new FileEntry("Updater.exe"));
updateFile.ApplicationDirectory.Files.Add(new FileEntry("App.exe"));
this.InvokeOnUI(() => MessageDialog.Show(
this,
"Updater",
e.Cancelled ? "Cancelled" : "Error",
e.Cancelled ? "Update got cancelled" : "Please check the logs for more information.",
e.Cancelled ? SystemIcons.Warning : SystemIcons.Error,
MessageBoxButtons.OK));

return;
}

UpdaterForm updateForm = new UpdaterForm(updateFile);
updateForm.ShowDialog(this);
if (!e.UpdateAvailable)
{
this.InvokeOnUI(() =>
MessageDialog.Show(
this,
"Updater",
"No update available!",
$"You already have the latest version ({e.LatestVersion}).",
SystemIcons.Information,
MessageBoxButtons.OK));

return;
}
}

private void button2_Click(object sender, EventArgs e)
private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateFile updateFile = new UpdateFile();
updateFile.VersionString = "1.0.0.0";
updateFile.ApplicationDirectory.Files.Add(new FileEntry("test"));
updateFile.ApplicationDirectory.Files.Add(new FileEntry("Updater.exe"));
updateFile.ApplicationDirectory.Files.Add(new FileEntry("App.exe"));

UpdaterForm updateForm = new UpdaterForm(updateFile);
updateForm.ShowDialog(this);
}
checkForUpdatesToolStripMenuItem.Enabled = false;

private void button3_Click(object sender, EventArgs e)
{
UpdateFile file = UpdateFile.Load("../../../MatthiWare.UpdateLib.Generator/bin/Debug/Output/updatefile.xml");
UpdaterForm updaterForm = new UpdaterForm(file);
updaterForm.ShowDialog(this);
Updater.Instance.CheckForUpdatesAsync();
}

private void button4_Click(object sender, EventArgs e)
private void Form1_Load(object sender, EventArgs e)
{
updater.CheckForUpdates();
label1.Text = ReadFile("data/testfile1.txt");
label2.Text = ReadFile("data/testfile2.txt");
label3.Text = ReadFile("data/testfile3.txt");
}

private void Form1_Load(object sender, EventArgs e)
private string ReadFile(string file)
{
Action<object> test = new Action<object>((o) => { });

Func<int, bool> test2 = new Func<int, bool>((i) => { return i%2==0; });
string[] lines = File.ReadAllLines(file);

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

return string.Join(", ", lines);
}
}
}
118 changes: 118 additions & 0 deletions UpdateLib/TestApp/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,122 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="newToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAERSURBVDhPrZDbSgJRGIXnpewd6jXsjSQvIrwoI0RQMChU
0iiDPCGiE3ZCRkvR8VzTeBhnyR5/ccaZNnPhB4t9sdf6Ln5hb8QeathNJFVFKF5C8DqL4ksDVHWGDf7j
LHyPg6NjviSaFqlu5yQYR+KpupaIkrMknCxT3Y7v/NYYb0ITK1c3BarbWWhLQ7IR0cTKReyZ6lZ0XYei
ztHpK4bAc+h1FgQijzSxMptrGIxVSO0xX3AaStFki7bUMVFmaMm/eJMGfIH/MkGzLep0AXn4h/r3CJV3
mS9gn2bY4UY/UzQ7E9TqfeTFtnuB+XAfzSHKr11kSl/uBebDiZ89ZCst3OUkdwL28sIVsE83ock+EIQV
2Mz2wxeg6/UAAAAASUVORK5CYII=
</value>
</data>
<data name="openToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJHSURBVDhPxZBdSNNhFMb/F110ZZEVhVBgeeHNICiiuggp
olAUyyxI0oSaH1QYC3N+tKnp5ubm1JUua5uuqdNKMwr7kApFItTUkWZqVhSVYmao5Nevvy7UoYR3HXh4
4XCe33nOKyy3lAY7l9RWMo0O/raWXxEyo5spVYTNvOGyfIRPfW+ptOkXqaPl6T83hcRmExSdgzAz3NVm
YWyoYla/B+1M9JtxWLPpaH22JORIjI6gKAMB0jyEimIdo4OlbuaprwVMOOMovammpDADc34qppwUrmnl
5Kni3aFlFg2j3y1z5mnRTJccnNIltQhwq0jFry+mOXNtpWZWDx1Z1NhV3C3JwGFOw25SYjVe5oYhiUKd
HKMmwQUrMWUw/CF3NnZvvYKqUh1TvUroS3fXe7HXkwidMngTS2t5KLbregSzMY2f3Wr4qKW6LJvGR1rX
0MLor8OhKYTJBn/GHvvxrliCTBrsOqXIoOBHh5K+hmSq7FqmexTQHuUytkaKxuNMNgYyVneA4Qd7GKjc
hjLaRzxH7gIU6JIZaEvgtk1D8wsxSWecCDgNzWFMvwxm/PkhRmr3Mli1nW9lvjRdWc0Jf+/5jzRmyWmv
S+GOLQu6U6BFjPvqKOP1AYw88WOoZif9DgmfLVtxaj1RSLdwNvrkPCA3M54KqxrnvRia9MKcGrUrqFOt
5H7qKsqT1mGO9+Lqhc2ELdw+U/r0i+gVZ8hMiCDx3DHORwZyKnQ/hw/uYt9uCTskPvh6e7Fp41rWr/Fg
g6eHO+A/lyD8ARfG3mk9fv1YAAAAAElFTkSuQmCC
</value>
</data>
<data name="saveToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIySURBVDhPrZLfS5NRGMfff6H7boIuuq2pMZyL1eAt11CW
DcOKsB9vpFmaLtNExco0av6CbIVLJ61Wk3BSkT/AFCkRZSpZmrmiJQ41xSaCwdfznL15XEUX0Reem5f3
8znnec4j/Zc8fxYGla91CS3eRTx0z6OpMYS7jmnU1X6B/VYA18snUVoyjsKCt8jLHcH5c36ouCQR2NUJ
1Nas4G9ZXlmFKbULh1Kf8lJxSfI+WeCCyopv6q+/h+DQ/DJ2WV5Ao1FgPegRAveDOS4oLfmq/h6dn/DH
4AJizD4UXJrCAUuzEDgbZrjgou2DiohshIcnQtgme5GTPYbkJKcQ1N8OckHW2REVi+RXuM8fxGaDG4oy
ALPZIQQ11Z+5QDk1oKJ/hjv7P2FTfCMOH3mFxMQ6IbhROYWOdrCnBI4dfwPr0V4+bRoY9UzXppMjcDdS
rC8hy3YhuFI2gTYf2A4Aza4f7N2/o/zaLB8qDYx6zszwr8P7k1thNFYIweXCMXgeAfedq2xxwjClZUeV
Jd2GtDNFETiJwfs8MBjKhMCWN8pgoLoqzE8miH1GjE7G4PsZjE7OQsm9ij2mFg7rdrug1xcJAa2l4w7W
r00Cgk/n38S7wBwC04u4UGxHrMHF4CbEJtyDLj5fCDIzhljfSxzeavRgyw4Zj9t64GvvQ0d3P3pfD2Kv
2QqNvgFxDN6urYdWmyMElJMnevh60obRktA701PRtGlg1DOdSkXwzrisaMG/RZLWAE60OMW5fNhvAAAA
AElFTkSuQmCC
</value>
</data>
<data name="printToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIpSURBVDhPtZL/T1JRGMb5p1itrVZbbRpqZbawnBENV1I0
jGlByTSyJTXJwq2oKZQb1KAv6JCYWSxvBrkkZUq4CeQEiRABFeLL072Xa0zRra31bO8v57zP5znnPYf1
X+TxhWF6O7VtGYcnwbSWijKPOLzYrPSvLPwLS3huGUMlT7o9wGD9grVUBj+icdid03S9tDmgNxNwTgVQ
J+rA8XNtWwM+uuZATMwxmQVRycuJFNyzIRitDlScugKzjSgFRGJJaIwEsrk8AsHIhnSL/Ssck37UNipQ
I5DjtuYV7uksRYhr2kebhx2eP6nrycFIEh5fBA/1Nvru8q5+PDaOovK0rABwfwugWzcErfkzHhjsePL6
E7q1VrTdNUDcrgGvSYlDZHN5XTNOnL8BVe8AJAoNDtZfLgDu9L1BPJmikzcrk81hlRwodZJwdBXziwnI
OrVoaOkiT8C8hKLHBPO7CbywOaE1jeC+bhAd6meQdvZC1KoG/5IS3MZ2HObLUHZSggvkWq3wOvbWiAqA
VpWeyStVfCUNf3AZ4zNhfHCFMEDMgye+hYr6FrDLzxQAUuVTpr0ocn74mchg5vsKRt1RcHp2Qv9+kZ78
UcE17KkWFgHNN/uQzgBkGKLJPBZiecyGchjzrmFwPIF++xJUbDbUQzEacIArLpopSRSP4CUN1Obf1Abz
uqob5KjiXwWH/GVl5HPt5zZh37GL2H1EiF1VZ7GDI6CNW5r/TSzWbwHYL0mKJ5czAAAAAElFTkSuQmCC
</value>
</data>
<data name="printPreviewToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGCSURBVDhPnZK9S0JRGMb9F1xb2gqaq6mhwCGDtvYIIyLI
cJOE1paoIYpMKUjFRDH87lpoakGlIZF9DA2hZJEQhJXl1xPn3HPV29WQfvBwOfA+P95zuDJ39A6/4wyl
YOOSMHvOcHGThuwvSKEVRvsR+pQqWD3R1pK98DUbl7Jm5hA8SfESd6S5xH5wycalrO4E0D8yWQuriLH6
E2xcSqlcoRJBxCpiTO5TNi4m/ZgDF4nDsOulsfujyGRzUsmWM8YqdcggKbveS3A88bEkslRye58RSzZt
IVarY/FFaPmlwp+fUaESYRNW5Vm3BPmpBpZNvppACDmTLbS6FbGAPFAj5OGI4PALOK/yZfIlAlk4j7n5
xdaCarWKj0KRXmE2+UklJEJZZ/RCPTPdWvBdLOP1rYD41QNcgRiVkKJQ1mjGsa2VNxeQb2OWDC7sh47p
ddQLeoyOTSFiVAAFvVhChsmv2k6Uvd3Icx1UolMNiDdpl4nhLiohW/xb0tMph2JwCJxjAz9A30JI8zYA
tAAAAABJRU5ErkJggg==
</value>
</data>
<data name="cutToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGDSURBVDhPrZFNSwJRGIX9NYGbFoUlFElY1EJQKEYhCJsi
LaVsERnRF5iCaSZJO1toCDVGFkgoFpWQWWRR2aIvUxm1BKN1wSnHCFw4TOCzue+9nPNw4eVVnav4Izzb
QfxeGZ5TWaxT/rK3irzmC7CsusvC1G4IkbNLboIiDieF4GGUKeTeClDpppF8eeEu2PIfwfrzizSdw3Hk
EnKlFpkMzV2wH77AosOFTV8A+vkl9CiHuJeLJNNZjM8tYWB0FkTvMAwmy/8ERTR6CwjlGAi1Ccence6C
1NsXzN4PKIxJLLgeIJ2MoXvmFraNBKK3eXZRIveJPvs7FIYniEkXZENOdE+GIZ2Ko10TwLK7tJmKmL0F
EEYarYM+NMnt0C1sQzpx/lcSEnZ2gcKY/gs0dlmZuWvmjjmpwA1qxVp2AWFIMAF/OAGBzMjMI7ZrtJCb
4Df3o4Zfxy7QrdxDRFKol5khkpR2H4qmIOzUQNBGwrsXYxccnNOQqNbQ0KGGZ+eEPVwdeLxvqqrf4wGh
TNAAAAAASUVORK5CYII=
</value>
</data>
<data name="copyToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHkSURBVDhPvZHfS1NhHIf3p5QypLr2D4goMwoMCi/qIugH
Xe1Cr7qKDIMkZixwNhfWLGWbnuki0kXKzLU023KubBNPJrbRdOzocm6e2dPOO21mMS+CHvjcvOf9PF++
79H9M+7RT2iRRsIi9sEAXe43yAvf2LpSHq28G9uAnytNT4jMLewtcQ2Ht2pF8ps/aOt+gccX5lxD694S
+1BQFD1RkN5DSFa4Z3uONKbgHE3h8KZ4OJTC1J8UiSzmfhd2uf1CoJHbyKOsZokl0kKwm+aeJaov+wjO
rpQkVqdXfOz0bWAcVLghfaXxkUz3y2VxvpMGSwL3uMKh+gHezSSLEnNhX23vtYzKUirDfGyFj/Iy1mdx
UWqR8iKhwtQLxjgH659y4EwvVXWPiwJt3/Ws+muywRrlqvkDdx3zQrCN8l1ldnEd3/QqFmkS/akHJYGS
zjLzOUEwEsMf+sLI2zmaOou/93pPGoM5zvk7UU7fnBKxSBPoT7SXBNW1F/9Io2lKCNTCeomUyrS8xnBA
wfUqyf1eP5U1ptJD/o1LzeNCsHPydtqdr6k4aiwvOHvNSya3ibU/QIdrEkvfhJislc32MfYfuV1eUGPw
FF7bIVJVZ0N/soPK421UHGstlFvYd/hWecF/Qqf7CR0A5wwgSQA2AAAAAElFTkSuQmCC
</value>
</data>
<data name="pasteToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJSSURBVDhPtZJrSJNRGMdf6IN9KbpQn/pUEH2JIoLqQ0Zh
FqYZRmJG1iKmUqKyLB2pqSm6vC1Nm5GXoeatEsVJ0RASR3eNzegikRq5lrV3857Fr/d9ddlICoL+8OfA
Oef/e57zcIT/os7WLMw302muSGJ2689qqi7A44q8IzjtNYzarzHQm8tZtT8FmRqu6LToMxN+B8qhCbGR
KVcDE85ajKUaxoaryEuL4UVXIudPB5Ko2oy98xjDptXERuz3hsgAOTzlqqMk6yjdllzE90UM9Wp5azlB
S1kwkeG+1CSv4mmBQPThfd6Ahqq8GYB4A11yBKmaMLQxoZyLDkGjDiZOFUhUuB+FsWsUQFiArzegtlzH
pFjPpMPA2GA2jucx2KqWK7ZWLqO7dBGP9D5KWLbfto3eAKMhi3FHBeP9GYy9PMXos4OIrYvJrzSRbWjm
wuV6EnVG4tLLiEzSExGf4w0oL05nZEDPaK+akceBuO9v4uPtFUrYo6npbzhdE/QPOQmNSiPouHYOUpaf
gvgqA/dDf9wd63G1r2SgUlAqyyq/1anYUGfG2mdXwne7bOwJUc1AinOS+NxzBpd5HWLbUhyNPvRdF5S2
v05/54tbqvzBifWNHUvPOwLC4/CXwrv2HsB3+w6EwosJOB5ESeElfGpayGD1AmwlArHSm+W2PR1clToo
MrbT0mFTVtlbN6xFuJQar3wQz5Q9VksD+7XyPctrJdx4p5s605M5gKz8lJPSDwtGFbKboJ1blAN52vKb
PdXm80/AfDokTVu+8DfPXv9XCcIPTvjvLQ8YoakAAAAASUVORK5CYII=
</value>
</data>
</root>
2 changes: 2 additions & 0 deletions UpdateLib/TestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ static void Main()
private static void InitializeUpdater()
{
Updater.Instance.Initialize();
Updater.Instance.UpdateURL = "https://raw.githubusercontent.com/MatthiWare/UpdateLib.TestApp.UpdateExample/master/Dev/updatefile.xml";
//Updater.Instance.UpdateURL = "http://matthiware.dev/UpdateLib/Dev/updatefile.xml";
}

private static void SetupLogging()
Expand Down
11 changes: 11 additions & 0 deletions UpdateLib/TestApp/TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@
<Name>UpdateLib</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="data\testfile1.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="data\testfile2.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="data\testfile3.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
1 change: 1 addition & 0 deletions UpdateLib/TestApp/data/testfile1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is testfile1.
1 change: 1 addition & 0 deletions UpdateLib/TestApp/data/testfile2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is testfile2.
1 change: 1 addition & 0 deletions UpdateLib/TestApp/data/testfile3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is testfile3.
12 changes: 6 additions & 6 deletions UpdateLib/UpdateLib.Generator/Data/FilesPage/GenFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ namespace MatthiWare.UpdateLib.Generator.Data.FilesPage
{
public class GenFile
{
private FileInfo m_file;
public FileInfo FileInfo { get; set; }

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 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); } }

public GenFolder ParentFolder { get; set; }

public ListViewItemFile FileListView { get; set; }

public GenFile(FileInfo file)
{
m_file = file;
FileInfo = file;

FileListView = new ListViewItemFile(file);
}
Expand Down
22 changes: 20 additions & 2 deletions UpdateLib/UpdateLib.Generator/Data/FilesPage/GenFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,37 @@ 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<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 TreeViewFolderNode FolderTreeView { get; set; }

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

return x;
}
}

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

ParentFolder?.Directories.Add(this);

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

}
Expand Down
6 changes: 3 additions & 3 deletions UpdateLib/UpdateLib.Generator/Data/TreeViewFolderNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public class TreeViewFolderNode : TreeNode

public GenFolder Folder { get; set; }

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

Expand Down
Loading

0 comments on commit c981c4a

Please sign in to comment.