mirror of
https://github.com/stuff-by-3-random-dudes/UWUVCI-AIO-WPF
synced 2024-11-23 11:33:03 +00:00
Simplified and refactored
There was a decent amount of code that was copy/pasted around, extra code that wasn't necessary, and some formatting.
This commit is contained in:
parent
3f2e32756c
commit
0e4be84818
1 changed files with 64 additions and 138 deletions
|
@ -1,18 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace UWUVCI_AIO_WPF.UI.Windows
|
||||
{
|
||||
|
@ -33,23 +22,21 @@ namespace UWUVCI_AIO_WPF.UI.Windows
|
|||
nc.Visibility = Visibility.Hidden;
|
||||
try
|
||||
{
|
||||
if(this.Owner != null)
|
||||
if(Owner != null)
|
||||
{
|
||||
if (this.Owner?.GetType() != typeof(MainWindow))
|
||||
if (Owner?.GetType() != typeof(MainWindow))
|
||||
{
|
||||
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
}
|
||||
|
||||
dont.Visibility = Visibility.Hidden;
|
||||
|
@ -75,10 +62,6 @@ namespace UWUVCI_AIO_WPF.UI.Windows
|
|||
{
|
||||
dont.Visibility = Visibility.Visible;
|
||||
}
|
||||
if (title.ToLower().Contains("instance"))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseProgram(object sender, RoutedEventArgs e)
|
||||
|
@ -87,17 +70,16 @@ namespace UWUVCI_AIO_WPF.UI.Windows
|
|||
}
|
||||
public Custom_Message(string title, string message, string Path)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (this.Owner?.GetType() != typeof(MainWindow))
|
||||
if (Owner?.GetType() != typeof(MainWindow))
|
||||
{
|
||||
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
|
@ -116,34 +98,14 @@ namespace UWUVCI_AIO_WPF.UI.Windows
|
|||
dont.Visibility = Visibility.Hidden;
|
||||
Title.Text = title;
|
||||
Message.Content = message;
|
||||
this.path = Path;
|
||||
path = Path;
|
||||
Folder.Visibility = Visibility.Visible;
|
||||
|
||||
}
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(dont.IsChecked == true)
|
||||
{
|
||||
if (Message.Content.ToString().ToLower().Contains("gcz"))
|
||||
{
|
||||
Properties.Settings.Default.gczw = true;
|
||||
}
|
||||
else if (Message.Content.ToString().ToLower().Contains("dsi"))
|
||||
{
|
||||
Properties.Settings.Default.ndsw = true;
|
||||
}
|
||||
else if (Message.Content.ToString().ToLower().Contains("co-processor"))
|
||||
{
|
||||
Properties.Settings.Default.snesw = true;
|
||||
}
|
||||
else if (Message.Content.ToString().ToLower().Contains("images"))
|
||||
{
|
||||
Properties.Settings.Default.dont = true;
|
||||
}
|
||||
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
this.Close();
|
||||
dontChecked();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Folder_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -152,7 +114,7 @@ namespace UWUVCI_AIO_WPF.UI.Windows
|
|||
{
|
||||
if (File.Exists(path)) path = new FileInfo(path).DirectoryName;
|
||||
Process.Start(path);
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -162,30 +124,11 @@ namespace UWUVCI_AIO_WPF.UI.Windows
|
|||
cm.Owner = (FindResource("mvm") as MainViewModel).mw;
|
||||
}catch(Exception)
|
||||
{
|
||||
|
||||
//left empty on purpose
|
||||
}
|
||||
cm.ShowDialog();
|
||||
if (dont.IsChecked == true)
|
||||
{
|
||||
if (Message.Content.ToString().ToLower().Contains("gcz"))
|
||||
{
|
||||
Properties.Settings.Default.gczw = true;
|
||||
}
|
||||
else if (Message.Content.ToString().ToLower().Contains("dsi"))
|
||||
{
|
||||
Properties.Settings.Default.ndsw = true;
|
||||
}
|
||||
else if (Message.Content.ToString().ToLower().Contains("co-processor"))
|
||||
{
|
||||
Properties.Settings.Default.snesw = true;
|
||||
}
|
||||
else if (Message.Content.ToString().ToLower().Contains("images"))
|
||||
{
|
||||
Properties.Settings.Default.dont = true;
|
||||
}
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
this.Close();
|
||||
dontChecked();
|
||||
Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -194,7 +137,7 @@ namespace UWUVCI_AIO_WPF.UI.Windows
|
|||
{
|
||||
if (reset)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
((MainViewModel)FindResource("mvm")).ResetTitleKeys();
|
||||
}
|
||||
else if (add)
|
||||
|
@ -205,35 +148,16 @@ namespace UWUVCI_AIO_WPF.UI.Windows
|
|||
{
|
||||
((MainViewModel)FindResource("mvm")).choosefolder = true;
|
||||
}
|
||||
if (dont.IsChecked == true)
|
||||
{
|
||||
if (Message.Content.ToString().ToLower().Contains("gcz"))
|
||||
{
|
||||
Properties.Settings.Default.gczw = true;
|
||||
}
|
||||
else if (Message.Content.ToString().ToLower().Contains("dsi"))
|
||||
{
|
||||
Properties.Settings.Default.ndsw = true;
|
||||
}
|
||||
else if (Message.Content.ToString().ToLower().Contains("co-processor"))
|
||||
{
|
||||
Properties.Settings.Default.snesw = true;
|
||||
}
|
||||
else if (Message.Content.ToString().ToLower().Contains("images"))
|
||||
{
|
||||
Properties.Settings.Default.dont = true;
|
||||
}
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
this.Close();
|
||||
dontChecked();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void nc_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
if (Message.Content.ToString().ToLower().Contains("nintendont"))
|
||||
{
|
||||
SDSetup sd = new SDSetup(true, path);
|
||||
Close();
|
||||
var containNintendont = Message.Content.ToString().ToLower().Contains("nintendont");
|
||||
|
||||
SDSetup sd = new SDSetup(containNintendont ? true : false, path);
|
||||
try
|
||||
{
|
||||
sd.Owner = (FindResource("mvm") as MainViewModel).mw;
|
||||
|
@ -241,59 +165,61 @@ namespace UWUVCI_AIO_WPF.UI.Windows
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
//left empty on purpose
|
||||
}
|
||||
sd.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
SDSetup sd = new SDSetup(false, path);
|
||||
try
|
||||
{
|
||||
sd.Owner = (FindResource("mvm") as MainViewModel).mw;
|
||||
sd.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
sd.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void wind_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (!Title.Text.Contains("Warning"))
|
||||
{
|
||||
if ((FindResource("mvm") as MainViewModel).mw != null)
|
||||
(FindResource("mvm") as MainViewModel).mw.Topmost = true;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
isWindClosing(true);
|
||||
}
|
||||
|
||||
private void wind_Closed(object sender, EventArgs e)
|
||||
{
|
||||
isWindClosing(false);
|
||||
}
|
||||
|
||||
private void isWindClosing(bool topMost)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Title.Text.Contains("Warning"))
|
||||
{
|
||||
if ((FindResource("mvm") as MainViewModel).mw != null)
|
||||
(FindResource("mvm") as MainViewModel).mw.Topmost = false;
|
||||
(FindResource("mvm") as MainViewModel).mw.Topmost = topMost;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//left empty on purpose;
|
||||
}
|
||||
}
|
||||
|
||||
private void dontChecked()
|
||||
{
|
||||
if (dont.IsChecked == true)
|
||||
{
|
||||
var messageLower = Message.Content.ToString().ToLower();
|
||||
if (messageLower.Contains("gcz"))
|
||||
{
|
||||
Properties.Settings.Default.gczw = true;
|
||||
}
|
||||
else if (messageLower.Contains("dsi"))
|
||||
{
|
||||
Properties.Settings.Default.ndsw = true;
|
||||
}
|
||||
else if (messageLower.Contains("co-processor"))
|
||||
{
|
||||
Properties.Settings.Default.snesw = true;
|
||||
}
|
||||
else if (messageLower.Contains("images"))
|
||||
{
|
||||
Properties.Settings.Default.dont = true;
|
||||
}
|
||||
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue