-
Notifications
You must be signed in to change notification settings - Fork 0
/
WindowSettings.cs
97 lines (81 loc) · 2.84 KB
/
WindowSettings.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
namespace Kneeboard_Picture_Viewer
{
public partial class WindowSettings : Form
{
private WindowMain mainWindow = (WindowMain)Application.OpenForms[0];
/*
* save settings in VAR and restore on Close/Cancel
*
private System.Configuration.SettingsBase settingsCache;
settingsCache = Properties.Settings.Default;
Properties.Settings.Default = settingsCache;
*
* or save and restore propertyGrid items
private GridItem gi;
gi = propertyGrid.SelectedGridItem;
while (gi.Parent != null)
{
gi = gi.Parent;
}
foreach (GridItem item in gi.GridItems)
{
ParseGridItems(item);
}
private void ParseGridItems(GridItem gi)
{
if (gi.GridItemType == GridItemType.Category)
{
foreach (GridItem item in gi.GridItems)
{
ParseGridItems(item);
}
}
if (gi.Value != null)
{
Debug.WriteLine(gi.Label +": "+ gi.Value.ToString());
//save to array
}
}
*/
public WindowSettings()
{
InitializeComponent();
// load current settings from store
Properties.Settings.Default.Reload();
// Set tooltips
toolTipSettings.SetToolTip(btnSave, "Apply & Save settings and close window");
toolTipSettings.SetToolTip(btnTry, "Preview settings");
toolTipSettings.SetToolTip(btnReset, "WARNING: Resets all settings to default!");
toolTipSettings.SetToolTip(btnCancel, "Discard changes and close window");
btnTry.Visible = false;
}
private void WindowSettings_Load(object sender, EventArgs e)
{
propertyGrid.SelectedObject = Properties.Settings.Default;
}
private void btnSave_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Save();
// apply settings
mainWindow.WindowMain_ApplySettings();
this.Close();
}
private void btnTry_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Save();
// apply settings
mainWindow.WindowMain_ApplySettings();
}
private void btnReset_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Reset();
// apply settings
mainWindow.WindowMain_ApplySettings();
WindowSettings_Load(sender, e);
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}