-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsDialog.cs
More file actions
131 lines (119 loc) · 5.04 KB
/
Copy pathSettingsDialog.cs
File metadata and controls
131 lines (119 loc) · 5.04 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
using System;
using System.Drawing;
using System.Windows.Forms;
namespace CoreTempGPU
{
/// <summary>Plugin settings (Core Temp Plugin Manager → Configure), including tray sensors.</summary>
public sealed class SettingsDialog : Form
{
private readonly CheckBox _chkSnap;
private readonly CheckBox _chkTopmost;
private readonly CheckBox _chkPanel;
private readonly CheckBox _chkTrayLoad;
private readonly CheckBox _chkTrayVram;
private readonly CheckBox _chkTrayTemp;
private readonly CheckBox _chkTrayClock;
private readonly NumericUpDown _nudInterval;
private readonly Label _statusLabel;
public bool SnapOnRelease { get { return _chkSnap.Checked; } }
public bool AlwaysOnTop { get { return _chkTopmost.Checked; } }
public bool ShowPanel { get { return _chkPanel.Checked; } }
public int IntervalMs { get { return (int)_nudInterval.Value; } }
public bool TrayShowLoad { get { return _chkTrayLoad.Checked; } }
public bool TrayShowVram { get { return _chkTrayVram.Checked; } }
public bool TrayShowTemp { get { return _chkTrayTemp.Checked; } }
public bool TrayShowClock { get { return _chkTrayClock.Checked; } }
public SettingsDialog(PluginSettings settings, string statusText)
{
Text = "CoreTempGPU — Settings";
FormBorderStyle = FormBorderStyle.FixedDialog;
MaximizeBox = false;
MinimizeBox = false;
StartPosition = FormStartPosition.CenterParent;
ClientSize = new Size(380, 360);
BackColor = Color.FromArgb(45, 45, 48);
ForeColor = Color.White;
Font = UiStyle.Regular(9.5F);
int y = 16;
_chkPanel = MkCheck("Show GPU shade strip", settings.ShowPanel, ref y);
_chkSnap = MkCheck("Snap to edges on release", settings.SnapOnRelease, ref y);
_chkTopmost = MkCheck("Always on top", settings.AlwaysOnTop, ref y);
var lblInterval = new Label
{
Text = "Refresh interval (ms):",
ForeColor = Color.White,
Location = new Point(16, y),
AutoSize = true
};
_nudInterval = new NumericUpDown
{
Minimum = 250,
Maximum = 10000,
Increment = 250,
Value = Math.Max(250, Math.Min(10000, settings.IntervalMs)),
Location = new Point(170, y - 2),
Width = 70
};
y += 32;
var trayHeader = new Label
{
Text = "Notification area (system tray)",
ForeColor = Color.FromArgb(255, 180, 80),
Font = UiStyle.Bold(10F),
Location = new Point(16, y),
AutoSize = true
};
y += 24;
var trayNote = new Label
{
Text = "Core Temp’s own tray only lists CPU sensors.\nThese icons are provided by the GPU plugin:",
ForeColor = Color.FromArgb(170, 170, 170),
Location = new Point(16, y),
Size = new Size(340, 36)
};
y += 40;
_chkTrayLoad = MkCheck("GPU load %", settings.TrayShowLoad, ref y);
_chkTrayVram = MkCheck("GPU VRAM used (GB)", settings.TrayShowVram, ref y);
_chkTrayTemp = MkCheck("GPU temperature °C", settings.TrayShowTemp, ref y);
_chkTrayClock = MkCheck("GPU clock (MHz / GHz)", settings.TrayShowClock, ref y);
_statusLabel = new Label
{
Text = statusText,
ForeColor = Color.FromArgb(160, 160, 160),
Location = new Point(16, y + 4),
Size = new Size(340, 40)
};
var ok = new Button { Text = "OK", DialogResult = DialogResult.OK, Location = new Point(200, 320), Width = 80 };
var cancel = new Button { Text = "Cancel", DialogResult = DialogResult.Cancel, Location = new Point(288, 320), Width = 80 };
Controls.Add(_chkPanel);
Controls.Add(_chkSnap);
Controls.Add(_chkTopmost);
Controls.Add(lblInterval);
Controls.Add(_nudInterval);
Controls.Add(trayHeader);
Controls.Add(trayNote);
Controls.Add(_chkTrayLoad);
Controls.Add(_chkTrayVram);
Controls.Add(_chkTrayTemp);
Controls.Add(_chkTrayClock);
Controls.Add(_statusLabel);
Controls.Add(ok);
Controls.Add(cancel);
AcceptButton = ok;
CancelButton = cancel;
}
private CheckBox MkCheck(string text, bool isChecked, ref int y)
{
var c = new CheckBox
{
Text = text,
Checked = isChecked,
ForeColor = Color.White,
Location = new Point(16, y),
AutoSize = true
};
y += 26;
return c;
}
}
}