UWUVCI-AIO-WPF/UWUVCI AIO WPF/UI/Windows/EnterKey.xaml.cs

173 lines
5.3 KiB
C#
Raw Normal View History

using GameBaseClassLibrary;
using System;
using System.Collections.Generic;
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
{
/// <summary>
/// Interaktionslogik für EnterKey.xaml
/// </summary>
public partial class EnterKey : Window
{
bool ckey = false;
2020-04-19 17:36:03 +00:00
Custom_Message cm;
public EnterKey(bool ckey)
{
2020-04-30 15:01:41 +00:00
try
{
if (this.Owner?.GetType() != typeof(MainWindow))
2020-04-30 15:01:41 +00:00
{
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
}
catch (Exception)
{
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
InitializeComponent();
this.ckey = ckey;
2020-04-17 17:15:27 +00:00
if (ckey)
{
Key.Text = "CommonKey";
region.Text = "WIIU";
2020-06-05 17:43:22 +00:00
otp.Visibility = Visibility.Visible;
}
2020-04-17 17:15:27 +00:00
else
{
if ((FindResource("mvm") as MainViewModel).GbTemp.Tid != "")
{
2020-04-29 14:01:24 +00:00
2020-04-17 17:15:27 +00:00
}
}
}
2020-04-16 04:41:25 +00:00
public EnterKey(int i)
{
if (this.Owner?.GetType() != typeof(MainWindow))
2020-04-30 15:01:41 +00:00
{
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
2020-04-16 04:41:25 +00:00
InitializeComponent();
region.Visibility = Visibility.Hidden;
Key.Text = "Enter the TitleKey for 000500101000400";
if (i == 1)
{
Key.Text += "0";
}
else
{
Key.Text += "1";
}
or.Visibility = Visibility.Hidden;
otp.Visibility = Visibility.Hidden;
2020-04-16 04:41:25 +00:00
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
if(tbKey.Text.Length > 32 || tbKey.Text.Length < 32)
{
if(tbKey.Text.Length > 32)
{
2020-04-19 17:36:03 +00:00
cm = new Custom_Message("Wrong Key", "The entered Key is too long");
cm.Owner = this;
cm.ShowDialog();
2020-04-06 20:05:10 +00:00
}
else
{
2020-04-19 17:36:03 +00:00
cm = new Custom_Message("Wrong Key", "The entered Key is too short");
cm.Owner = this;
cm.ShowDialog();
}
}
else
2020-03-23 23:18:36 +00:00
{
if (ckey)
{
MainViewModel mvm = (MainViewModel)FindResource("mvm");
if (mvm.checkcKey(tbKey.Text))
{
2020-05-04 16:20:21 +00:00
this.Visibility = Visibility.Hidden;
2020-04-19 17:36:03 +00:00
cm = new Custom_Message("Correct Key", "The entered CommonKey is correct!");
2020-05-22 13:26:36 +00:00
cm.Owner = this.Owner;
(this.Owner as MainWindow).move = false;
2020-04-19 17:36:03 +00:00
cm.ShowDialog();
2020-05-22 13:26:36 +00:00
(this.Owner as MainWindow).move = true;
this.Close();
mvm.ArePathsSet();
}
else
{
2020-04-19 17:36:03 +00:00
cm = new Custom_Message("Incorrect Key", "The entered CommonKey is incorrect!");
cm.Owner = this;
cm.ShowDialog();
}
}
2020-04-06 20:05:10 +00:00
else
{
MainViewModel mvm = (MainViewModel)FindResource("mvm");
if (mvm.checkKey(tbKey.Text))
{
2020-05-04 16:20:21 +00:00
this.Visibility = Visibility.Hidden;
cm = new Custom_Message("Correct Key", "The entered TitleKey is correct!");
2020-05-22 13:26:36 +00:00
cm.Owner = this.Owner;
(this.Owner as MainWindow).move = false;
2020-04-19 17:36:03 +00:00
cm.ShowDialog();
2020-05-22 13:26:36 +00:00
(this.Owner as MainWindow).move = true;
this.Close();
}
else
{
2020-04-19 17:36:03 +00:00
cm = new Custom_Message("Incorrect Key", "The entered TitleKey is incorrect!");
cm.Owner = this;
cm.ShowDialog();
}
2020-04-06 20:05:10 +00:00
}
2020-03-23 23:18:36 +00:00
}
}
2020-04-19 17:36:03 +00:00
private void Window_GotFocus(object sender, RoutedEventArgs e)
{
tbKey.Focus();
tbKey.Select(0,0);
}
2020-05-06 21:53:52 +00:00
private void wind_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
(FindResource("mvm") as MainViewModel).mw.Topmost = true;
}
private void wind_Closed(object sender, EventArgs e)
{
(FindResource("mvm") as MainViewModel).mw.Topmost = false;
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
tbKey.Text = (FindResource("mvm") as MainViewModel).ReadCkeyFromOtp();
}
}
}