Skip to content

Commit

Permalink
Update .NET installer UI and functionality
Browse files Browse the repository at this point in the history
- MagicChatbox.csproj: Removed and re-added csharp-bot.png as a resource.
- DotNetInstallerWindow.xaml: Enhanced UI with new colors, added csharp-bot.png image, and updated text and styling for .NET 8 upgrade.
- DotNetInstallerWindow.xaml.cs: Added LINQ support, updated .NET installer URL to 8.0.8, refactored .NET 8 check, improved process restart, and added event handler for "What is .NET?" link.
  • Loading branch information
BoiHanny committed Aug 22, 2024
1 parent 54a656b commit 0f6007b
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 46 deletions.
Binary file added vrcosc-magicchatbox/Img/Icons/csharp-bot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions vrcosc-magicchatbox/MagicChatbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<None Remove="Img\Icons\Copy_ico.png" />
<None Remove="Img\Icons\Cross_ico.png" />
<None Remove="Img\Icons\Cross_v1_ico.png" />
<None Remove="Img\Icons\csharp-bot.png" />
<None Remove="Img\Icons\Cut_ico.png" />
<None Remove="Img\Icons\Delete_ico.png" />
<None Remove="Img\Icons\Discord.png" />
Expand Down Expand Up @@ -112,6 +113,7 @@
<Resource Include="Img\Icons\Copy_ico.png" />
<Resource Include="Img\Icons\Cross_ico.png" />
<Resource Include="Img\Icons\Cross_v1_ico.png" />
<Resource Include="Img\Icons\csharp-bot.png" />
<Resource Include="Img\Icons\Cut_ico.png" />
<Resource Include="Img\Icons\Delete_ico.png">
<CopyToOutputDirectory></CopyToOutputDirectory>
Expand Down
119 changes: 92 additions & 27 deletions vrcosc-magicchatbox/UI/Dialogs/DotNetInstallerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<RowDefinition Height="50" />
</Grid.RowDefinitions>

<!-- Header Area -->
<!-- Header Area -->
<Grid x:Name="Drag_area" Grid.Row="0">
<Grid.Background>
<LinearGradientBrush StartPoint="0,1" EndPoint="0.5,1">
Expand Down Expand Up @@ -66,12 +66,26 @@
</TextBlock.Effect>
</TextBlock>
</StackPanel>
<TextBlock
x:Name="WhatsNET"
Width="auto"
Margin="0,0,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Cursor="Hand"
FontFamily="Albert Sans Thin"
FontSize="13"
Foreground="MediumPurple"
MouseUp="WhatsNET_MouseUp"
Text="What is .NET?"
TextDecorations="Underline"
WindowChrome.IsHitTestVisibleInChrome="True" />
</Grid>

<!-- Main Content Area -->
<!-- Main Content Area -->
<Grid Grid.Row="1">
<!-- First Page: Checking for .NET 8 -->
<Grid x:Name="CheckDotNetPage">
<!-- First Page: Checking for .NET 8 -->
<Grid x:Name="CheckDotNetPage" Background="#41375B">
<TextBlock
Margin="25"
HorizontalAlignment="Center"
Expand All @@ -91,16 +105,20 @@
</TextBlock>
</Grid>

<!-- Second Page: Ask to Install .NET 8 -->
<Grid x:Name="AskInstallPage" Visibility="Hidden">
<!-- Second Page: Ask to Install .NET 8 -->
<StackPanel
x:Name="AskInstallPage"
Background="#41375B"
RenderOptions.BitmapScalingMode="NearestNeighbor"
Visibility="Hidden">
<TextBlock
Margin="25"
Margin="0,10,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontFamily="Comfortaa Light"
FontSize="20"
Foreground="White"
Text=".NET 8 is not installed on your system."
FontSize="22"
FontWeight="DemiBold"
Text="It's time for a little upgrade magic! ✨"
TextAlignment="Center">
<TextBlock.Effect>
<DropShadowEffect
Expand All @@ -109,15 +127,20 @@
ShadowDepth="0"
Color="#251153" />
</TextBlock.Effect>
<TextBlock.Foreground>
<RadialGradientBrush>
<GradientStop Color="White" />
<GradientStop Offset="1" Color="#FFC3A9FF" />
</RadialGradientBrush>
</TextBlock.Foreground>
</TextBlock>
<Image Height="100" Source="/Img/Icons/csharp-bot.png" />
<TextBlock
Margin="25,60,25,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontFamily="Comfortaa Light"
FontSize="16"
Foreground="LightYellow"
Text="Would you like to install .NET 8 now?"
Text=".NET 6 is saying goodbye, and so are we! 🚀"
TextAlignment="Center">
<TextBlock.Effect>
<DropShadowEffect
Expand All @@ -126,11 +149,46 @@
ShadowDepth="0"
Color="#251153" />
</TextBlock.Effect>
<TextBlock.Foreground>
<RadialGradientBrush>
<GradientStop Color="White" />
<GradientStop Offset="2" Color="#FFC3A9FF" />
</RadialGradientBrush>
</TextBlock.Foreground>
</TextBlock>
</Grid>

<!-- Third Page: Installing .NET 8 -->
<Grid x:Name="InstallDotNetPage" Visibility="Hidden">
<TextBlock
Margin="0,35,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontFamily="Comfortaa Light"
FontSize="16"
Text="Keep the magic going and unlock new features and stay safe, make sure to install .NET 8!"
TextAlignment="Center">
<TextBlock.Effect>
<DropShadowEffect
BlurRadius="10"
Opacity="1"
ShadowDepth="0"
Color="#251153" />
</TextBlock.Effect>
<TextBlock.Foreground>
<RadialGradientBrush>
<GradientStop Color="White" />
<GradientStop Offset="2" Color="#FFC3A9FF" />
</RadialGradientBrush>
</TextBlock.Foreground>
</TextBlock>



