Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 877cdfe

Browse files
committed
Merge branch '#79_Updater_Window_Restyle'
2 parents 6d2aa77 + 52c2c31 commit 877cdfe

File tree

6 files changed

+30
-13
lines changed

6 files changed

+30
-13
lines changed

Interop/Updater/UpdateCheck.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ private static bool IsUpToDate(Version currentVer, Version latestVer)
7171
private static async Task<Release> GetLatest()
7272
{
7373
var client = new GitHubClient(new ProductHeaderValue("spcode-client"));
74-
var releases = await client.Repository.Release.GetAll("Hexer10", "SPCode");
75-
return releases[0];
74+
var latestRelease = await client.Repository.Release.GetLatest("Hexer10", "SPCode");
75+
return latestRelease;
7676
}
7777
}
7878
}

Interop/Updater/UpdateWindow.xaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6-
Width="500" Height="200" ResizeMode="NoResize" ShowInTaskbar="False" WindowStyle="None" ShowTitleBar="False" GlowBrush="{DynamicResource AccentColorBrush}"
7-
ShowCloseButton="False" WindowStartupLocation="CenterOwner" >
5+
Width="500" Height="400" TitleCaps="False" ShowInTaskbar="False" GlowBrush="{DynamicResource AccentColorBrush}" WindowStartupLocation="CenterOwner" WindowStyle="None" >
86
<mahapps:MetroWindow.Resources>
97
<ResourceDictionary>
108
<ResourceDictionary.MergedDictionaries>
@@ -17,11 +15,13 @@
1715
</ResourceDictionary>
1816
</mahapps:MetroWindow.Resources>
1917
<Grid>
18+
<Image Name="Icon" Source="/SPCode;component/Resources/Icon.ico" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5,5,5,5" Width="40" Height="40"/>
2019
<mahapps:ProgressRing Name="Progress" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5,5,5,5" Width="40" Height="40" IsActive="False" IsLarge="False" IsHitTestVisible="False" />
21-
<TextBlock Name="MainLine" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="50,0,0,0" FontSize="16" Foreground="{StaticResource AccentColorBrush}" Text="An update is available. Do you want to update?" IsHitTestVisible="False" />
20+
<TextBlock Name="MainLine" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="50,0,0,0" FontSize="16" Foreground="{StaticResource AccentColorBrush}" Text="Update now?" IsHitTestVisible="False" />
2221
<TextBlock Name="SubLine" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="50,25,0,0" FontSize="14" IsHitTestVisible="False" />
2322
<Button Name="ActionYesButton" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="50,25,0,0" Content="Yes" Width="50" Click="ActionYesButton_Click" />
2423
<Button Name="ActionNoButton" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="110,25,0,0" Content="No" Width="50" Click="ActionNoButton_Click" />
25-
<TextBox Name="DescriptionBox" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,55,0,0" Height="145" VerticalScrollBarVisibility="Visible" IsReadOnly="True" />
26-
</Grid>
24+
<RichTextBox Name="DescriptionBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,55,0,0" VerticalScrollBarVisibility="Visible" IsReadOnly="True" />
25+
<Button x:Name="ActionGithubButton" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="170,25,0,0" Content="View on Github" Width="110" Click="ActionGithubButton_Click" />
26+
</Grid>
2727
</mahapps:MetroWindow>

Interop/Updater/UpdateWindow.xaml.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
using System.Diagnostics;
33
using System.IO;
44
using System.Net;
5+
using System.Reflection;
56
using System.Threading;
67
using System.Windows;
8+
using System.Windows.Controls;
9+
using Markdig;
710
using Octokit;
11+
using SPCode.Utils;
812

913
namespace SPCode.Interop.Updater
1014
{
@@ -21,11 +25,13 @@ public UpdateWindow()
2125
InitializeComponent();
2226
}
2327

24-
public UpdateWindow(UpdateInfo info)
28+
public UpdateWindow(UpdateInfo info) : this()
2529
{
2630
updateInfo = info;
27-
InitializeComponent();
28-
DescriptionBox.Text = updateInfo.Release.Body;
31+
32+
Title = $"Version {info.Release.TagName} is available for download!";
33+
DescriptionBox.AppendText(Markdown.ToPlainText(updateInfo.Release.Body));
34+
2935
if (info.SkipDialog)
3036
{
3137
StartUpdate();
@@ -52,9 +58,10 @@ private void StartUpdate()
5258

5359
ActionYesButton.Visibility = Visibility.Hidden;
5460
ActionNoButton.Visibility = Visibility.Hidden;
61+
Icon.Visibility = Visibility.Hidden;
5562
Progress.IsActive = true;
5663
MainLine.Text = "Updating to " + updateInfo.Release.TagName;
57-
SubLine.Text = "Downloading Updater";
64+
SubLine.Text = "Downloading updater...";
5865
var t = new Thread(UpdateDownloadWorker);
5966
t.Start();
6067
}
@@ -110,5 +117,10 @@ private void FinalizeUpdate()
110117

111118
Close();
112119
}
120+
121+
private void ActionGithubButton_Click(object sender, RoutedEventArgs e)
122+
{
123+
Process.Start(new ProcessStartInfo(Constants.GitHubLatestRelease));
124+
}
113125
}
114126
}

Spcode.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
<HintPath>packages\MahApps.Metro.1.6.5\lib\net45\MahApps.Metro.dll</HintPath>
8686
<Private>True</Private>
8787
</Reference>
88+
<Reference Include="Markdig, Version=0.23.0.0, Culture=neutral, processorArchitecture=MSIL">
89+
<HintPath>packages\Markdig.0.23.0\lib\net452\Markdig.dll</HintPath>
90+
</Reference>
8891
<Reference Include="Microsoft.CSharp" />
8992
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.4.0, Culture=neutral, PublicKeyToken=8985beaab7ea3f04, processorArchitecture=MSIL">
9093
<HintPath>packages\Microsoft-WindowsAPICodePack-Core.1.1.4\lib\net48\Microsoft.WindowsAPICodePack.dll</HintPath>

Utils/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public class Constants
44
{
55
public static string GitHubNewIssueLink = "https://github.com/Hexer10/SPCode/issues/new";
6+
public static string GitHubLatestRelease = "https://github.com/Hexer10/SPCode/releases/latest";
67
public static string DiscordRPCAppID = "692110664948514836";
78
public static string JavaDownloadSite64 = "https://api.adoptopenjdk.net/v3/installer/latest/15/ga/windows/x64/jdk/hotspot/normal/adoptopenjdk?project=jdk";
89
public static string JavaDownloadSite32 = "https://api.adoptopenjdk.net/v3/installer/latest/15/ga/windows/x32/jdk/hotspot/normal/adoptopenjdk?project=jdk";

packages.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<package id="DiscordRichPresence" version="1.0.150" targetFramework="net45" />
77
<package id="Extended.Wpf.Toolkit" version="2.9" targetFramework="net45" />
88
<package id="MahApps.Metro" version="1.6.5" targetFramework="net45" />
9-
<package id="Microsoft-WindowsAPICodePack-Core" version="1.1.4" targetFramework="net48" />
9+
<package id="Markdig" version="0.23.0" targetFramework="net48" />
10+
<package id="Microsoft-WindowsAPICodePack-Core" version="1.1.4" targetFramework="net48" />
1011
<package id="Microsoft-WindowsAPICodePack-Shell" version="1.1.4" targetFramework="net48" />
1112
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net45" />
1213
<package id="Octokit" version="0.46.0" targetFramework="net48" />

0 commit comments

Comments
 (0)