-
Notifications
You must be signed in to change notification settings - Fork 0
/
WindowMain.cs
137 lines (109 loc) · 3.93 KB
/
WindowMain.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
125
126
127
128
129
130
131
132
133
134
135
136
137
using Microsoft.Win32;
using OpenXR_Switcher.Properties;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.Xml.Linq;
namespace OpenXR_Switcher
{
public partial class WindowMain : Form
{
public WindowMain()
{
InitializeComponent();
}
private void WindowMain_Load(object sender, EventArgs e)
{
// display version in the title
Version version = Assembly.GetExecutingAssembly().GetName().Version;
Text = Text + " (v" + version.Major + "." + version.Minor + "." + version.Build + ")";
// set previous window size
if (Settings.Default.WindowSize != null && Settings.Default.WindowSize.Width >= 400 && Settings.Default.WindowSize.Height >= 400)
{
this.Size = Settings.Default.WindowSize;
}
Functions.GetRuntimes();
Functions.GetActiveRuntime();
Functions.CheckArguments();
Functions.AddRuntimes();
Functions.GetAddLayers();
}
private void WindowMain_Closing(object sender, FormClosingEventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
Settings.Default.WindowSize = this.Size;
}
else
{
Settings.Default.WindowSize = this.RestoreBounds.Size;
}
Settings.Default.Save();
}
private void RepositionRefreshButton()
{
int ScrollbarWidth = 17;
int MarginsBordersPadding = 19;
int PosX = this.Width - buttonRefresh.Width - MarginsBordersPadding;
if (flowLayers.VerticalScroll.Visible)
{
PosX -= ScrollbarWidth;
buttonRefresh.Location = new Point(PosX, 6);
}
else
{
buttonRefresh.Location = new Point(PosX, 6);
}
}
private void buttonRefresh_Click(object sender, EventArgs e)
{
flowRuntimes.Controls.Clear();
flowLayers.Controls.Clear();
WindowMain_Load(sender, e);
RepositionRefreshButton();
}
private void WindowMain_Resize(object sender, EventArgs e)
{
RepositionRefreshButton();
}
private void WindowMain_Shown(object sender, EventArgs e)
{
RepositionRefreshButton();
}
private void ResetOverlay()
{
Functions.saved_name = "";
maskedTextBox.Text = "";
tableLayoutPanel.Enabled = true; // Enabled | Visible
buttonRefresh.Visible = true;
panelEdit.Visible = false;
}
private void evtbuttonCancel_Click(object sender, EventArgs e)
{
ResetOverlay();
}
private void evtbuttonSave_Click(object sender, EventArgs e)
{
if (!Functions.WriteToReg("HKCU", Functions.reg_usersetnames, Functions.saved_name, maskedTextBox.Text, RegistryValueKind.String))
MessageBox.Show("Couldn't write to registry!", "ERROR", MessageBoxButtons.OK);
ResetOverlay();
buttonRefresh.PerformClick();
}
private void evtbuttonReset_Click(object sender, EventArgs e)
{
if (!Functions.WriteToReg("HKCU", Functions.reg_usersetnames, "#DELETE#", Functions.saved_name, RegistryValueKind.String))
MessageBox.Show("Couldn't delete value from registry!", "ERROR", MessageBoxButtons.OK);
ResetOverlay();
buttonRefresh.PerformClick();
}
private void maskedTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
buttonSave.PerformClick();
}
}
}
}