mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Auto-update - Added update dialog
This commit is contained in:
1 parent
8e83310384
commit
e3c906390d
3 files changed
+119
-21
No files matched your search
@@ -0,0 +1,37 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Settings.Dialogs.UpdateDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline6TextBlock}" TextWrapping="Wrap">
|
||||
Update available
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
|
||||
Foreground="{DynamicResource MaterialDesignBodyLight}"
|
||||
Margin="0 20 0 20"
|
||||
TextWrapping="Wrap">
|
||||
A new Artemis update is available! 🥳<LineBreak/>
|
||||
You are currently running build <Run Text="{Binding CurrentBuild, Mode=OneWay}" /> while the latest build is <Run Text="{Binding LatestBuild, Mode=OneWay}" />. <LineBreak/> <LineBreak/>
|
||||
Updating Artemis will give you the latest bug(fixes), features and improvements.
|
||||
</TextBlock>
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 8 0 0">
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Focusable="False"
|
||||
IsCancel="True"
|
||||
Command="{s:Action Cancel}"
|
||||
Content="LATER" />
|
||||
<Button x:Name="ConfirmButton"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
IsDefault="True"
|
||||
Focusable="True"
|
||||
Command="{s:Action Update}"
|
||||
Content="UPDATE" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Services;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Dialogs
|
||||
{
|
||||
public class UpdateDialogViewModel : DialogViewModelBase
|
||||
{
|
||||
private readonly JToken _buildInfo;
|
||||
private readonly IUpdateService _updateService;
|
||||
|
||||
public UpdateDialogViewModel(JToken buildInfo, IUpdateService updateService)
|
||||
{
|
||||
_buildInfo = buildInfo;
|
||||
_updateService = updateService;
|
||||
CurrentBuild = Constants.BuildInfo.BuildNumberDisplay;
|
||||
LatestBuild = buildInfo?.SelectToken("value[0].buildNumber")?.Value<string>();
|
||||
}
|
||||
|
||||
public string CurrentBuild { get; }
|
||||
public string LatestBuild { get; }
|
||||
|
||||
public async Task Update()
|
||||
{
|
||||
await _updateService.ApplyUpdate();
|
||||
Session.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user