Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions WPILibInstaller-Avalonia/ViewModels/DeprecatedOsPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,65 @@
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Reactive;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using ReactiveUI;
using WPILibInstaller.Interfaces;
using WPILibInstaller.Models;
using WPILibInstaller.Utils;

namespace WPILibInstaller.ViewModels
{
public class DeprecatedOsPageViewModel : PageViewModelBase
{
private readonly IViewModelResolver viewModelResolver;
private readonly IConfigurationProvider configurationProvider;

public DeprecatedOsPageViewModel(IViewModelResolver viewModelResolver)
public DeprecatedOsPageViewModel(IViewModelResolver viewModelResolver, IConfigurationProvider configurationProvider)
: base("I Understand", "")
{
this.viewModelResolver = viewModelResolver;
this.configurationProvider = configurationProvider;

var version = Environment.OSVersion;
var bitness = IntPtr.Size == 8 ? "64 Bit" : "32 Bit";
CurrentSystem = $"Detected {version.VersionString} {bitness}";
bool isWindows10 = OperatingSystem.IsWindowsVersionAtLeast(10);
bool is64Bit = IntPtr.Size == 8;
if (!isWindows10 || !is64Bit)
{
DeprecatedMessage1 = "You are using an unsupported Operating System or Architecture";
DeprecatedMessage2 = "You will not be able to install or run WPILib " + this.configurationProvider.UpgradeConfig.FrcYear;
}
else if (isWindows10 && Environment.OSVersion.Version.Build < 22000)
{
DeprecatedMessage1 = "You are using Windows 10, which is no longer supported by Microsoft";
DeprecatedMessage2 = "You may not be able to install or run future year's versions of WPILib";
}
else
{
DeprecatedMessage1 = "Unknown Error";
DeprecatedMessage2 = "";
}

CancelCommand = ReactiveCommand.Create(ExitApplication);
}

public string CurrentSystem { get; }

public string DeprecatedMessage1 { get; }
public string DeprecatedMessage2 { get; }

public ReactiveCommand<Unit, Unit> CancelCommand { get; }

public override PageViewModelBase MoveNext()
{
return viewModelResolver.Resolve<StartPageViewModel>();
return viewModelResolver.Resolve<ConfigurationPageViewModel>();
}

private void ExitApplication()
{
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.Shutdown();
}
}
}
}
10 changes: 0 additions & 10 deletions WPILibInstaller-Avalonia/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,6 @@ public ReactiveCommand<Unit, Unit> CreateCatchableButton(Func<Task> toRun)

public void Initialize()
{
if (OperatingSystem.IsWindows())
{
bool isWindows10 = OperatingSystem.IsWindowsVersionAtLeast(10);
bool is64Bit = IntPtr.Size == 8;
if (!isWindows10 || !is64Bit)
{
CurrentPage = viewModelResolver.Resolve<DeprecatedOsPageViewModel>();
return;
}
}
var startPage = viewModelResolver.Resolve<StartPageViewModel>();
CurrentPage = startPage;
startPage.Initialize();
Expand Down
10 changes: 10 additions & 0 deletions WPILibInstaller-Avalonia/ViewModels/StartPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,16 @@ public string InstallDirectory

public override PageViewModelBase MoveNext()
{
if (OperatingSystem.IsWindows())
{
bool isWindows10 = OperatingSystem.IsWindowsVersionAtLeast(10);
bool is64Bit = IntPtr.Size == 8;
if (!isWindows10 || !is64Bit || (isWindows10 && Environment.OSVersion.Version.Build < 22000))
{
return viewModelResolver.Resolve<DeprecatedOsPageViewModel>();
}
}

return viewModelResolver.Resolve<ConfigurationPageViewModel>();
}

Expand Down
14 changes: 10 additions & 4 deletions WPILibInstaller-Avalonia/Views/DeprecatedOsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
x:Class="WPILibInstaller.Views.DeprecatedOsPage">
<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock Text="You are using an out of date Operating System or Architecture"
<TextBlock Text="{Binding DeprecatedMessage1}"
HorizontalAlignment="Center"
FontWeight="Bold"
FontSize="25"
VerticalAlignment="Center"
TextAlignment="Center"
TextWrapping="Wrap"/>
<TextBlock Text="You will not be able to install or run WPILib 2023"
<TextBlock Text="{Binding DeprecatedMessage2}"
HorizontalAlignment="Center"
FontSize="20"
VerticalAlignment="Center" />
<TextBlock Text="Please upgrade to at least Windows 10 64 Bit"
VerticalAlignment="Center"/>
<TextBlock Text="Please upgrade to at least Windows 11 64 Bit"
HorizontalAlignment="Center"
FontSize="20"
VerticalAlignment="Center" />
Expand All @@ -29,5 +29,11 @@
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding CurrentSystem, Mode=OneWay}" />
<Button Content="Cancel"
HorizontalAlignment="Center"
Margin="20,20,20,20"
FontSize="20"
Padding="20,10"
Command="{Binding CancelCommand}" />
</StackPanel>
</UserControl>