This commit is contained in:
Asval 2024-10-06 02:37:04 +02:00
parent 2d001ff21f
commit 0060635e66
13 changed files with 214 additions and 123 deletions

View File

@ -151,13 +151,7 @@
<MenuItem.Icon>
<Viewbox Width="16" Height="16">
<Canvas Width="24" Height="24">
<Path StrokeThickness="2" Stroke="{DynamicResource {x:Static adonisUi:Brushes.AccentForegroundBrush}}" Data="M16 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" />
<Path StrokeThickness="2" Stroke="{DynamicResource {x:Static adonisUi:Brushes.AccentForegroundBrush}}" Data="M12 8m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" />
<Path StrokeThickness="2" Stroke="{DynamicResource {x:Static adonisUi:Brushes.AccentForegroundBrush}}" Data="M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" />
<Path StrokeThickness="2" Stroke="{DynamicResource {x:Static adonisUi:Brushes.AccentForegroundBrush}}" Data="M12 15v-6" />
<Path StrokeThickness="2" Stroke="{DynamicResource {x:Static adonisUi:Brushes.AccentForegroundBrush}}" Data="M15 11l-2 -2" />
<Path StrokeThickness="2" Stroke="{DynamicResource {x:Static adonisUi:Brushes.AccentForegroundBrush}}" Data="M11 7l-1.9 -1.9" />
<Path StrokeThickness="2" Stroke="{DynamicResource {x:Static adonisUi:Brushes.AccentForegroundBrush}}" Data="M13.446 2.6l7.955 7.954a2.045 2.045 0 0 1 0 2.892l-7.955 7.955a2.045 2.045 0 0 1 -2.892 0l-7.955 -7.955a2.045 2.045 0 0 1 0 -2.892l7.955 -7.955a2.045 2.045 0 0 1 2.892 0z" />
<Path Fill="{DynamicResource {x:Static adonisUi:Brushes.AccentForegroundBrush}}" Data="{StaticResource GitHubIcon}" />
</Canvas>
</Viewbox>
</MenuItem.Icon>
@ -803,13 +797,17 @@
<Style TargetType="StatusBarItem">
<Style.Triggers>
<DataTrigger Binding="{Binding IsAutoOpenSounds, Source={x:Static settings:UserSettings.Default}}" Value="False">
<Setter Property="Visibility" Value="Hidden" />
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</StatusBarItem.Style>
<TextBlock HorizontalAlignment="Center" FontWeight="SemiBold" Text="SND" />
</StatusBarItem>
<StatusBarItem Margin="10 0 0 0">
<TextBlock Text="{Binding LastUpdateCheck, Source={x:Static local:Settings.UserSettings.Default}, Converter={x:Static converters:RelativeDateTimeConverter.Instance}, StringFormat=Last Refresh: {0}}" />
</StatusBarItem>
</StackPanel>
</StatusBarItem>
</StatusBar>

View File

