diff --git a/MainWindow.xaml b/MainWindow.xaml index c932dc4..e5964c3 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -113,15 +113,32 @@ - + + + + + + + + + + - - + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index da4f48d..e7d4ae6 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -4,6 +4,7 @@ using System.Windows.Navigation; using WindConfig.Model; +using WindConfig.View; namespace WindConfig; @@ -20,24 +21,36 @@ public MainWindow(string title, string processName) private void Resolution_RadioButton1_Checked(object sender, RoutedEventArgs e) { - WindRegistry.CreationWidth = 800; - WindRegistry.CreationHeight = 600; + if (ProcessName?.Length != 0) + { + WindRegistry.CreationWidth = 800; + WindRegistry.CreationHeight = 600; + } } private void Resolution_RadioButton2_Checked(object sender, RoutedEventArgs e) { - WindRegistry.CreationWidth = 1024; - WindRegistry.CreationHeight = 768; + if (ProcessName?.Length != 0) + { + WindRegistry.CreationWidth = 1024; + WindRegistry.CreationHeight = 768; + } } private void Window_WindowMode_Checked(object sender, RoutedEventArgs e) { - WindRegistry.IsFullscreen = 0; + if (ProcessName?.Length != 0) + { + WindRegistry.IsFullscreen = 0; + } } private void Window_FullScreenMode_Checked(object sender, RoutedEventArgs e) { - WindRegistry.IsFullscreen = 1; + if (ProcessName?.Length != 0) + { + WindRegistry.IsFullscreen = 1; + } } private void Start_Click(object sender, RoutedEventArgs e) @@ -45,10 +58,7 @@ private void Start_Click(object sender, RoutedEventArgs e) MessageBoxResult CustomResolutionResult = MessageBoxResult.Cancel; if (CustomResolution.IsEnabled) { - const string caption = "警告 (Warning)"; - const string message = "自定义分辨率可能产生预期之外的错误. 甚至损坏你的硬件.\nCustom resolutions can produce unexpected errors. Even damage your hardware."; - const MessageBoxResult defaultResult = MessageBoxResult.Cancel; - CustomResolutionResult = MessageBox.Show(message, caption, MessageBoxButton.OKCancel, MessageBoxImage.Warning, defaultResult); + CustomResolutionResult = Wind.ShowCustomResolutionWarningMessage(); } //1. File must exists. //2. File exists with IsCustomResolution == true. CustomResolutionResult == MessageBoxResult.OK must be IsCustomResolution == true. @@ -73,7 +83,7 @@ private void Start_Click(object sender, RoutedEventArgs e) // if CustomResolutionResult is MessageBoxResult.Cancel, nothing needs to do. else if (!File.Exists(ProcessName)) { - MessageBox.Show($"未找到 {ProcessName} \n Can not find {ProcessName}", "警告 (Warning)"); + Wind.ShowProcessNotFoundWarningMessage(ProcessName); } } @@ -82,4 +92,33 @@ private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; } + + private void Registry_Click(object sender, RoutedEventArgs e) + { + if (ProcessName?.Length == 0) + { + Wind.ShowProcessNotFoundWarningMessage(ProcessName); + } + else + { + WindRegistry.LastKey = WindRegistry.WindKey; + using Process Regedit = new(); + { + Regedit.StartInfo.FileName = "regedit"; + Regedit.StartInfo.UseShellExecute = true; + Regedit.StartInfo.Verb = "runas"; + Regedit.Start(); + } + } + } + + private void FAQ_Click(object sender, RoutedEventArgs e) + { + Window FAQ = new FAQ() + { + Owner = this + }; + + FAQ.ShowDialog(); + } } diff --git a/Model/Wind.cs b/Model/Wind.cs index 867d2c0..f547459 100644 --- a/Model/Wind.cs +++ b/Model/Wind.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics; using System.Drawing; +using System.Windows; using System.Windows.Forms; using Windows.Win32; @@ -8,6 +9,9 @@ using static Windows.Win32.UI.WindowsAndMessaging.SET_WINDOW_POS_FLAGS; +using MessageBox = System.Windows.MessageBox; +using Point = System.Drawing.Point; + namespace WindConfig.Model; public static class Wind @@ -18,6 +22,9 @@ public static class Wind public const string Wind4RegistryKeyName = "Wind4"; public const string Wind3ConfigTitleName = "风色幻想3 配置向导"; public const string Wind4ConfigTitleName = "风色幻想4 配置向导"; + public const string DefaultConfigTitleName = "WindConfig"; + public const int Wind3Version = 211; + public const int Wind4Version = 110; public static void SetWindowPosToCenter(Process process) { @@ -33,4 +40,24 @@ public static void SetWindowPosToCenter(Process process) Point point = new(screen.Left + (screen.Width / 2) - ((rect.right - rect.left) / 2), screen.Top + (screen.Height / 2) - ((rect.bottom - rect.top) / 2)); PInvoke.SetWindowPos(hWnd, (HWND)IntPtr.Zero, point.X, point.Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); } + + public static MessageBoxResult ShowProcessNotFoundWarningMessage(string? ProcessName) + { + if (ProcessName?.Length == 0) + { + return MessageBox.Show("未找到游戏 \nCan not find game", "警告 (Warning)", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + return MessageBox.Show($"未找到 {ProcessName} \nCan not find {ProcessName}", "警告 (Warning)", MessageBoxButton.OK, MessageBoxImage.Warning); + } + } + + public static MessageBoxResult ShowCustomResolutionWarningMessage() + { + const string caption = "警告 (Warning)"; + const string message = "自定义分辨率可能产生预期之外的错误. 甚至损坏你的硬件.\nCustom resolutions can produce unexpected errors. Even damage your hardware."; + const MessageBoxResult defaultResult = MessageBoxResult.Cancel; + return MessageBox.Show(message, caption, MessageBoxButton.OKCancel, MessageBoxImage.Warning, defaultResult); + } }