mirror of
https://github.com/ckaczor/WorldClockStatusWindow.git
synced 2026-01-21 01:35:38 -05:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 14ac34f27f | |||
| 72644ef84f | |||
| e732fe9d91 | |||
| 3a189986da | |||
| adab62394b |
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
@@ -5,6 +5,8 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy-to-github-releases:
|
deploy-to-github-releases:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@@ -24,11 +26,11 @@ jobs:
|
|||||||
dotnet-version: 8.0.x
|
dotnet-version: 8.0.x
|
||||||
|
|
||||||
- name: Publish Application
|
- name: Publish Application
|
||||||
run: dotnet publish WorldClockStatusWindow.csproj -c Release -o publish -r win-x64 --self-contained true
|
run: dotnet publish WorldClockStatusWindow.csproj -c Release -o publish
|
||||||
|
|
||||||
- name: Create Velopack Release
|
- name: Create Velopack Release
|
||||||
run: |
|
run: |
|
||||||
dotnet tool install -g vpk
|
dotnet tool install -g vpk
|
||||||
vpk download github --repoUrl https://github.com/ckaczor/WorldClockStatusWindow
|
vpk download github --repoUrl https://github.com/ckaczor/WorldClockStatusWindow
|
||||||
vpk pack -u WorldClockStatusWindow -v ${{ steps.version.outputs.version }} -p publish
|
vpk pack -u WorldClockStatusWindow -v ${{ steps.version.outputs.version }} -p publish --packTitle "World Clock Status Window" --shortcuts StartMenuRoot --framework net8.0-x64-desktop
|
||||||
vpk upload github --repoUrl https://github.com/ckaczor/WorldClockStatusWindow --publish --releaseName "WorldClockStatusWindow ${{ steps.version.outputs.version }}" --tag v${{ steps.version.outputs.version }} --token ${{ secrets.GITHUB_TOKEN }}
|
vpk upload github --repoUrl https://github.com/ckaczor/WorldClockStatusWindow --publish --releaseName "${{ steps.version.outputs.version }}" --tag v${{ steps.version.outputs.version }} --token ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
|
using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
|
||||||
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -8,11 +9,8 @@ using System.Text.Json;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using Serilog;
|
|
||||||
using Serilog.Core;
|
|
||||||
using Velopack;
|
using Velopack;
|
||||||
using Velopack.Sources;
|
using Velopack.Sources;
|
||||||
using WorldClockStatusWindow.Properties;
|
|
||||||
|
|
||||||
namespace WorldClockStatusWindow;
|
namespace WorldClockStatusWindow;
|
||||||
|
|
||||||
@@ -22,6 +20,8 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
private readonly Timer _timer;
|
private readonly Timer _timer;
|
||||||
private readonly Dispatcher _dispatcher;
|
private readonly Dispatcher _dispatcher;
|
||||||
|
|
||||||
|
private readonly UpdateManager _updateManager;
|
||||||
|
|
||||||
private List<TimeZoneEntry> _timeZoneEntries;
|
private List<TimeZoneEntry> _timeZoneEntries;
|
||||||
|
|
||||||
internal WindowSource()
|
internal WindowSource()
|
||||||
@@ -31,34 +31,40 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
|
|
||||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||||
|
|
||||||
|
_updateManager = new UpdateManager(new GithubSource("https://github.com/ckaczor/WorldClockStatusWindow", null, false));
|
||||||
|
|
||||||
_timer = new Timer(1000);
|
_timer = new Timer(1000);
|
||||||
|
|
||||||
Task.Factory.StartNew(UpdateApp).ContinueWith(_ => Start());
|
Task.Factory.StartNew(UpdateApp).ContinueWith(task => Start(task.Result.Result));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateApp()
|
private async Task<bool> UpdateApp()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var updateManager = new UpdateManager(new GithubSource("https://github.com/ckaczor/WorldClockStatusWindow", null, false));
|
if (!_updateManager.IsInstalled)
|
||||||
|
|
||||||
if (!updateManager.IsInstalled)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_dispatcher.Invoke(() => _floatingStatusWindow.SetText("Checking for update..."));
|
Log.Logger.Information("Checking for update");
|
||||||
|
|
||||||
var newVersion = await updateManager.CheckForUpdatesAsync();
|
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText("Checking for update..."));
|
||||||
|
|
||||||
|
var newVersion = await _updateManager.CheckForUpdatesAsync();
|
||||||
|
|
||||||
if (newVersion == null)
|
if (newVersion == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_dispatcher.Invoke(() => _floatingStatusWindow.SetText("Downloading update..."));
|
Log.Logger.Information("Downloading update");
|
||||||
|
|
||||||
await updateManager.DownloadUpdatesAsync(newVersion);
|
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText("Downloading update..."));
|
||||||
|
|
||||||
_dispatcher.Invoke(() => _floatingStatusWindow.SetText("Installing update..."));
|
await _updateManager.DownloadUpdatesAsync(newVersion);
|
||||||
|
|
||||||
updateManager.ApplyUpdatesAndRestart(newVersion);
|
Log.Logger.Information("Installing update");
|
||||||
|
|
||||||
|
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText("Installing update..."));
|
||||||
|
|
||||||
|
_updateManager.ApplyUpdatesAndRestart(newVersion);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -68,10 +74,19 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start(bool hasUpdate)
|
||||||
{
|
{
|
||||||
|
Log.Logger.Information($"Start: hasUpdate={hasUpdate}");
|
||||||
|
|
||||||
|
if (hasUpdate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Log.Logger.Information("Load");
|
||||||
|
|
||||||
Load();
|
Load();
|
||||||
|
|
||||||
|
Log.Logger.Information("Starting timer");
|
||||||
|
|
||||||
_timer.Elapsed += HandleTimerElapsed;
|
_timer.Elapsed += HandleTimerElapsed;
|
||||||
_timer.Enabled = true;
|
_timer.Enabled = true;
|
||||||
}
|
}
|
||||||
@@ -115,6 +130,10 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
text.Append($"{timeZoneEntry.Label.PadLeft(labelLength)}: {TimeZoneInfo.ConvertTime(now, timeZone).ToString(Properties.Settings.Default.TimeFormat)}");
|
text.Append($"{timeZoneEntry.Label.PadLeft(labelLength)}: {TimeZoneInfo.ConvertTime(now, timeZone).ToString(Properties.Settings.Default.TimeFormat)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.AppendLine();
|
||||||
|
text.AppendLine();
|
||||||
|
text.Append(_updateManager.CurrentVersion);
|
||||||
|
|
||||||
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(text.ToString()));
|
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(text.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,14 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||||
<StartupObject>WorldClockStatusWindow.Program</StartupObject>
|
<StartupObject>WorldClockStatusWindow.Program</StartupObject>
|
||||||
|
<ApplicationIcon>clock.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AppDesigner Include="Properties\" />
|
<AppDesigner Include="Properties\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="clock.ico" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ChrisKaczor.Wpf.Application.StartWithWindows" Version="1.0.5" />
|
<PackageReference Include="ChrisKaczor.Wpf.Application.StartWithWindows" Version="1.0.5" />
|
||||||
<PackageReference Include="ChrisKaczor.Wpf.Windows.FloatingStatusWindow" Version="2.0.0.5" />
|
<PackageReference Include="ChrisKaczor.Wpf.Windows.FloatingStatusWindow" Version="2.0.0.5" />
|
||||||
|
|||||||
Reference in New Issue
Block a user