simplify all

This commit is contained in:
Jack Baron 2020-11-16 14:02:28 +00:00
parent 2f0375bb86
commit cfe66c84e1
No known key found for this signature in database
GPG key ID: CD10BCEEC646C064
9 changed files with 31 additions and 31 deletions

View file

@ -31,7 +31,7 @@ namespace ModAssistant
private async void Application_Startup(object sender, StartupEventArgs e) private async void Application_Startup(object sender, StartupEventArgs e)
{ {
// Set SecurityProtocol to prevent crash with TLS // Set SecurityProtocol to prevent crash with TLS
System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
if (ModAssistant.Properties.Settings.Default.UpgradeRequired) if (ModAssistant.Properties.Settings.Default.UpgradeRequired)
{ {
@ -52,14 +52,14 @@ namespace ModAssistant
Languages.LoadLanguages(); Languages.LoadLanguages();
while (string.IsNullOrEmpty(App.BeatSaberInstallDirectory)) while (string.IsNullOrEmpty(BeatSaberInstallDirectory))
{ {
string title = (string)Current.FindResource("App:InstallDirDialog:Title"); string title = (string)Current.FindResource("App:InstallDirDialog:Title");
string body = (string)Current.FindResource("App:InstallDirDialog:OkCancel"); string body = (string)Current.FindResource("App:InstallDirDialog:OkCancel");
if (System.Windows.Forms.MessageBox.Show(body, title, System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) if (System.Windows.Forms.MessageBox.Show(body, title, System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
{ {
App.BeatSaberInstallDirectory = Utils.GetManualDir(); BeatSaberInstallDirectory = Utils.GetManualDir();
} }
else else
{ {
@ -224,7 +224,7 @@ namespace ModAssistant
MessageBox.Show($"{body}: {e.Exception}", title, MessageBoxButton.OK, MessageBoxImage.Warning); MessageBox.Show($"{body}: {e.Exception}", title, MessageBoxButton.OK, MessageBoxImage.Warning);
e.Handled = true; e.Handled = true;
Application.Current.Shutdown(); Current.Shutdown();
} }
} }
} }

View file

@ -218,9 +218,9 @@ namespace ModAssistant.API
public static DateTime UnixTimestampToDateTime(double unixTime) public static DateTime UnixTimestampToDateTime(double unixTime)
{ {
DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
long unixTimeStampInTicks = (long)(unixTime * TimeSpan.TicksPerSecond); long unixTimeStampInTicks = (long)(unixTime * TimeSpan.TicksPerSecond);
return new DateTime(unixStart.Ticks + unixTimeStampInTicks, System.DateTimeKind.Utc); return new DateTime(unixStart.Ticks + unixTimeStampInTicks, DateTimeKind.Utc);
} }
public static async Task Download(string url, string output, int retries = 3) public static async Task Download(string url, string output, int retries = 3)

View file

@ -112,22 +112,22 @@ namespace ModAssistant
{ {
try try
{ {
Themes.ApplyWindowsTheme(); ApplyWindowsTheme();
} }
catch catch
{ {
Themes.ApplyTheme("Light", false); ApplyTheme("Light", false);
} }
return; return;
} }
try try
{ {
Themes.ApplyTheme(savedTheme, false); ApplyTheme(savedTheme, false);
} }
catch (ArgumentException) catch (ArgumentException)
{ {
Themes.ApplyWindowsTheme(); ApplyWindowsTheme();
MainWindow.Instance.MainText = (string)Application.Current.FindResource("Themes:ThemeNotFound"); MainWindow.Instance.MainText = (string)Application.Current.FindResource("Themes:ThemeNotFound");
} }
} }

View file

@ -245,7 +245,7 @@ namespace ModAssistant
int index = Encoding.UTF8.GetString(file).IndexOf("public.app-category.games") + 136; int index = Encoding.UTF8.GetString(file).IndexOf("public.app-category.games") + 136;
Array.Copy(file, index, bytes, 0, 32); Array.Copy(file, index, bytes, 0, 32);
string version = Encoding.UTF8.GetString(bytes).Trim(Utils.Constants.IllegalCharacters); string version = Encoding.UTF8.GetString(bytes).Trim(Constants.IllegalCharacters);
return version; return version;
} }
@ -392,7 +392,7 @@ namespace ModAssistant
{ {
try try
{ {
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo() Process.Start(new System.Diagnostics.ProcessStartInfo()
{ {
FileName = location, FileName = location,
UseShellExecute = true, UseShellExecute = true,
@ -462,7 +462,7 @@ namespace ModAssistant
// want to suppress exceptions for non-clipboard operations // want to suppress exceptions for non-clipboard operations
if (success) if (success)
{ {
Utils.SendNotify($"Copied text to clipboard"); SendNotify($"Copied text to clipboard");
} }
} }
} }

View file

@ -30,7 +30,7 @@ namespace ModAssistant
} }
set set
{ {
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.MainTextBlock.Text = value; })); Dispatcher.Invoke(new Action(() => { Instance.MainTextBlock.Text = value; }));
} }
} }
@ -54,11 +54,11 @@ namespace ModAssistant
if (Utils.IsVoid()) if (Utils.IsVoid())
{ {
Main.Content = Invalid.Instance; Main.Content = Invalid.Instance;
MainWindow.Instance.ModsButton.IsEnabled = false; Instance.ModsButton.IsEnabled = false;
MainWindow.Instance.OptionsButton.IsEnabled = false; Instance.OptionsButton.IsEnabled = false;
MainWindow.Instance.IntroButton.IsEnabled = false; Instance.IntroButton.IsEnabled = false;
MainWindow.Instance.AboutButton.IsEnabled = false; Instance.AboutButton.IsEnabled = false;
MainWindow.Instance.GameVersionsBox.IsEnabled = false; Instance.GameVersionsBox.IsEnabled = false;
return; return;
} }
@ -139,7 +139,7 @@ namespace ModAssistant
if (!string.IsNullOrEmpty(GameVersion) && Properties.Settings.Default.Agreed) if (!string.IsNullOrEmpty(GameVersion) && Properties.Settings.Default.Agreed)
{ {
MainWindow.Instance.ModsButton.IsEnabled = true; Instance.ModsButton.IsEnabled = true;
} }
}); });

