This repository was archived by the owner on Apr 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOptions Screen.cs
More file actions
154 lines (138 loc) · 4.53 KB
/
Copy pathOptions Screen.cs
File metadata and controls
154 lines (138 loc) · 4.53 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System;
using System.Drawing;
using System.Windows.Forms;
namespace System_Info
{
public partial class Options_Screen : Form
{
public Options_Screen()
{
InitializeComponent();
progbarCPU.Value = 100;
progbarHDD.Value = 100;
progbarRAM.Value = 100;
progbarCPU.BackColor = Color.Black;
progbarHDD.BackColor = Color.Black;
progbarRAM.BackColor = Color.Black;
LoadSettings();
}
private void ScrollbarHSize_ValueChanged(object sender, EventArgs e)
{
ScrollBar bar = (ScrollBar)sender;
string type = bar.Name.Substring(bar.Name.Length - 3, 3);
if (bar.Value > bar.Minimum || ((ScrollBar)sender).Value < bar.Maximum)
{
Controls.Find("txtboxHSize" + type, true)[0].Text = bar.Value.ToString();
Controls.Find("progbar" + type, true)[0].Width = bar.Value;
Controls.Find("progbar" + type, true)[0].Invalidate();
}
}
private void TxtboxHSize_TextChanged(object sender, EventArgs e)
{
TextBox txtbox = (TextBox)sender;
string type = txtbox.Name.Substring(txtbox.Name.Length - 3, 3);
ScrollBar bar = (ScrollBar)Controls.Find("scrollbarHSize" + type, true)[0];
if (!string.IsNullOrEmpty(txtbox.Text))
{
if (int.Parse(txtbox.Text) < bar.Minimum)
{
bar.Value = bar.Minimum;
}
else if (int.Parse(txtbox.Text) > bar.Maximum)
{
bar.Value = bar.Maximum;
}
else
{
bar.Value = int.Parse(txtbox.Text);
}
}
}
private void ScrollbarVSize_ValueChanged(object sender, EventArgs e)
{
ScrollBar bar = (ScrollBar)sender;
string type = bar.Name.Substring(bar.Name.Length - 3, 3);
if (bar.Value > bar.Minimum || ((ScrollBar)sender).Value < bar.Maximum)
{
Controls.Find("txtboxVSize" + type, true)[0].Text = bar.Value.ToString();
Controls.Find("progbar" + type, true)[0].Height = bar.Value;
Controls.Find("progbar" + type, true)[0].Invalidate();
}
}
private void TxtboxVSize_TextChanged(object sender, EventArgs e)
{
TextBox txtbox = (TextBox)sender;
string type = txtbox.Name.Substring(txtbox.Name.Length - 3, 3);
ScrollBar bar = (ScrollBar)Controls.Find("scrollbarVSize" + type, true)[0];
if (!string.IsNullOrEmpty(txtbox.Text))
{
if (int.Parse(txtbox.Text) < bar.Minimum)
{
bar.Value = bar.Minimum;
}
else if (int.Parse(txtbox.Text) > bar.Maximum)
{
bar.Value = bar.Maximum;
}
else
{
bar.Value = int.Parse(txtbox.Text);
}
}
}
private void ResetToDefault()
{
Properties.Settings.Default.Reset();
Properties.Settings.Default.Save();
LoadSettings();
}
private void LoadSettings()
{
scrollbarVSizeCPU.Value = Properties.Settings.Default.CpuBarHeight;
scrollbarVSizeRAM.Value = Properties.Settings.Default.RamBarHeight;
scrollbarVSizeHDD.Value = Properties.Settings.Default.HddBarHeight;
scrollbarHSizeCPU.Value = Properties.Settings.Default.CpuBarWidth;
scrollbarHSizeRAM.Value = Properties.Settings.Default.RamBarWidth;
scrollbarHSizeHDD.Value = Properties.Settings.Default.HddBarWidth;
txtboxFont.Text = FontToString(Properties.Settings.Default.Font);
}
private string FontToString(Font f)
{
FontConverter converter = new FontConverter();
return converter.ConvertToString(f);
}
private Font StringToFont(string s)
{
FontConverter converter = new FontConverter();
return (Font)converter.ConvertFromString(s);
}
private void BtnResetDefaults_Click(object sender, EventArgs e)
{
ResetToDefault();
}
private void BtnApply_Click(object sender, EventArgs e)
{
Properties.Settings.Default.CpuBarHeight = (short)scrollbarVSizeCPU.Value;
Properties.Settings.Default.RamBarHeight = (short)scrollbarVSizeRAM.Value;
Properties.Settings.Default.HddBarHeight = (short)scrollbarVSizeHDD.Value;
Properties.Settings.Default.CpuBarWidth = (short)scrollbarHSizeCPU.Value;
Properties.Settings.Default.RamBarWidth = (short)scrollbarHSizeRAM.Value;
Properties.Settings.Default.HddBarWidth = (short)scrollbarHSizeHDD.Value;
Properties.Settings.Default.Font = StringToFont(txtboxFont.Text);
Properties.Settings.Default.Save();
Close();
}
private void BtnCancel_Click(object sender, EventArgs e)
{
Close();
}
private void BtnFontSelection_Click(object sender, EventArgs e)
{
fontDialog1.Font = StringToFont(txtboxFont.Text);
if (fontDialog1.ShowDialog() == DialogResult.OK)
{
txtboxFont.Text = FontToString(fontDialog1.Font);
}
}
}
}