forked from kugelrund/LiveSplit.MemoryGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextStyleOverrideControl.cs
55 lines (46 loc) · 2.12 KB
/
TextStyleOverrideControl.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
using System;
using System.Drawing;
using System.Windows.Forms;
namespace LiveSplit.MemoryGraph
{
public partial class TextStyleOverrideControl : UserControl
{
public bool OverrideColor { get; set; }
public bool OverrideFont { get; set; }
public Color OverridingColor { get; set; }
public Font OverridingFont { get; set; }
private string OverridingFontString => string.Format("{0} {1}", OverridingFont.FontFamily.Name, OverridingFont.Style);
public TextStyleOverrideControl()
{
InitializeComponent();
OverridingColor = Color.White;
OverrideColor = false;
OverridingFont = new Font("Segoe UI", 13, FontStyle.Regular, GraphicsUnit.Pixel);
OverrideFont = false;
btnColor.DataBindings.Add("BackColor", this, "OverridingColor", false, DataSourceUpdateMode.OnPropertyChanged);
chkOverrideColor.DataBindings.Add("Checked", this, "OverrideColor", false, DataSourceUpdateMode.OnPropertyChanged);
chkOverrideFont.DataBindings.Add("Checked", this, "OverrideFont", false, DataSourceUpdateMode.OnPropertyChanged);
chkOverrideColor_CheckedChanged(null, null);
chkOverrideFont_CheckedChanged(null, null);
}
private void chkOverrideColor_CheckedChanged(object sender, EventArgs e)
{
btnColor.Enabled = chkOverrideColor.Checked;
}
private void chkOverrideFont_CheckedChanged(object sender, EventArgs e)
{
btnFont.Enabled = chkOverrideFont.Checked;
}
private void btnColor_Click(object sender, EventArgs e)
{
UI.SettingsHelper.ColorButtonClick((Button)sender, this);
}
private void btnFont_Click(object sender, EventArgs e)
{
CustomFontDialog.FontDialog dialog = UI.SettingsHelper.GetFontDialog(OverridingFont, 7, 20);
dialog.FontChanged += (s, ev) => OverridingFont = ((CustomFontDialog.FontChangedEventArgs) ev).NewFont;
dialog.ShowDialog(this);
btnFont.Text = OverridingFontString;
}
}
}