Skip to content

Commit 97a9ff4

Browse files
committed
Automatic Update
1 parent 8ac5136 commit 97a9ff4

19 files changed

+78
-77
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
4+
<StartArguments>"c:\Users\bernathcs\AppData\Local\Data Commander\DataCommander.exe"</StartArguments>
5+
</PropertyGroup>
6+
</Project>

DataCommander.Updater/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Diagnostics;
33
using System.Windows.Forms;
4+
using Foundation.Deployment;
45

56
namespace DataCommander.Updater
67
{
@@ -15,7 +16,7 @@ static void Main(string[] args)
1516

1617
var applicationExeFileName = args[0];
1718
var updaterDirectory = Environment.CurrentDirectory;
18-
Foundation.Deployment.Updater.Update(updaterDirectory, applicationExeFileName);
19+
DeploymentHelper.Update(updaterDirectory, applicationExeFileName);
1920

2021
//Application.EnableVisualStyles();
2122
//Application.SetCompatibleTextRenderingDefault(false);

DataCommander/DataCommander.csproj

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,23 +171,20 @@
171171
<Reference Include="System.Xml" />
172172
</ItemGroup>
173173
<ItemGroup>
174-
<Compile Include="CheckForUpdateCompleted.cs" />
175-
<Compile Include="CheckForUpdatesStarted.cs" />
176-
<Compile Include="DownloadingNewVersionStarted.cs" />
177-
<Compile Include="DownloadProgressChanged.cs" />
178-
<Compile Include="Event.cs" />
179-
<Compile Include="EventHandler.cs" />
180-
<Compile Include="NewVersionDownloaded.cs" />
181-
<Compile Include="Updater.cs" />
182-
<Compile Include="UpdaterForm.cs">
174+
<Compile Include="Update\Events\CheckForUpdateCompleted.cs" />
175+
<Compile Include="Update\Events\CheckForUpdatesStarted.cs" />
176+
<Compile Include="Update\Events\DownloadingNewVersionStarted.cs" />
177+
<Compile Include="Update\Events\DownloadProgressChanged.cs" />
178+
<Compile Include="Update\Events\Event.cs" />
179+
<Compile Include="Update\EventHandler.cs" />
180+
<Compile Include="Update\Events\NewVersionDownloaded.cs" />
181+
<Compile Include="Update\Updater.cs" />
182+
<Compile Include="Update\UpdaterForm.cs">
183183
<SubType>Form</SubType>
184184
</Compile>
185-
<Compile Include="UpdaterForm.Designer.cs">
185+
<Compile Include="Update\UpdaterForm.Designer.cs">
186186
<DependentUpon>UpdaterForm.cs</DependentUpon>
187187
</Compile>
188-
<Content Include="Version.txt">
189-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
190-
</Content>
191188
<None Include="App.config">
192189
<SubType>Designer</SubType>
193190
</None>
@@ -232,7 +229,7 @@
232229
</BootstrapperPackage>
233230
</ItemGroup>
234231
<ItemGroup>
235-
<EmbeddedResource Include="UpdaterForm.resx">
232+
<EmbeddedResource Include="Update\UpdaterForm.resx">
236233
<DependentUpon>UpdaterForm.cs</DependentUpon>
237234
</EmbeddedResource>
238235
</ItemGroup>

DataCommander/DataCommander.csproj.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<ProjectView>ShowAllFiles</ProjectView>
4+
<ProjectView>ProjectFiles</ProjectView>
55
<PublishUrlHistory />
66
<InstallUrlHistory />
77
<SupportUrlHistory />

DataCommander/EntryPoint.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Threading;
55
using System.Windows.Forms;
66
using DataCommander.Providers;
7+
using DataCommander.Update;
78
using Foundation.Configuration;
89
using Foundation.Diagnostics.MethodProfiler;
910
using Foundation.Log;
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
using System.Windows.Forms;
2+
using DataCommander.Update.Events;
23
using Foundation.Windows.Forms;
34

4-
namespace DataCommander
5+
namespace DataCommander.Update
56
{
67
internal sealed class EventHandler
78
{
89
private readonly UpdaterForm _updaterForm;
910
public EventHandler(UpdaterForm updaterForm) => _updaterForm = updaterForm;
1011
public void Handle(Event @event) => Handle((dynamic) @event);
1112
private void Handle(CheckForUpdatesStarted @event) => _updaterForm.Invoke(() => _updaterForm.Log("Checking for updates..."));
13+
1214
private void Handle(DownloadingNewVersionStarted @event) => _updaterForm.Invoke(() =>
1315
{
1416
_updaterForm.WindowState = FormWindowState.Normal;
15-
Application.DoEvents();
1617
_updaterForm.Log("Downloading new version...");
17-
Application.DoEvents();
1818
});
1919

20-
private void Handle(DownloadProgressChanged @event) => _updaterForm.Invoke(() => _updaterForm.Log($"{@event.DownloadProgressChangedEventArgs.ProgressPercentage}% complete."));
20+
private void Handle(DownloadProgressChanged @event) =>
21+
_updaterForm.Invoke(() => _updaterForm.Log($"{@event.DownloadProgressChangedEventArgs.ProgressPercentage}% complete."));
22+
2123
private void Handle(NewVersionDownloaded @event) => _updaterForm.Invoke(() => _updaterForm.Log("New version downloaded."));
2224

2325
private void Handle(CheckForUpdateCompleted @event) => _updaterForm.Invoke(() =>
2426
{
2527
_updaterForm.Log("Checking for updates completed.");
26-
Application.DoEvents();
2728
_updaterForm.Close();
28-
Application.DoEvents();
2929
});
3030
}
3131
}

DataCommander/CheckForUpdateCompleted.cs renamed to DataCommander/Update/Events/CheckForUpdateCompleted.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace DataCommander
1+
namespace DataCommander.Update.Events
22
{
33
public sealed class CheckForUpdateCompleted : Event
44
{

DataCommander/CheckForUpdatesStarted.cs renamed to DataCommander/Update/Events/CheckForUpdatesStarted.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace DataCommander
1+
namespace DataCommander.Update.Events
22
{
33
public sealed class CheckForUpdatesStarted : Event
44
{

DataCommander/DownloadProgressChanged.cs renamed to DataCommander/Update/Events/DownloadProgressChanged.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Net;
22

3-
namespace DataCommander
3+
namespace DataCommander.Update.Events
44
{
55
public sealed class DownloadProgressChanged : Event
66
{

DataCommander/DownloadingNewVersionStarted.cs renamed to DataCommander/Update/Events/DownloadingNewVersionStarted.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace DataCommander
1+
namespace DataCommander.Update.Events
22
{
33
public sealed class DownloadingNewVersionStarted : Event
44
{

0 commit comments

Comments
 (0)