-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
124 lines (111 loc) · 3.68 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Navigation;
using WindConfig.Model;
using WindConfig.View;
namespace WindConfig;
public partial class MainWindow : Window
{
private readonly string ProcessName = string.Empty;
public MainWindow(string title, string processName)
{
InitializeComponent();
Title = title;
ProcessName = processName;
}
private void Resolution_RadioButton1_Checked(object sender, RoutedEventArgs e)
{
if (ProcessName?.Length != 0)
{
WindRegistry.CreationWidth = 800;
WindRegistry.CreationHeight = 600;
}
}
private void Resolution_RadioButton2_Checked(object sender, RoutedEventArgs e)
{
if (ProcessName?.Length != 0)
{
WindRegistry.CreationWidth = 1024;
WindRegistry.CreationHeight = 768;
}
}
private void Window_WindowMode_Checked(object sender, RoutedEventArgs e)
{
if (ProcessName?.Length != 0)
{
WindRegistry.IsFullscreen = 0;
}
}
private void Window_FullScreenMode_Checked(object sender, RoutedEventArgs e)
{
if (ProcessName?.Length != 0)
{
WindRegistry.IsFullscreen = 1;
}
}
private void Start_Click(object sender, RoutedEventArgs e)
{
MessageBoxResult CustomResolutionResult = MessageBoxResult.Cancel;
if (CustomResolution.IsEnabled)
{
CustomResolutionResult = Wind.ShowCustomResolutionWarningMessage();
}
//1. File must exists.
//2. File exists with IsCustomResolution == true. CustomResolutionResult == MessageBoxResult.OK must be IsCustomResolution == true.
//3. File exists with !IsCustomResolution.
if (File.Exists(ProcessName) && (CustomResolutionResult == MessageBoxResult.OK || !CustomResolution.IsEnabled))
{
WindRegistry.Path = $"{Path.GetDirectoryName(Path.GetFullPath(ProcessName))}\\";
using Process WindProcess = new();
{
WindProcess.StartInfo.UseShellExecute = false;
WindProcess.StartInfo.FileName = ProcessName;
WindProcess.StartInfo.CreateNoWindow = false;
WindProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
WindProcess.Start();
if (WindRegistry.IsFullscreen == 0)
{
Wind.SetWindowPosToCenter(WindProcess);
}
}
Application.Current.Shutdown();
}
// if CustomResolutionResult is MessageBoxResult.Cancel, nothing needs to do.
else if (!File.Exists(ProcessName))
{
Wind.ShowProcessNotFoundWarningMessage(ProcessName);
}
}
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();
}
}