From 85df620eaf3ce6fb54f14176b32e36fc667aaac2 Mon Sep 17 00:00:00 2001 From: weedeej Date: Tue, 15 Feb 2022 15:08:29 +0800 Subject: [PATCH] MainWindow themes changed. --- ValorantCC/App.xaml | 389 +------------------- ValorantCC/App.xaml.cs | 8 +- ValorantCC/MainWindow.xaml | 332 +++++++++-------- ValorantCC/MainWindow.xaml.cs | 88 +++-- ValorantCC/SubWindow/ProfilesWindow.xaml | 6 +- ValorantCC/SubWindow/ProfilesWindow.xaml.cs | 59 ++- ValorantCC/SubWindow/src/CreateRender.cs | 5 +- ValorantCC/ValorantCC.csproj | 1 + ValorantCC/src/API.cs | 14 +- ValorantCC/src/Auth.cs | 8 +- ValorantCC/src/BackgroundAuth.cs | 4 +- ValorantCC/src/Modifier.cs | 21 +- ValorantCC/src/Processor.cs | 54 +-- 13 files changed, 339 insertions(+), 650 deletions(-) diff --git a/ValorantCC/App.xaml b/ValorantCC/App.xaml index 18a7851..3bde1c2 100644 --- a/ValorantCC/App.xaml +++ b/ValorantCC/App.xaml @@ -4,386 +4,15 @@ xmlns:local="clr-namespace:ValorantCC" StartupUri="MainWindow.xaml"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/ValorantCC/App.xaml.cs b/ValorantCC/App.xaml.cs index 547525f..d62e6b6 100644 --- a/ValorantCC/App.xaml.cs +++ b/ValorantCC/App.xaml.cs @@ -33,12 +33,12 @@ private void AppEventHandler(object sender, StartupEventArgs e) private void LogFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { - Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); + Utilities.Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); } private void LogDispatcherUnhandled(object sender, DispatcherUnhandledExceptionEventArgs e) { - Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); + Utilities.Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); e.Handled = false; } @@ -47,13 +47,13 @@ private void LogUnhandled(object sender, UnhandledExceptionEventArgs e) var ex = e.ExceptionObject as Exception; if (e.IsTerminating) { - Utils.Log($"{ex.Message}: {ex.StackTrace}"); + Utilities.Utils.Log($"{ex.Message}: {ex.StackTrace}"); } } private void LogUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { - Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); + Utilities.Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); e.SetObserved(); } } diff --git a/ValorantCC/MainWindow.xaml b/ValorantCC/MainWindow.xaml index 384d219..f912fdd 100644 --- a/ValorantCC/MainWindow.xaml +++ b/ValorantCC/MainWindow.xaml @@ -1,14 +1,17 @@ - @@ -17,83 +20,45 @@ - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - + + + + - + + + + + + + + + + @@ -121,11 +86,13 @@ + - - - - + + + + + @@ -153,91 +120,138 @@ + - - - - - - - - - - + + + + + + + + + - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/ValorantCC/MainWindow.xaml.cs b/ValorantCC/MainWindow.xaml.cs index 6eee048..c6adef7 100644 --- a/ValorantCC/MainWindow.xaml.cs +++ b/ValorantCC/MainWindow.xaml.cs @@ -1,4 +1,5 @@ using EZ_Updater; +using MahApps.Metro.Controls; using System; using System.Collections.Generic; using System.Diagnostics; @@ -15,7 +16,7 @@ namespace ValorantCC { - public partial class MainWindow : Window + public partial class MainWindow : MetroWindow { public Processor DataProcessor = new Processor(); BrushConverter bc = new BrushConverter(); @@ -29,47 +30,22 @@ public partial class MainWindow : Window public MainWindow() { // Create logging dir - if (!Directory.Exists(Path.GetDirectoryName(Utils.LoggingFile))) Directory.CreateDirectory(Path.GetDirectoryName(Utils.LoggingFile)); + if (!Directory.Exists(Path.GetDirectoryName(Utilities.Utils.LoggingFile))) Directory.CreateDirectory(Path.GetDirectoryName(Utilities.Utils.LoggingFile)); // Replace old logs - if (File.Exists(Utils.LoggingFile)) File.Move(Utils.LoggingFile, Utils.LoggingFile + ".old", true); + if (File.Exists(Utilities.Utils.LoggingFile)) File.Move(Utilities.Utils.LoggingFile, Utilities.Utils.LoggingFile + ".old", true); Version ProgramFileVersion = new Version(FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion); InitializeComponent(); - Utils.Log($"App Started | v{ProgramFileVersion}. Replaced old logfile."); - Txt_CurrVer.Content = $"ValorantCC3.0b - v{ProgramFileVersion}"; + Utilities.Utils.Log($"App Started | v{ProgramFileVersion}. Replaced old logfile."); + this.Title = $"ValorantCC3.0b - v{ProgramFileVersion}"; BackgroundAuth auth = new BackgroundAuth(DataProcessor); auth.LoopCheck(); } - - private async void Grid_Loaded(object sender, RoutedEventArgs e) - { - Updater.CustomLogger = Utils.Log; - Updater.OriginalFileName = "ValorantCC"; - Updater.LogInterfix = " | "; - if (await Updater.CheckUpdateAsync("weedeej", "ValorantCC")) - { - try - { - File.Create("./valccPermsTest.null").Close(); - File.Delete("./valccPermsTest.null"); - } - catch (UnauthorizedAccessException) - { - Utils.Log("User is not authorized to create a file on current valcc dir. Consider moving."); - MessageWindow.Show("There's an update available but you have no access to write on this folder.\nPlease consider moving the app to a folder created by you or running the app as administrator."); - this.Close(); - } - var update = new UpdateWindow(); - update.Owner = this; - update.ShowDialog(); - } - } - private async void btnSave_Click(object sender, RoutedEventArgs e) { if (!LoggedIn) { - Utils.MessageText("You are not logged in!", Brushes.Red); + Utilities.Utils.MessageText("You are not logged in!", Brushes.Red); return; } if (DataProcessor.ProfileListed) @@ -85,10 +61,10 @@ private async void btnSave_Click(object sender, RoutedEventArgs e) await DataProcessor.Construct(); profiles.Items.Refresh(); profiles.SelectedIndex = DataProcessor.CurrentProfile; - Utils.MessageText("Saved! Restart Valorant.", Brushes.Lime); + Utilities.Utils.MessageText("Saved! Restart Valorant.", Brushes.Lime); return; } - Utils.MessageText("Your session expired! Please restart ValorantCC/Valorant", Brushes.Red); + Utilities.Utils.MessageText("Your session expired! Please restart ValorantCC/Valorant", Brushes.Red); return; } @@ -126,12 +102,12 @@ private async void btnReload_Click(object sender, RoutedEventArgs e) { if (!LoggedIn) { - Utils.MessageText("You are not logged in!", Brushes.Red); + Utilities.Utils.MessageText("You are not logged in!", Brushes.Red); return; } - Utils.Log("Reload Clicked > Reconstructing Processor."); + Utilities.Utils.Log("Reload Clicked > Reconstructing Processor."); if (!(await DataProcessor.Construct())) - Utils.MessageText("Your session expired! Please restart ValorantCC/Valorant", Brushes.Red); + Utilities.Utils.MessageText("Your session expired! Please restart ValorantCC/Valorant", Brushes.Red); profiles.ItemsSource = DataProcessor.ProfileNames; profiles.Items.Refresh(); @@ -276,9 +252,9 @@ private void ClipboardButtonLeave(object sender, MouseEventArgs e) private void btnOpenLogs_Click(object sender, RoutedEventArgs e) { Process p = new Process(); - p.StartInfo = new ProcessStartInfo() { FileName = Path.GetDirectoryName(Utils.LoggingFile), UseShellExecute = true }; + p.StartInfo = new ProcessStartInfo() { FileName = Path.GetDirectoryName(Utilities.Utils.LoggingFile), UseShellExecute = true }; p.Start(); - Utils.MessageText("Log folder opened! Please include OLD files to your report if exists.", Brushes.Lime); + Utilities.Utils.MessageText("Log folder opened! Please include OLD files to your report if exists.", Brushes.Lime); } private void next_Click(object sender, RoutedEventArgs e) @@ -307,7 +283,7 @@ private void btnCommunityProfiles_Click(object sender, RoutedEventArgs e) { if (!LoggedIn) { - Utils.MessageText("You are not logged in !", Brushes.Red); + Utilities.Utils.MessageText("You are not logged in !", Brushes.Red); return; } try @@ -327,7 +303,7 @@ private void chkbxShareable_Click(object sender, RoutedEventArgs e) { if (!LoggedIn) { - Utils.MessageText("You are not logged in !", Brushes.Red); + Utilities.Utils.MessageText("You are not logged in !", Brushes.Red); ((CheckBox)sender).IsChecked = !((CheckBox)sender).IsChecked; return; } @@ -337,11 +313,10 @@ private async void btnShare_Click(object sender, RoutedEventArgs e) { if (!LoggedIn) { - Utils.MessageText("You are not logged in !", Brushes.Red); + Utilities.Utils.MessageText("You are not logged in !", Brushes.Red); return; } - exitButton.Visibility = Visibility.Collapsed; - Utils.MessageText("Your profile is being saved...", Brushes.Yellow); + Utilities.Utils.MessageText("Your profile is being saved...", Brushes.Yellow); ValCCAPI.Shareable = (bool)chkbxShareable.IsChecked; ValCCAPI.profile = SelectedProfile; @@ -350,8 +325,31 @@ private async void btnShare_Click(object sender, RoutedEventArgs e) Clipboard.SetText(sharecode); MessageWindow.Show($"Your sharecode is: \"{sharecode}\" and is copied.\nIf you want this profile accessible across the community,\nPlease be sure that you have the 'shareable' checkbox checked.", "Profile shared!"); - Utils.MessageText("Your profile has been saved. It can now be browsed if \"shareable\" checkbox is checked before saving.", Brushes.Lime); - exitButton.Visibility = Visibility.Visible; + Utilities.Utils.MessageText("Your profile has been saved. It can now be browsed if \"shareable\" checkbox is checked before saving.", Brushes.Lime); + } + + private async void spinner_Loaded(object sender, RoutedEventArgs e) + { + Updater.CustomLogger = Utilities.Utils.Log; + Updater.OriginalFileName = "ValorantCC"; + Updater.LogInterfix = " | "; + if (await Updater.CheckUpdateAsync("weedeej", "ValorantCC")) + { + try + { + File.Create("./valccPermsTest.null").Close(); + File.Delete("./valccPermsTest.null"); + } + catch (UnauthorizedAccessException) + { + Utilities.Utils.Log("User is not authorized to create a file on current valcc dir. Consider moving."); + MessageWindow.Show("There's an update available but you have no access to write on this folder.\nPlease consider moving the app to a folder created by you or running the app as administrator."); + this.Close(); + } + var update = new UpdateWindow(); + update.Owner = this; + update.ShowDialog(); + } } } } diff --git a/ValorantCC/SubWindow/ProfilesWindow.xaml b/ValorantCC/SubWindow/ProfilesWindow.xaml index dc34d16..deed021 100644 --- a/ValorantCC/SubWindow/ProfilesWindow.xaml +++ b/ValorantCC/SubWindow/ProfilesWindow.xaml @@ -4,6 +4,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:ValorantCC" + xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns:gif="http://wpfanimatedgif.codeplex.com" mc:Ignorable="d" Title="ProfilesWindow" RenderOptions.BitmapScalingMode="Fant" Background="Transparent" AllowsTransparency="True" Height="481" Width="339" ResizeMode="NoResize" SizeToContent="WidthAndHeight" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" WindowStyle="None"> @@ -26,9 +27,10 @@ - -