@ -186,6 +186,20 @@ namespace FModel.Settings
set => SetProperty(ref _updateMode, value);
}
private DateTime _lastUpdateCheck = DateTime.MinValue;
public DateTime LastUpdateCheck
{
get => _lastUpdateCheck;
set => SetProperty(ref _lastUpdateCheck, value);
}
private DateTime _nextUpdateCheck = DateTime.Now;
public DateTime NextUpdateCheck
{
get => _nextUpdateCheck;
set => SetProperty(ref _nextUpdateCheck, value);
}
private string _commitHash = Constants.APP_VERSION;
public string CommitHash
{

View File

@ -119,6 +119,8 @@ public class FModelApiEndpoint : AbstractApiProvider
public void CheckForUpdates(EUpdateMode updateMode, bool launch = false)
{
if (DateTime.Now < UserSettings.Default.NextUpdateCheck) return;
if (launch)
{
AutoUpdater.ParseUpdateInfoEvent += ParseUpdateInfoEvent;
@ -150,6 +152,7 @@ public class FModelApiEndpoint : AbstractApiProvider
{
if (args is { CurrentVersion: { } })
{
UserSettings.Default.LastUpdateCheck = DateTime.Now;
var qa = (CustomMandatory) args.Mandatory;
var currentVersion = new System.Version(args.CurrentVersion);
if ((qa.Value && qa.CommitHash == UserSettings.Default.CommitHash) || // qa branch : same commit id

View File

@ -18,9 +18,6 @@ public class GitHubApiEndpoint : AbstractApiProvider
request.AddParameter("page", page);
request.AddParameter("per_page", limit);
var response = await _client.ExecuteAsync<GitHubCommit[]>(request).ConfigureAwait(false);
#if DEBUG
System.IO.File.WriteAllTextAsync(@"C:\Users\valen\Downloads\history.json", Newtonsoft.Json.JsonConvert.SerializeObject(response.Data));
#endif
return response.Data;
}
@ -28,9 +25,6 @@ public class GitHubApiEndpoint : AbstractApiProvider
{
var request = new FRestRequest($"{Constants.GH_RELEASES}/tags/{tag}");
var response = await _client.ExecuteAsync<GitHubRelease>(request).ConfigureAwait(false);
#if DEBUG
System.IO.File.WriteAllTextAsync(@"C:\Users\valen\Downloads\qa.json", Newtonsoft.Json.JsonConvert.SerializeObject(response.Data));
#endif
return response.Data;
}
}

View File

@ -1,6 +1,13 @@
using System;
using System.Windows;
using AdonisUI.Controls;
using AutoUpdaterDotNET;
using FModel.Framework;
using FModel.Settings;
using MessageBox = AdonisUI.Controls.MessageBox;
using MessageBoxButton = AdonisUI.Controls.MessageBoxButton;
using MessageBoxImage = AdonisUI.Controls.MessageBoxImage;
using MessageBoxResult = AdonisUI.Controls.MessageBoxResult;
using J = Newtonsoft.Json.JsonPropertyAttribute;
namespace FModel.ViewModels.ApiEndpoints.Models;
@ -58,6 +65,37 @@ public class GitHubCommit : ViewModel
public bool IsCurrent => Sha == UserSettings.Default.CommitHash;
public string ShortSha => Sha[..7];
public bool IsDownloadable => Asset != null;
public void Download()
{
if (IsCurrent) return;
var messageBox = new MessageBoxModel
{
Text = $"Are you sure you want to update to version '{ShortSha}'?{(!Asset.IsLatest ? "\nThis is not the latest version." : "")}",
Caption = "Update FModel",
Icon = MessageBoxImage.Question,
Buttons = MessageBoxButtons.YesNo(),
IsSoundEnabled = false
};
MessageBox.Show(messageBox);
if (messageBox.Result != MessageBoxResult.Yes) return;
try
{
if (AutoUpdater.DownloadUpdate(new UpdateInfoEventArgs { DownloadURL = Asset.BrowserDownloadUrl }))
{
UserSettings.Default.CommitHash = Sha;
Application.Current.Shutdown();
}
}
catch (Exception exception)
{
UserSettings.Default.ShowChangelog = false;
MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
public class Commit

View File

@ -0,0 +1,40 @@
using System;
using FModel.Framework;
using FModel.Settings;
namespace FModel.ViewModels.Commands;
public class RemindMeCommand : ViewModelCommand<UpdateViewModel>
{
public RemindMeCommand(UpdateViewModel contextViewModel) : base(contextViewModel)
{
}
public override void Execute(UpdateViewModel contextViewModel, object parameter)
{
switch (parameter)
{
case "Days":
// check for update in 3 days
UserSettings.Default.NextUpdateCheck = DateTime.Now.AddDays(3);
break;
case "Week":
// check for update next week (a week starts on Monday)
var delay = DayOfWeek.Monday - DateTime.Now.DayOfWeek;
UserSettings.Default.NextUpdateCheck = DateTime.Now.AddDays(delay);
break;
case "Month":
// check for update next month (if today is 31st, it will be 1st of next month)
UserSettings.Default.NextUpdateCheck = DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(1);
break;
case "Never":
// never check for updates
UserSettings.Default.NextUpdateCheck = DateTime.MaxValue;
break;
default:
// reset
UserSettings.Default.NextUpdateCheck = DateTime.Now;
break;
}
}
}

View File

@ -6,6 +6,7 @@ using FModel.Extensions;
using FModel.Framework;
using FModel.Services;
using FModel.ViewModels.ApiEndpoints.Models;
using FModel.ViewModels.Commands;
using FModel.Views.Resources.Converters;
namespace FModel.ViewModels;
@ -14,6 +15,9 @@ public class UpdateViewModel : ViewModel
{
private ApiEndpointViewModel _apiEndpointView => ApplicationService.ApiEndpointView;
private RemindMeCommand _remindMeCommand;
public RemindMeCommand RemindMeCommand => _remindMeCommand ??= new RemindMeCommand(this);
public RangeObservableCollection<GitHubCommit> Commits { get; }
public ICollectionView CommitsView { get; }
@ -28,15 +32,11 @@ public class UpdateViewModel : ViewModel
public async Task Load()
{
#if DEBUG
Commits.AddRange(Newtonsoft.Json.JsonConvert.DeserializeObject<GitHubCommit[]>(await System.IO.File.ReadAllTextAsync(@"C:\Users\valen\Downloads\history.json")));
var qa = Newtonsoft.Json.JsonConvert.DeserializeObject<GitHubRelease>(await System.IO.File.ReadAllTextAsync(@"C:\Users\valen\Downloads\qa.json"));
#else
Commits.AddRange(await _apiEndpointView.GitHubApi.GetCommitHistoryAsync());
var qa = await _apiEndpointView.GitHubApi.GetReleaseAsync("qa");
#endif
var qa = await _apiEndpointView.GitHubApi.GetReleaseAsync("qa");
qa.Assets.OrderByDescending(x => x.CreatedAt).First().IsLatest = true;
foreach (var asset in qa.Assets)
{
var commitSha = asset.Name.SubstringBeforeLast(".zip");
@ -47,4 +47,9 @@ public class UpdateViewModel : ViewModel
}
}
}
public void DownloadLatest()
{
Commits.FirstOrDefault(x => x.Asset.IsLatest)?.Download();
}
}

View File

@ -29,12 +29,12 @@
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding IsCurrent}" Value="True">
<Setter Property="Text" Value="Current" />
</DataTrigger>
<DataTrigger Binding="{Binding Asset.IsLatest}" Value="True">
<Setter Property="Text" Value="Latest" />
</DataTrigger>
<DataTrigger Binding="{Binding IsCurrent}" Value="True">
<Setter Property="Text" Value="Current" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
@ -44,16 +44,16 @@
<Style TargetType="Border">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsCurrent}" Value="True">
<Setter Property="Visibility" Value="Visible" />
<Setter Property="BorderBrush" Value="#3f92b9" />
<Setter Property="Background" Value="#0f3f92b9" />
</DataTrigger>
<DataTrigger Binding="{Binding Asset.IsLatest}" Value="True">
<Setter Property="Visibility" Value="Visible" />
<Setter Property="BorderBrush" Value="#3fb950" />
<Setter Property="Background" Value="#0f3fb950" />
</DataTrigger>
<DataTrigger Binding="{Binding IsCurrent}" Value="True">
<Setter Property="Visibility" Value="Visible" />
<Setter Property="BorderBrush" Value="#3f92b9" />
<Setter Property="Background" Value="#0f3f92b9" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>

View File

@ -1,14 +1,6 @@
using System;
using System.Windows;
using System.Windows;
using System.Windows.Controls;
using AdonisUI.Controls;
using AutoUpdaterDotNET;
using FModel.Settings;
using FModel.ViewModels.ApiEndpoints.Models;
using MessageBox = AdonisUI.Controls.MessageBox;
using MessageBoxButton = AdonisUI.Controls.MessageBoxButton;
using MessageBoxImage = AdonisUI.Controls.MessageBoxImage;
using MessageBoxResult = AdonisUI.Controls.MessageBoxResult;
namespace FModel.Views.Resources.Controls;
@ -30,33 +22,7 @@ public partial class CommitDownloaderControl : UserControl
private void OnDownload(object sender, RoutedEventArgs e)
{
if (Commit.IsCurrent) return;
var messageBox = new MessageBoxModel
{
Text = $"Are you sure you want to update to version '{Commit.ShortSha}'?{(!Commit.Asset.IsLatest ? "\nThis is not the latest version." : "")}",
Caption = "Update FModel",
Icon = MessageBoxImage.Question,
Buttons = MessageBoxButtons.YesNo(),
IsSoundEnabled = false
};
MessageBox.Show(messageBox);
if (messageBox.Result != MessageBoxResult.Yes) return;
try
{
if (AutoUpdater.DownloadUpdate(new UpdateInfoEventArgs { DownloadURL = Commit.Asset.BrowserDownloadUrl }))
{
UserSettings.Default.CommitHash = Commit.Sha;
Application.Current.Shutdown();
}
}
catch (Exception exception)
{
UserSettings.Default.ShowChangelog = false;
MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
}
Commit.Download();
}
}

View File

@ -16,6 +16,9 @@ public class RelativeDateTimeConverter : IValueConverter
int time;
string unit;
if (timeSpan.TotalSeconds < 30)
return "Just now";
if (timeSpan.TotalMinutes < 1)
{
time = timeSpan.Seconds;

View File

@ -69,6 +69,7 @@
<Geometry x:Key="LocateMeIcon">M11.71,17.99C8.53,17.84,6,15.22,6,12c0-3.31,2.69-6,6-6c3.22,0,5.84,2.53,5.99,5.71l-2.1-0.63C15.48,9.31,13.89,8,12,8 c-2.21,0-4,1.79-4,4c0,1.89,1.31,3.48,3.08,3.89L11.71,17.99z M22,12c0,0.3-0.01,0.6-0.04,0.9l-1.97-0.59C20,12.21,20,12.1,20,12 c0-4.42-3.58-8-8-8s-8,3.58-8,8s3.58,8,8,8c0.1,0,0.21,0,0.31-0.01l0.59,1.97C12.6,21.99,12.3,22,12,22C6.48,22,2,17.52,2,12 C2,6.48,6.48,2,12,2S22,6.48,22,12z M18.23,16.26l2.27-0.76c0.46-0.15,0.45-0.81-0.01-0.95l-7.6-2.28 c-0.38-0.11-0.74,0.24-0.62,0.62l2.28,7.6c0.14,0.47,0.8,0.48,0.95,0.01l0.76-2.27l3.91,3.91c0.2,0.2,0.51,0.2,0.71,0l1.27-1.27 c0.2-0.2,0.2-0.51,0-0.71L18.23,16.26z</Geometry>
<Geometry x:Key="MeshIcon">M1.8 6q-.525 0-.887-.35Q.55 5.3.55 4.8V4q0-1.425 1.012-2.438Q2.575.55 4 .55h.8q.5 0 .85.362.35.363.35.888 0 .5-.35.85T4.8 3H4q-.425 0-.712.287Q3 3.575 3 4v.8q0 .5-.35.85T1.8 6ZM4 23.45q-1.425 0-2.438-1.012Q.55 21.425.55 20v-.8q0-.5.363-.85.362-.35.887-.35.5 0 .85.35t.35.85v.8q0 .425.288.712Q3.575 21 4 21h.8q.5 0 .85.35t.35.85q0 .525-.35.887-.35.363-.85.363Zm15.2 0q-.5 0-.85-.363-.35-.362-.35-.887 0-.5.35-.85t.85-.35h.8q.425 0 .712-.288Q21 20.425 21 20v-.8q0-.5.35-.85t.85-.35q.525 0 .888.35.362.35.362.85v.8q0 1.425-1.012 2.438Q21.425 23.45 20 23.45ZM22.2 6q-.5 0-.85-.35T21 4.8V4q0-.425-.288-.713Q20.425 3 20 3h-.8q-.5 0-.85-.35T18 1.8q0-.525.35-.888.35-.362.85-.362h.8q1.425 0 2.438 1.012Q23.45 2.575 23.45 4v.8q0 .5-.362.85-.363.35-.888.35ZM12 17.35l1-.575v-4.1l3.55-2.075V9.425l-1-.575L12 10.925 8.45 8.85l-1 .575V10.6L11 12.675v4.1Zm-1.325 2.325-4.55-2.65q-.625-.35-.975-.963-.35-.612-.35-1.337V9.45q0-.725.35-1.337.35-.613.975-.963l4.55-2.65Q11.3 4.15 12 4.15t1.325.35l4.55 2.65q.625.35.975.963.35.612.35 1.337v5.275q0 .725-.35 1.337-.35.613-.975.963l-4.55 2.65q-.625.35-1.325.35t-1.325-.35Z</Geometry>
<Geometry x:Key="ArchiveIcon">M3.5 1.75v11.5c0 .09.048.173.126.217a.75.75 0 0 1-.752 1.298A1.748 1.748 0 0 1 2 13.25V1.75C2 .784 2.784 0 3.75 0h5.586c.464 0 .909.185 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 12.25 15h-.5a.75.75 0 0 1 0-1.5h.5a.25.25 0 0 0 .25-.25V4.664a.25.25 0 0 0-.073-.177L9.513 1.573a.25.25 0 0 0-.177-.073H7.25a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5h-3a.25.25 0 0 0-.25.25Zm3.75 8.75h.5c.966 0 1.75.784 1.75 1.75v3a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1-.75-.75v-3c0-.966.784-1.75 1.75-1.75ZM6 5.25a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 6 5.25Zm.75 2.25h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5ZM8 6.75A.75.75 0 0 1 8.75 6h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 8 6.75ZM8.75 3h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5ZM8 9.75A.75.75 0 0 1 8.75 9h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 8 9.75Zm-1 2.5v2.25h1v-2.25a.25.25 0 0 0-.25-.25h-.5a.25.25 0 0 0-.25.25Z</Geometry>
<Geometry x:Key="GitHubIcon">M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z</Geometry>
<Style x:Key="TabItemFillSpace" TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
<Setter Property="Width">

View File

@ -1,7 +1,9 @@
<adonisControls:AdonisWindow x:Class="FModel.Views.UpdateView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FModel"
xmlns:converters="clr-namespace:FModel.Views.Resources.Converters"
xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI"
xmlns:adonisExtensions="clr-namespace:AdonisUI.Extensions;assembly=AdonisUI"
xmlns:adonisControls="clr-namespace:AdonisUI.Controls;assembly=AdonisUI"
xmlns:controls="clr-namespace:FModel.Views.Resources.Controls"
@ -20,10 +22,28 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</adonisControls:AdonisWindow.Resources>
<DockPanel>
<StackPanel DockPanel.Dock="Top">
<StackPanel.Style>
<Style TargetType="StackPanel">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center" Margin="10">
All releases listed below are available for download. They are sorted by date, with the latest release at the top.
We regularly remove old ones to keep the list clean and up to date with the latest UE releases.
If you wish to manually check for updates, this window is accessible via the Help > Releases menu.
</TextBlock>
<Grid Grid.Row="1" HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding Title, RelativeSource={RelativeSource AncestorType=adonisControls:AdonisWindow}}" Value="Releases">
@ -31,62 +51,64 @@
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
</Grid.Style>
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Center">
<Button>Download Latest Release</Button>
<TextBlock Text="Remind Me:" />
<ComboBox>
<ComboBoxItem Content="In 3 Days" />
<ComboBoxItem Content="Next Week" />
<ComboBoxItem Content="Next Month" />
<!-- TODO: show that it can be manually updated via Help > Releases -->
<ComboBoxItem Content="Never" />
</ComboBox>
</WrapPanel>
<Button Grid.Column="0" Style="{DynamicResource {x:Static adonisUi:Styles.AccentButton}}"
VerticalAlignment="Top" Height="{Binding ActualHeight, ElementName=RemindButton}"
Click="OnDownloadLatest">
Download Latest Release
</Button>
<StackPanel Grid.Column="2">
<adonisControls:SplitButton x:Name="RemindButton" Content="Remind Me Now ..." Command="{Binding RemindMeCommand}">
<adonisControls:SplitButton.SplitMenu>
<ContextMenu>
<MenuItem Header="In 3 Days" Command="{Binding RemindMeCommand}" CommandParameter="Days" />
<MenuItem Header="Next Week" Command="{Binding RemindMeCommand}" CommandParameter="Week" />
<MenuItem Header="Next Month" Command="{Binding RemindMeCommand}" CommandParameter="Month" />
<MenuItem Header="Never" Command="{Binding RemindMeCommand}" CommandParameter="Never" />
</ContextMenu>
</adonisControls:SplitButton.SplitMenu>
</adonisControls:SplitButton>
<TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Right" FontSize="10" Margin="0 2.5 0 0"
Text="{Binding NextUpdateCheck, Source={x:Static local:Settings.UserSettings.Default}, StringFormat=Next Refresh: {0:MMM d, yyyy}}" />
</StackPanel>
</Grid>
<Separator Style="{StaticResource CustomSeparator}" Tag="History" />
</StackPanel>
<ItemsControl DockPanel.Dock="Bottom" ItemsSource="{Binding CommitsView}">
<ItemsControl.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="GroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupItem">
<GroupBox adonisExtensions:LayerExtension.Layer="3"
Header="{Binding Name}"
HeaderStringFormat="Commits on {0:MMM d, yyyy}"
Margin="0 0 0 5">
<ItemsPresenter />
</GroupBox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</ItemsControl.GroupStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<controls:CommitControl Margin="0 0 0 1" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
</DockPanel>
<Separator Grid.Row="2" Style="{StaticResource CustomSeparator}" Tag="History" />
<ScrollViewer Grid.Row="3" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding CommitsView}">
<ItemsControl.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="GroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupItem">
<GroupBox adonisExtensions:LayerExtension.Layer="3"
Header="{Binding Name}"
HeaderStringFormat="Commits on {0:MMM d, yyyy}"
Margin="0 0 0 5">
<ItemsPresenter />
</GroupBox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</ItemsControl.GroupStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<controls:CommitControl Margin="0 0 0 1" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</adonisControls:AdonisWindow>

View File

@ -1,5 +1,6 @@
using System.Windows;
using FModel.ViewModels;
using FModel.Views.Resources.Controls;
namespace FModel.Views;
@ -16,5 +17,11 @@ public partial class UpdateView
if (DataContext is not UpdateViewModel viewModel) return;
await viewModel.Load();
}
private void OnDownloadLatest(object sender, RoutedEventArgs e)
{
if (DataContext is not UpdateViewModel viewModel) return;
viewModel.DownloadLatest();
}
}