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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
using grapher.Models.Serialized;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace grapher.Models.Options
{
public class ApplyOptions
{
#region Constructors
public ApplyOptions(
ToolStripMenuItem wholeVectorMenuItem,
ToolStripMenuItem byComponentMenuItem,
CheckBox byComponentVectorXYLock,
AccelOptionSet optionSetX,
AccelOptionSet optionSetY,
OptionXY sensitivity,
Option rotation,
Label lockXYLabel,
AccelCharts accelCharts)
{
WholeVectorMenuItem = wholeVectorMenuItem;
ByComponentVectorMenuItem = byComponentMenuItem;
WholeVectorMenuItem.Click += new System.EventHandler(OnWholeClicked);
ByComponentVectorMenuItem.Click += new System.EventHandler(OnByComponentClicked);
WholeVectorMenuItem.CheckedChanged += new System.EventHandler(OnWholeCheckedChange);
ByComponentVectorMenuItem.CheckedChanged += new System.EventHandler(OnByComponentCheckedChange);
ByComponentVectorXYLock = byComponentVectorXYLock;
OptionSetX = optionSetX;
OptionSetY = optionSetY;
Sensitivity = sensitivity;
Rotation = rotation;
LockXYLabel = lockXYLabel;
AccelCharts = accelCharts;
LockXYLabel.AutoSize = false;
LockXYLabel.TextAlign = ContentAlignment.MiddleCenter;
ByComponentVectorXYLock.CheckedChanged += new System.EventHandler(OnByComponentXYLockChecked);
ByComponentVectorXYLock.Checked = true;
Rotation.SnapTo(Sensitivity);
EnableWholeApplication();
}
#endregion Constructors
#region Properties
public ToolStripMenuItem WholeVectorMenuItem { get; }
public ToolStripMenuItem ByComponentVectorMenuItem { get; }
public CheckBox ByComponentVectorXYLock { get; }
public AccelOptionSet OptionSetX { get; }
public AccelOptionSet OptionSetY { get; }
public OptionXY Sensitivity { get; }
public Option Rotation { get; }
public AccelCharts AccelCharts { get; }
public Label ActiveValueTitleY { get; }
public Label LockXYLabel { get; }
public bool IsWhole { get; private set; }
#endregion Properties
#region Methods
public Vec2<AccelMode> GetModes()
{
var xMode = (AccelMode)OptionSetX.Options.AccelerationIndex;
return new Vec2<AccelMode>
{
x = xMode,
y = ByComponentVectorXYLock.Checked ? xMode : (AccelMode)OptionSetY.Options.AccelerationIndex
};
}
public Vec2<AccelArgs> GetArgs()
{
var xArgs = OptionSetX.GenerateArgs();
return new Vec2<AccelArgs>
{
x = xArgs,
y = ByComponentVectorXYLock.Checked ? xArgs : OptionSetY.GenerateArgs()
};
}
public void SetActiveValues(
double xSens,
double ySens,
double rotation,
int xMode,
int yMode,
AccelArgs xArgs,
AccelArgs yArgs,
bool isWhole)
{
Sensitivity.SetActiveValues(xSens, ySens);
Rotation.SetActiveValue(rotation);
OptionSetX.SetActiveValues(xMode, xArgs);
WholeVectorMenuItem.Checked = isWhole;
ByComponentVectorMenuItem.Checked = !isWhole;
ByComponentVectorXYLock.Checked = xArgs.Equals(yArgs);
OptionSetY.SetActiveValues(yMode, yArgs);
}
public void SetActiveValues(DriverSettings settings)
{
SetActiveValues(
settings.sensitivity.x,
settings.sensitivity.y,
settings.rotation,
(int)settings.modes.x,
(int)settings.modes.y,
settings.args.x,
settings.args.y,
settings.combineMagnitudes);
AccelCharts.SetLogarithmic(
OptionSetX.Options.AccelerationType.LogarithmicCharts,
OptionSetY.Options.AccelerationType.LogarithmicCharts);
}
public void OnWholeClicked(object sender, EventArgs e)
{
if (!WholeVectorMenuItem.Checked)
{
WholeVectorMenuItem.Checked = true;
ByComponentVectorMenuItem.Checked = false;
}
}
public void OnByComponentClicked(object sender, EventArgs e)
{
if (!ByComponentVectorMenuItem.Checked)
{
WholeVectorMenuItem.Checked = false;
ByComponentVectorMenuItem.Checked = true;
}
}
public void OnWholeCheckedChange(object sender, EventArgs e)
{
if (WholeVectorMenuItem.Checked)
{
EnableWholeApplication();
}
}
public void OnByComponentCheckedChange(object sender, EventArgs e)
{
if (ByComponentVectorMenuItem.Checked)
{
EnableByComponentApplication();
}
}
public void ShowWholeSet()
{
OptionSetX.SetRegularMode();
OptionSetY.Hide();
AccelCharts.SetWidened();
SetActiveTitlesWhole();
}
public void ShowByComponentAsOneSet()
{
OptionSetX.SetTitleMode("X = Y");
OptionSetY.Hide();
AccelCharts.SetWidened();
SetActiveTitlesByComponents();
}
public void ShowByComponentAsTwoSets()
{
OptionSetX.SetTitleMode("X");
OptionSetY.SetTitleMode("Y");
OptionSetY.Show();
AccelCharts.SetNarrowed();
}
public void ShowByComponentSet()
{
if (ByComponentVectorXYLock.Checked)
{
ShowByComponentAsOneSet();
}
else
{
ShowByComponentAsTwoSets();
}
}
private void OnByComponentXYLockChecked(object sender, EventArgs e)
{
if (!IsWhole)
{
ShowByComponentSet();
}
}
public void EnableWholeApplication()
{
IsWhole = true;
ByComponentVectorXYLock.Hide();
ShowWholeSet();
}
public void EnableByComponentApplication()
{
IsWhole = false;
ByComponentVectorXYLock.Show();
ShowByComponentSet();
}
private void SetActiveTitlesWhole()
{
OptionSetX.ActiveValuesTitle.Left = OptionSetX.Options.Left + OptionSetX.Options.Width;
LockXYLabel.Width = (AccelCharts.Left - OptionSetX.ActiveValuesTitle.Left) / 2;
OptionSetX.ActiveValuesTitle.Width = LockXYLabel.Width;
LockXYLabel.Left = OptionSetX.ActiveValuesTitle.Left + OptionSetX.ActiveValuesTitle.Width;
Sensitivity.Fields.LockCheckBox.Left = LockXYLabel.Left + LockXYLabel.Width / 2 - Sensitivity.Fields.LockCheckBox.Width / 2;
ByComponentVectorXYLock.Left = Sensitivity.Fields.LockCheckBox.Left;
AlignActiveValues();
}
private void SetActiveTitlesByComponents()
{
OptionSetY.ActiveValuesTitle.Left = OptionSetY.Options.Left + OptionSetY.Options.Width;
OptionSetY.ActiveValuesTitle.Width = Constants.NarrowChartLeft - OptionSetY.ActiveValuesTitle.Left;
AlignActiveValues();
}
private void AlignActiveValues()
{
OptionSetX.AlignActiveValues();
OptionSetY.AlignActiveValues();
Sensitivity.AlignActiveValues();
Rotation.AlignActiveValues();
}
#endregion Methods
}
}
|