Skip to content

Commit

Permalink
add min windows version message
Browse files Browse the repository at this point in the history
  • Loading branch information
aspriddell committed Jul 3, 2023
1 parent 2008bab commit 10d28e0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions DragonFruit.Kaplan/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace DragonFruit.Kaplan
{
internal class Program
{
internal static Version MinWindowsVersion = new("10.0.19041");

public static string Version { get; } = typeof(Program).Assembly.GetName().Version!.ToString(3);
public static string AppTitle { get; } = $"DragonFruit Kaplan v{Version}";

Expand Down
11 changes: 9 additions & 2 deletions DragonFruit.Kaplan/Views/Welcome.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:kaplan="clr-namespace:DragonFruit.Kaplan"
xmlns:views="clr-namespace:DragonFruit.Kaplan.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="DragonFruit.Kaplan.Views.Welcome"
x:Class="DragonFruit.Kaplan.Views.Welcome" x:DataType="views:Welcome"
Icon="avares://DragonFruit.Kaplan/Assets/icon.ico"
CanResize="False" WindowStartupLocation="CenterScreen"
MinHeight="300" MinWidth="500" Height="300" Width="600"
Expand All @@ -19,12 +20,18 @@
</StackPanel>
</StackPanel>

<DockPanel DockPanel.Dock="Bottom" VerticalAlignment="Bottom">
<DockPanel IsVisible="{Binding WindowsVersionCompatible}" DockPanel.Dock="Bottom" VerticalAlignment="Bottom">
<Button DockPanel.Dock="Right" Click="CloseDialog">Continue</Button>
<Button DockPanel.Dock="Right" Click="OpenAboutDialog" Margin="10, 0">About</Button>

<CheckBox DockPanel.Dock="Left" IsChecked="{Binding BugReportingEnabled, Source={x:Static kaplan:App.Instance}}">Enable sending (anonymous) bug reports</CheckBox>
</DockPanel>

<TextBlock DockPanel.Dock="Bottom"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
IsVisible="{Binding ShowCompatabilityMessage}"
Text="{Binding CompatabilityErrorMessage}"/>
</DockPanel>
</Window.Content>
</Window>
7 changes: 7 additions & 0 deletions DragonFruit.Kaplan/Views/Welcome.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Kaplan Copyright (c) DragonFruit Network <[email protected]>
// Licensed under Apache-2. Refer to the LICENSE file for more info

using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
Expand All @@ -14,8 +15,14 @@ public partial class Welcome : Window
public Welcome()
{
InitializeComponent();
DataContext = this;
}

public bool ShowCompatabilityMessage => !WindowsVersionCompatible;
public bool WindowsVersionCompatible => Environment.OSVersion.Version >= Program.MinWindowsVersion;

public string CompatabilityErrorMessage => $"Windows {Program.MinWindowsVersion.ToString()} is required to use this program. This machine is currently running version {Environment.OSVersion.Version.ToString()}";

private async void OpenAboutDialog(object sender, RoutedEventArgs e)
{
await new About().ShowDialog(this).ConfigureAwait(false);
Expand Down

0 comments on commit 10d28e0

Please sign in to comment.