-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrmSettings.cs
More file actions
142 lines (129 loc) · 4.57 KB
/
FrmSettings.cs
File metadata and controls
142 lines (129 loc) · 4.57 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Hantek_UI
{
public partial class FrmSettings : Form
{
public FrmSettings()
{
InitializeComponent();
}
public Color? WindowColor { get; set; }
public Color? TextColor { get; set; }
public Color? UnitColor { get; set; }
public Color? ModeColor { get; set; }
public int? Precision { get; set; }
public bool? WindowBorder { get; set; }
public decimal? Interval { get; set; }
private bool initializing;
private void FrmSettings_Load(object sender, EventArgs e)
{
initializing = true;
BtnTextColor.BackColor = Settings.Default.TextColor;
BtnWindowColor.BackColor = Settings.Default.WindowColor;
BtnUnitColor.BackColor = Settings.Default.UnitColor;
BtnModeColor.BackColor = Settings.Default.ModeColor;
ChkTransparent.Checked = Settings.Default.WindowColor == Color.Transparent;
ChkWindowBorder.Checked = Settings.Default.HasBorder;
CboPrecision.Text = Settings.Default.Precision.ToString();
NumInterval.Value = Settings.Default.Interval;
initializing = false;
}
private Color? SelectColor(Button colorBtn)
{
Color color = colorBtn.BackColor;
using ColorDialog dlgColor = new();
dlgColor.AnyColor = true;
if (color == Color.Transparent)
dlgColor.Color = Color.FromArgb(96, 64, 32);
else
dlgColor.Color = color;
DialogResult rslt = dlgColor.ShowDialog(this);
if ((rslt == DialogResult.OK) && (color != dlgColor.Color))
return dlgColor.Color;
else
return null;
}
private void BtnTextColor_Click(object sender, EventArgs e)
{
TextColor = SelectColor(BtnTextColor);
if (TextColor != null)
BtnTextColor.BackColor = TextColor.Value;
}
private void BtnWindowColor_Click(object sender, EventArgs e)
{
Color? tmpColor = SelectColor(BtnWindowColor);
if (tmpColor != null)
{
if (ChkTransparent.Checked) ChkTransparent.Checked = false;
WindowColor = tmpColor;
BtnWindowColor.BackColor = WindowColor.Value;
}
}
private void BtnUnitColor_Click(object sender, EventArgs e)
{
UnitColor = SelectColor(BtnUnitColor);
if (UnitColor != null)
BtnUnitColor.BackColor = UnitColor.Value;
}
private void BtnModeColor_Click(object sender, EventArgs e)
{
ModeColor = SelectColor(BtnModeColor);
if (ModeColor != null)
BtnModeColor.BackColor = ModeColor.Value;
}
private void ChkTransparent_CheckedChanged(object sender, EventArgs e)
{
if (!initializing)
{
if (ChkTransparent.Checked)
{
WindowColor = Color.Transparent;
BtnWindowColor.BackColor = Color.Transparent;
ChkWindowBorder.Checked = false;
}
else
{
WindowColor = Color.Black;
BtnWindowColor.BackColor = Color.Black;
}
}
}
private void CboPrecision_SelectedIndexChanged(object sender, EventArgs e)
{
if (!initializing)
{
var item = CboPrecision.SelectedItem as String; //CboPrecision.Items[CboPrecision.SelectedIndex];
if (item != null)
{
if (int.TryParse(item, out int val))
{
Precision = val;
}
}
}
}
private void ChkWindowBorder_CheckedChanged(object sender, EventArgs e)
{
if (!initializing)
{
WindowBorder = ChkWindowBorder.Checked;
if (ChkWindowBorder.Checked) ChkTransparent.Checked = false;
}
}
private void NumInterval_ValueChanged(object sender, EventArgs e)
{
if (!initializing)
{
Interval = NumInterval.Value;
}
}
}
}