2020-04-17 01:28:14 +00:00
using System ;
using System.Diagnostics ;
2020-04-17 17:15:27 +00:00
using System.IO ;
2020-04-17 01:28:14 +00:00
using System.Windows ;
namespace UWUVCI_AIO_WPF.UI.Windows
{
/// <summary>
/// Interaktionslogik für Custom_Message.xaml
/// </summary>
2020-05-04 16:20:21 +00:00
///
2020-04-17 01:28:14 +00:00
public partial class Custom_Message : Window
{
string path ;
2020-04-17 16:02:45 +00:00
bool reset = false ;
2020-04-28 23:40:54 +00:00
bool add = false ;
2020-04-17 01:28:14 +00:00
public Custom_Message ( string title , string message )
{
2020-05-01 18:10:51 +00:00
InitializeComponent ( ) ;
2020-05-04 16:20:21 +00:00
nc . Visibility = Visibility . Hidden ;
2020-04-30 15:01:41 +00:00
try
{
2020-10-01 00:21:38 +00:00
if ( Owner ! = null )
2020-04-30 15:01:41 +00:00
{
2020-10-01 00:21:38 +00:00
if ( Owner ? . GetType ( ) ! = typeof ( MainWindow ) )
2020-05-01 18:10:51 +00:00
{
2020-10-01 00:21:38 +00:00
WindowStartupLocation = WindowStartupLocation . CenterScreen ;
2020-05-01 18:10:51 +00:00
}
2020-05-04 16:20:21 +00:00
else
{
2020-10-01 00:21:38 +00:00
WindowStartupLocation = WindowStartupLocation . CenterOwner ;
2020-05-04 16:20:21 +00:00
}
}
2020-04-30 15:01:41 +00:00
}
catch ( Exception )
{
2020-10-01 00:21:38 +00:00
WindowStartupLocation = WindowStartupLocation . CenterScreen ;
2020-04-30 15:01:41 +00:00
}
2020-04-17 01:28:14 +00:00
2020-10-01 00:21:38 +00:00
dont . Visibility = Visibility . Hidden ;
2020-04-17 01:28:14 +00:00
Title . Text = title ;
Message . Content = message ;
Folder . Visibility = Visibility . Hidden ;
2020-06-05 11:02:11 +00:00
2020-04-28 23:40:54 +00:00
if ( title . Contains ( "Resetting" ) | | message . Contains ( "NUS format" ) | | message . Contains ( "Folder contains Files or Subfolders, do you really want to use this" ) | | message . Contains ( "If using Custom Bases" ) | | title . Contains ( "Found additional Files" ) )
2020-04-17 16:02:45 +00:00
{
Reset . Visibility = Visibility . Visible ;
if ( title . Contains ( "Resetting" ) )
{
reset = true ;
}
2020-04-28 23:40:54 +00:00
if ( title . Contains ( "Found additional Files" ) )
{
add = true ;
Reset . Content = "Yes" ;
2020-05-22 13:45:46 +00:00
btnClose . Content = "No" ;
2020-04-28 23:40:54 +00:00
}
2020-04-17 16:02:45 +00:00
}
2020-05-07 07:49:36 +00:00
if ( title . Equals ( "Image Warning" ) | | message . ToLower ( ) . Contains ( "dsi" ) | | message . ToLower ( ) . Contains ( "gcz" ) | | message . ToLower ( ) . Contains ( "co-processor" ) )
2020-04-20 09:31:26 +00:00
{
dont . Visibility = Visibility . Visible ;
}
2020-05-22 14:12:05 +00:00
}
public void CloseProgram ( object sender , RoutedEventArgs e )
{
Environment . Exit ( 1 ) ;
2020-04-17 01:28:14 +00:00
}
public Custom_Message ( string title , string message , string Path )
2020-10-01 00:21:38 +00:00
{
2020-04-30 15:01:41 +00:00
try
{
2020-10-01 00:21:38 +00:00
if ( Owner ? . GetType ( ) ! = typeof ( MainWindow ) )
2020-04-30 15:01:41 +00:00
{
2020-10-01 00:21:38 +00:00
WindowStartupLocation = WindowStartupLocation . CenterScreen ;
2020-04-30 15:01:41 +00:00
}
}
catch ( Exception )
{
2020-10-01 00:21:38 +00:00
WindowStartupLocation = WindowStartupLocation . CenterScreen ;
2020-04-30 15:01:41 +00:00
}
2020-05-04 16:20:21 +00:00
2020-04-17 01:28:14 +00:00
InitializeComponent ( ) ;
2020-05-04 16:20:21 +00:00
if ( ! message . Contains ( "Nintendont" ) )
{
nc . Visibility = Visibility . Hidden ;
}
2020-06-11 08:12:03 +00:00
if ( message . Contains ( "If you want the inject to be put on your SD now" ) )
2020-06-05 11:02:11 +00:00
{
2020-06-13 20:16:15 +00:00
if ( message . Contains ( "Copy to SD" ) )
{
nc . Content = "Copy to SD" ;
}
2020-06-05 11:02:11 +00:00
nc . Visibility = Visibility . Visible ;
}
2020-04-21 02:05:19 +00:00
dont . Visibility = Visibility . Hidden ;
2020-04-17 01:28:14 +00:00
Title . Text = title ;
Message . Content = message ;
2020-10-01 00:21:38 +00:00
path = Path ;
2020-04-17 01:28:14 +00:00
Folder . Visibility = Visibility . Visible ;
2020-05-04 16:20:21 +00:00
2020-04-17 01:28:14 +00:00
}
private void Button_Click ( object sender , RoutedEventArgs e )
{
2020-10-01 00:21:38 +00:00
dontChecked ( ) ;
Close ( ) ;
2020-04-17 01:28:14 +00:00
}
private void Folder_Click ( object sender , RoutedEventArgs e )
{
2020-04-20 00:35:31 +00:00
try
{
if ( File . Exists ( path ) ) path = new FileInfo ( path ) . DirectoryName ;
Process . Start ( path ) ;
2020-10-01 00:21:38 +00:00
Close ( ) ;
2020-04-20 00:35:31 +00:00
}
catch ( Exception )
{
Custom_Message cm = new Custom_Message ( "An Error occured" , "An error occured opening the folder. Please make sure the Output Path exists." ) ;
try
{
cm . Owner = ( FindResource ( "mvm" ) as MainViewModel ) . mw ;
} catch ( Exception )
{
2020-10-01 00:21:38 +00:00
//left empty on purpose
2020-04-20 00:35:31 +00:00
}
cm . ShowDialog ( ) ;
2020-10-01 00:21:38 +00:00
dontChecked ( ) ;
Close ( ) ;
2020-04-20 00:35:31 +00:00
}
2020-04-17 16:02:45 +00:00
}
private void Reset_Click ( object sender , RoutedEventArgs e )
{
if ( reset )
{
2020-10-01 00:21:38 +00:00
Close ( ) ;
2020-04-17 16:02:45 +00:00
( ( MainViewModel ) FindResource ( "mvm" ) ) . ResetTitleKeys ( ) ;
}
2020-04-28 23:40:54 +00:00
else if ( add )
{
( ( MainViewModel ) FindResource ( "mvm" ) ) . addi = true ;
}
2020-04-17 16:02:45 +00:00
else
{
( ( MainViewModel ) FindResource ( "mvm" ) ) . choosefolder = true ;
}
2020-10-01 00:21:38 +00:00
dontChecked ( ) ;
Close ( ) ;
2020-04-17 01:28:14 +00:00
}
2020-05-04 16:20:21 +00:00
private void nc_Click ( object sender , RoutedEventArgs e )
{
2020-10-01 00:21:38 +00:00
Close ( ) ;
var containNintendont = Message . Content . ToString ( ) . ToLower ( ) . Contains ( "nintendont" ) ;
2020-06-09 20:26:03 +00:00
2020-10-01 00:21:38 +00:00
SDSetup sd = new SDSetup ( containNintendont ? true : false , path ) ;
try
{
sd . Owner = ( FindResource ( "mvm" ) as MainViewModel ) . mw ;
sd . WindowStartupLocation = WindowStartupLocation . CenterOwner ;
2020-05-06 21:53:52 +00:00
}
2020-10-01 00:21:38 +00:00
catch ( Exception )
2020-05-06 21:53:52 +00:00
{
2020-10-01 00:21:38 +00:00
//left empty on purpose
2020-05-06 21:53:52 +00:00
}
2020-10-01 00:21:38 +00:00
sd . ShowDialog ( ) ;
2020-05-06 21:53:52 +00:00
}
private void wind_Closing ( object sender , System . ComponentModel . CancelEventArgs e )
{
2020-10-01 00:21:38 +00:00
isWindClosing ( true ) ;
}
private void wind_Closed ( object sender , EventArgs e )
{
isWindClosing ( false ) ;
}
2020-05-22 14:12:05 +00:00
2020-10-01 00:21:38 +00:00
private void isWindClosing ( bool topMost )
{
2020-05-22 14:12:05 +00:00
try
{
2020-06-24 15:54:51 +00:00
if ( ! Title . Text . Contains ( "Warning" ) )
{
if ( ( FindResource ( "mvm" ) as MainViewModel ) . mw ! = null )
2020-10-01 00:21:38 +00:00
( FindResource ( "mvm" ) as MainViewModel ) . mw . Topmost = topMost ;
2020-06-24 15:54:51 +00:00
}
2020-05-22 14:12:05 +00:00
}
2020-10-01 00:21:38 +00:00
catch ( Exception )
{
//left empty on purpose;
2020-05-22 14:12:05 +00:00
}
2020-05-06 21:53:52 +00:00
}
2020-05-04 16:20:21 +00:00
2020-10-01 00:21:38 +00:00
private void dontChecked ( )
2020-05-06 21:53:52 +00:00
{
2020-10-01 00:21:38 +00:00
if ( dont . IsChecked = = true )
2020-05-22 14:12:05 +00:00
{
2020-10-01 00:21:38 +00:00
var messageLower = Message . Content . ToString ( ) . ToLower ( ) ;
if ( messageLower . Contains ( "gcz" ) )
2020-06-24 15:54:51 +00:00
{
2020-10-01 00:21:38 +00:00
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 ;
2020-06-24 15:54:51 +00:00
}
2020-05-22 14:12:05 +00:00
2020-10-01 00:21:38 +00:00
Properties . Settings . Default . Save ( ) ;
}
2020-05-04 16:20:21 +00:00
}
2020-04-17 01:28:14 +00:00
}
}