</StackPanel>

<!-- Third Page: Installing .NET 8 -->
<Grid
x:Name="InstallDotNetPage"
Background="#41375B"
Visibility="Hidden">
<TextBlock
Margin="25"
HorizontalAlignment="Center"
Expand All @@ -155,20 +213,23 @@
Margin="0,60,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
IsIndeterminate="True"
Foreground="YellowGreen" />
Foreground="YellowGreen"
IsIndeterminate="True" />
</Grid>

<!-- Fourth Page: Confirmation -->
<Grid x:Name="ConfirmDotNetPage" Visibility="Hidden">
<!-- Fourth Page: Confirmation -->
<Grid
x:Name="ConfirmDotNetPage"
Background="#41375B"
Visibility="Hidden">
<TextBlock
Margin="25"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontFamily="Comfortaa Light"
FontSize="20"
Foreground="White"
Text=".NET 8 is installed and ready for use!"
Text=".NET 8 is installed, MagicChatbox can soon run on .NET 8."
TextAlignment="Center">
<TextBlock.Effect>
<DropShadowEffect
Expand All @@ -192,17 +253,21 @@
</Grid>
</Grid>

<!-- Footer with Navigation Buttons -->
<Grid Grid.Row="2" HorizontalAlignment="Center" Margin="10,0">
<!-- Footer with Navigation Buttons -->
<Grid
Grid.Row="2"
Margin="10,0"
HorizontalAlignment="Center"
Background="#41375B">
<StackPanel Orientation="Horizontal">
<Button
x:Name="CancelButton"
Width="100"
Height="40"
Margin="10,0"
Click="CancelButton_Click"
Visibility="Hidden"
Style="{StaticResource Status_Button_style}">
Style="{StaticResource Status_Button_style}"
Visibility="Hidden">
<TextBlock FontSize="16" Text="Cancel" />
</Button>
<Button
Expand All @@ -211,8 +276,8 @@
Height="40"
Margin="10,0"
Click="NextButton_Click"
Visibility="Hidden"
Style="{StaticResource Status_Button_style}">
Style="{StaticResource Status_Button_style}"
Visibility="Hidden">
<TextBlock FontSize="16" Text="Next" />
</Button>
</StackPanel>
Expand Down
63 changes: 44 additions & 19 deletions vrcosc-magicchatbox/UI/Dialogs/DotNetInstallerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Security.Principal;
Expand Down Expand Up @@ -77,8 +78,8 @@ public async Task InstallDotNet8Async()
return;
}

string installerUrl = "https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-8.0.0-windows-x64-installer";
string installerPath = Path.Combine(Path.GetTempPath(), "dotnet-runtime-8.0.0-win-x64.exe");
string installerUrl = "https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-8.0.8-windows-x64-installer";
string installerPath = Path.Combine(Path.GetTempPath(), "runtime-desktop-8.0.8-windows-x64-installer.exe");

using (WebClient client = new WebClient())
{
Expand Down Expand Up @@ -110,28 +111,41 @@ public async Task InstallDotNet8Async()
}
}

public bool IsDotNet8Installed()

public bool IsDotNet8Installed()
{
try
{
try
// Path where Microsoft.WindowsDesktop.App runtimes are installed
string desktopRuntimePath = @"C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App";

if (Directory.Exists(desktopRuntimePath))
{
var key = @"SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedhost";
using (var registryKey = Registry.LocalMachine.OpenSubKey(key))
// Get all subdirectories (version folders)
var versionFolders = Directory.GetDirectories(desktopRuntimePath)
.Select(Path.GetFileName)
.Where(name => name.StartsWith("10."))
.ToList();

// If any folder starts with "8.", .NET 8 is installed
if (versionFolders.Any())
{
if (registryKey != null)
{
var version = registryKey.GetValue("Version") as string;
return version != null && version.StartsWith("8.");
}
return true;
}
}
catch (Exception ex)
{
MessageBox.Show($"Error checking .NET installation: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
return false;
}
catch (Exception ex)
{
MessageBox.Show($"Error checking .NET installation: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}

private bool IsAdministrator()
// Return false if no .NET 8 version is found
return false;
}



private bool IsAdministrator()
{
var identity = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(identity);
Expand All @@ -142,9 +156,9 @@ private void ElevateAndRestart(string argument)
{
var startInfo = new ProcessStartInfo
{
FileName = Assembly.GetExecutingAssembly().Location,
FileName = Process.GetCurrentProcess().MainModule.FileName, // This gets the .exe file path
Arguments = argument,
Verb = "runas",
Verb = "runas", // Elevates the process to administrator
UseShellExecute = true
};

Expand All @@ -159,6 +173,7 @@ private void ElevateAndRestart(string argument)
}
}


public void ShowCheckPage()
{
CheckDotNetPage.Visibility = Visibility.Visible;
Expand Down Expand Up @@ -187,11 +202,21 @@ public void ShowConfirmationPage()
{
InstallDotNetPage.Visibility = Visibility.Hidden;
ConfirmDotNetPage.Visibility = Visibility.Visible;

}

private void CloseWindow_Click(object sender, RoutedEventArgs e)
{
Close();
}

private void WhatsNET_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Process.Start(new ProcessStartInfo
{
FileName = "https://dotnet.microsoft.com/en-us/learn/dotnet/what-is-dotnet",
UseShellExecute = true
});
}
}
}

0 comments on commit 0f6007b

Please sign in to comment.