View file

@ -19,7 +19,7 @@ namespace ModAssistant
} }
set set
{ {
Dispatcher.Invoke(new Action(() => { OneClickStatus.Instance.HistoryTextBlock.Text = value; })); Dispatcher.Invoke(new Action(() => { Instance.HistoryTextBlock.Text = value; }));
} }
} }
public string MainText public string MainText
@ -31,8 +31,8 @@ namespace ModAssistant
set set
{ {
Dispatcher.Invoke(new Action(() => { Dispatcher.Invoke(new Action(() => {
OneClickStatus.Instance.MainTextBlock.Text = value; Instance.MainTextBlock.Text = value;
OneClickStatus.Instance.HistoryTextBlock.Text = string.IsNullOrEmpty(MainText) ? $"{value}" : $"{value}\n{HistoryText}"; Instance.HistoryTextBlock.Text = string.IsNullOrEmpty(MainText) ? $"{value}" : $"{value}\n{HistoryText}";
})); }));
} }
} }

View file

@ -29,7 +29,7 @@ namespace ModAssistant.Pages
Properties.Settings.Default.Agreed = false; Properties.Settings.Default.Agreed = false;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
MessageBox.Show((string)FindResource("Intro:ClosingApp")); MessageBox.Show((string)FindResource("Intro:ClosingApp"));
System.Windows.Application.Current.Shutdown(); Application.Current.Shutdown();
} }
private void Agree_Click(object sender, RoutedEventArgs e) private void Agree_Click(object sender, RoutedEventArgs e)

View file

@ -51,7 +51,7 @@ namespace ModAssistant.Pages
public void RefreshColumns() public void RefreshColumns()
{ {
if (MainWindow.Instance.Main.Content != Mods.Instance) return; if (MainWindow.Instance.Main.Content != Instance) return;
double viewWidth = ModsListView.ActualWidth; double viewWidth = ModsListView.ActualWidth;
double totalSize = 0; double totalSize = 0;
GridViewColumn description = null; GridViewColumn description = null;
@ -342,7 +342,7 @@ namespace ModAssistant.Pages
); );
} }
Pages.Options.Instance.YeetBSIPA.IsEnabled = true; Options.Instance.YeetBSIPA.IsEnabled = true;
} }
else if (mod.ListItem.IsSelected) else if (mod.ListItem.IsSelected)
{ {
@ -622,7 +622,7 @@ namespace ModAssistant.Pages
private void ModsListView_SelectionChanged(object sender, SelectionChangedEventArgs e) private void ModsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if ((Mods.ModListItem)Mods.Instance.ModsListView.SelectedItem == null) if ((Mods.ModListItem)Instance.ModsListView.SelectedItem == null)
{ {
MainWindow.Instance.InfoButton.IsEnabled = false; MainWindow.Instance.InfoButton.IsEnabled = false;
} }
@ -647,7 +647,7 @@ namespace ModAssistant.Pages
if (File.Exists(Path.Combine(App.BeatSaberInstallDirectory, file))) if (File.Exists(Path.Combine(App.BeatSaberInstallDirectory, file)))
File.Delete(Path.Combine(App.BeatSaberInstallDirectory, file)); File.Delete(Path.Combine(App.BeatSaberInstallDirectory, file));
} }
Pages.Options.Instance.YeetBSIPA.IsEnabled = false; Options.Instance.YeetBSIPA.IsEnabled = false;
} }
private void Uninstall_Click(object sender, RoutedEventArgs e) private void Uninstall_Click(object sender, RoutedEventArgs e)
@ -784,14 +784,14 @@ namespace ModAssistant.Pages
{ {
target.Height = oldHeight; target.Height = oldHeight;
DoubleAnimation animation = new DoubleAnimation(newHeight, duration); DoubleAnimation animation = new DoubleAnimation(newHeight, duration);
target.BeginAnimation(TextBlock.HeightProperty, animation); target.BeginAnimation(HeightProperty, animation);
} }
private void Animate(TextBox target, double oldHeight, double newHeight, TimeSpan duration) private void Animate(TextBox target, double oldHeight, double newHeight, TimeSpan duration)
{ {
target.Height = oldHeight; target.Height = oldHeight;
DoubleAnimation animation = new DoubleAnimation(newHeight, duration); DoubleAnimation animation = new DoubleAnimation(newHeight, duration);
target.BeginAnimation(TextBox.HeightProperty, animation); target.BeginAnimation(HeightProperty, animation);
} }
} }
} }

View file

@ -203,7 +203,7 @@ namespace ModAssistant.Pages
MainWindow.Instance.MainText = $"{Application.Current.FindResource("Options:UploadingLog")}..."; MainWindow.Instance.MainText = $"{Application.Current.FindResource("Options:UploadingLog")}...";
await Task.Run(async () => await UploadLog()); await Task.Run(async () => await UploadLog());
System.Diagnostics.Process.Start(LogURL); Process.Start(LogURL);
Utils.SetClipboard(LogURL); Utils.SetClipboard(LogURL);
MainWindow.Instance.MainText = (string)Application.Current.FindResource("Options:LogUrlCopied"); MainWindow.Instance.MainText = (string)Application.Current.FindResource("Options:LogUrlCopied");
} }