Skip to content

Commit 38184a7

Browse files
committed
New ui complete
1 parent 80f812a commit 38184a7

File tree

7 files changed

+88
-23
lines changed

7 files changed

+88
-23
lines changed

CrosshairY.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<UseWindowsForms>true</UseWindowsForms>
1010
<ApplicationIcon>assets\logo.ico</ApplicationIcon>
1111
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
12-
<FileVersion>2.0.3</FileVersion>
12+
<FileVersion>2.0.4</FileVersion>
1313
</PropertyGroup>
1414

1515
<ItemGroup>

Managers/GithubDirectoryDownloaderService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public partial class GitHubDirectoryDownloaderService : IDisposable
2424
private readonly string _shaCacheFile;
2525
private HashSet<string> _currentFiles;
2626
public event EventHandler<ProgressEventArgs>? ProgressUpdated;
27+
public event EventHandler<EventArgs>? DownloadFinished;
2728

2829
/// <summary>
2930
/// Initializes a new instance of the GitHubDirectoryDownloaderService class for downloading the contents of a specific
@@ -54,7 +55,7 @@ public GitHubDirectoryDownloaderService(string repositoryOwner, string repositor
5455
_httpClient.DefaultRequestHeaders.Add("User-Agent", "GitHubDirectoryDownloaderService");
5556

5657
// Replace with token, IF token exists locally (development purposes only)
57-
string githubToken = Environment.GetEnvironmentVariable("GITHUB_TOKEN") ?? "N/A";
58+
string githubToken = Environment.GetEnvironmentVariable("GITHUB_TOKEN") ?? "";
5859
if (!string.IsNullOrEmpty(githubToken))
5960
_httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("token", githubToken);
6061
#endregion
@@ -119,6 +120,8 @@ public async Task DownloadDirectoryAsync(string downloadPath)
119120
await Task.WhenAll(_subfolderTasks);
120121

121122
SaveSHAHashes(_currentFiles);
123+
124+
DownloadFinished?.Invoke(this, EventArgs.Empty);
122125
}
123126
catch (Exception)
124127
{

Managers/UpdateManager.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public sealed class UpdateManager
1515

1616
private readonly string _repositoryOwner = "tsgsOFFICIAL";
1717
private readonly string _repositoryName = "CrosshairY";
18-
private readonly string _folderPath = "UI/bin/Release/net10.0-windows/publish/win-x64";
18+
private readonly string _folderPath = "bin/Release/net10.0-windows/publish/win-x64";
1919

2020
public event EventHandler<ProgressEventArgs>? DownloadProgress;
2121
public event EventHandler? UpdateAvailable;
@@ -42,7 +42,11 @@ private UpdateManager()
4242
if (isAvailable)
4343
{
4444
if (App.Settings.App.AutoUpdate)
45+
{
46+
App.Settings.App.UpdateAvailable = true;
47+
UpdateAvailable?.Invoke(this, EventArgs.Empty);
4548
await DownloadUpdate();
49+
}
4650
else
4751
{
4852
App.Settings.App.UpdateAvailable = true;
@@ -121,19 +125,25 @@ public async Task DownloadUpdate()
121125

122126
using GitHubDirectoryDownloaderService downloader = new GitHubDirectoryDownloaderService(_repositoryOwner, _repositoryName, _folderPath, basePath);
123127
downloader.ProgressUpdated += OnProgressChanged!;
128+
downloader.DownloadFinished += OnDownloadFinished!;
124129

125130
try
126131
{
127132
await downloader.DownloadDirectoryAsync(updatePath);
128-
129-
Process.Start(Path.Combine(updatePath, "CrosshairY"), "--updating");
130-
Environment.Exit(0);
131133
}
132134
catch (Exception ex)
133135
{
134136
NotificationManager.ShowNotification("Update Error", $"An error occurred while updating the application.\n{ex.Message}\n\nTry again after this time", 300);
135137
}
136138
}
139+
private void OnDownloadFinished(object sender, EventArgs e)
140+
{
141+
string basePath = Path.Combine(Environment.ExpandEnvironmentVariables("%APPDATA%"), "CrosshairY");
142+
string updatePath = Path.Combine(basePath, "Update");
143+
144+
Process.Start(Path.Combine(updatePath, "CrosshairY"), "--updating");
145+
Environment.Exit(0);
146+
}
137147
/// <summary>
138148
/// Raises the event that reports progress updates during an operation.
139149
/// </summary>

Pages/SettingsPage.xaml

Lines changed: 69 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:CrosshairY.Pages"
7+
xmlns:icon="http://metro.mahapps.com/winfx/xaml/iconpacks"
78
mc:Ignorable="d"
89
d:DesignHeight="450" d:DesignWidth="800"
910
Title="Settings"
@@ -104,25 +105,76 @@
104105

105106
<!-- Update Status -->
106107
<Border Background="{StaticResource SecondaryBrush}"
107-
BorderBrush="{StaticResource BorderBrush}"
108-
BorderThickness="1"
109-
CornerRadius="6"
110-
Padding="16"
111-
Margin="0,0,0,16">
108+
BorderBrush="{StaticResource BorderBrush}"
109+
BorderThickness="1"
110+
CornerRadius="6"
111+
Padding="16"
112+
Margin="0,0,0,16">
113+
112114
<StackPanel Orientation="Horizontal">
113-
<Path Data="M22,12 A10,10 0 1,1 12,2 A10,10 0 0,1 22,12 M9,12 L11,14 L15,10"
114-
Stroke="{StaticResource PrimaryBrush}"
115-
StrokeThickness="2"
116-
Width="20" Height="20"
117-
Stretch="Uniform"
118-
Margin="0,0,12,0"/>
115+
116+
<!-- Icon -->
117+
<icon:PackIconGameIcons
118+
Width="20" Height="20"
119+
Margin="0,0,12,0"
120+
VerticalAlignment="Center">
121+
122+
<icon:PackIconGameIcons.Style>
123+
<Style TargetType="icon:PackIconGameIcons">
124+
<!-- Default = up to date -->
125+
<Setter Property="Kind" Value="CheckMark"/>
126+
<Setter Property="Foreground" Value="{StaticResource PrimaryBrush}"/>
127+
128+
<Style.Triggers>
129+
<!-- Update available -->
130+
<DataTrigger Binding="{Binding UpdateAvailable}" Value="True">
131+
<Setter Property="Kind" Value="CloudDownload"/>
132+
<Setter Property="Foreground" Value="#FF6B6B"/>
133+
</DataTrigger>
134+
</Style.Triggers>
135+
</Style>
136+
</icon:PackIconGameIcons.Style>
137+
</icon:PackIconGameIcons>
138+
119139
<StackPanel>
120-
<TextBlock Text="You are up to date"
121-
Style="{StaticResource BodyText}"
122-
FontWeight="Medium"/>
123-
<TextBlock Text="{Binding AppVersion, StringFormat='Version {0}'}"
124-
Style="{StaticResource MutedText}"
125-
FontSize="12"/>
140+
141+
<!-- Title -->
142+
<TextBlock FontWeight="Medium">
143+
<TextBlock.Style>
144+
<Style TargetType="TextBlock" BasedOn="{StaticResource BodyText}">
145+
146+
<!-- default -->
147+
<Setter Property="Text" Value="You are up to date"/>
148+
149+
<Style.Triggers>
150+
<DataTrigger Binding="{Binding UpdateAvailable}" Value="True">
151+
<Setter Property="Text" Value="Update available!"/>
152+
</DataTrigger>
153+
</Style.Triggers>
154+
155+
</Style>
156+
</TextBlock.Style>
157+
</TextBlock>
158+
159+
<!-- Subtitle -->
160+
<TextBlock FontSize="12">
161+
<TextBlock.Style>
162+
<Style TargetType="TextBlock" BasedOn="{StaticResource MutedText}">
163+
164+
<!-- default -->
165+
<Setter Property="Text"
166+
Value="{Binding AppVersion, StringFormat='Version {0}'}"/>
167+
168+
<Style.Triggers>
169+
<DataTrigger Binding="{Binding UpdateAvailable}" Value="True">
170+
<Setter Property="Text"
171+
Value="Download the latest version to stay updated."/>
172+
</DataTrigger>
173+
</Style.Triggers>
174+
175+
</Style>
176+
</TextBlock.Style>
177+
</TextBlock>
126178
</StackPanel>
127179
</StackPanel>
128180
</Border>
6.5 KB
Binary file not shown.
0 Bytes
Binary file not shown.
1.45 KB
Binary file not shown.

0 commit comments

Comments
 (0)