summaryrefslogtreecommitdiff
path: root/grapher/Models/AccelGUIFactory.cs
blob: e7167e9ac40379d4f6861f58488081ef1644e550 (plain) (blame)
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
using grapher.Models.Calculations;
using grapher.Models.Options;
using grapher.Models.Serialized;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace grapher.Models
{
    public static class AccelGUIFactory
    {
        #region Methods

        public static AccelGUI Construct(
            RawAcceleration form,
            ManagedAccel activeAccel,
            Chart accelerationChart,
            Chart accelerationChartY,
            Chart velocityChart,
            Chart velocityChartY,
            Chart gainChart,
            Chart gainChartY,
            ComboBox accelTypeDrop,
            Button writeButton,
            ToolStripMenuItem showVelocityGainToolStripMenuItem,
            ToolStripMenuItem wholeVectorToolStripMenuItem,
            ToolStripMenuItem byVectorComponentToolStripMenuItem,
            ToolStripMenuItem sensitivityToolStripMenuItem,
            ToolStripMenuItem velocityGainToolStripMenuItem,
            ToolStripMenuItem autoWriteMenuItem,
            ToolStripMenuItem scaleMenuItem,
            ToolStripTextBox dpiTextBox,
            ToolStripTextBox pollRateTextBox,
            TextBox sensitivityBoxX,
            TextBox sensitivityBoxY,
            TextBox rotationBox,
            TextBox weightBoxX,
            TextBox weightBoxY,
            TextBox capBoxX,
            TextBox capBoxY,
            TextBox offsetBox,
            TextBox accelerationBox,
            TextBox limitBox,
            TextBox midpointBox,
            CheckBox sensXYLock,
            CheckBox weightXYLock,
            CheckBox capXYLock,
            Label sensitivityLabel,
            Label rotationLabel,
            Label weightLabel,
            Label capLabel,
            Label offsetLabel,
            Label constantOneLabel,
            Label constantTwoLabel,
            Label constantThreeLabel,
            Label activeValueTitle,
            Label sensitivityActiveXLabel,
            Label sensitivityActiveYLabel,
            Label rotationActiveLabel,
            Label weightActiveXLabel,
            Label weightActiveYLabel,
            Label capActiveXLabel,
            Label capActiveYLabel,
            Label offsetActiveLabel,
            Label accelerationActiveLabel,
            Label limitExpActiveLabel,
            Label midpointActiveLabel,
            Label accelTypeActiveLabel,
            Label mouseLabel)
        {
            var accelCharts = new AccelCharts(
                                form,
                                new ChartXY(accelerationChart, accelerationChartY),
                                new ChartXY(velocityChart, velocityChartY),
                                new ChartXY(gainChart, gainChartY),
                                showVelocityGainToolStripMenuItem);

            var applyOptions = new ApplyOptions(wholeVectorToolStripMenuItem, byVectorComponentToolStripMenuItem);

            var sensitivity = new OptionXY(
                sensitivityBoxX,
                sensitivityBoxY,
                sensXYLock,
                form,
                1,
                sensitivityLabel,
                new ActiveValueLabelXY(
                    new ActiveValueLabel(sensitivityActiveXLabel, activeValueTitle),
                    new ActiveValueLabel(sensitivityActiveYLabel, activeValueTitle)),
                "Sensitivity");

            var rotation = new Option(
                rotationBox,
                form,
                0,
                rotationLabel,
                new ActiveValueLabel(rotationActiveLabel, activeValueTitle),
                "Rotation");

            var weight = new OptionXY(
                weightBoxX,
                weightBoxY,
                weightXYLock,
                form,
                1,
                weightLabel,
                new ActiveValueLabelXY(
                    new ActiveValueLabel(weightActiveXLabel, activeValueTitle),
                    new ActiveValueLabel(weightActiveYLabel, activeValueTitle)),
                "Weight");

            var cap = new OptionXY(
                capBoxX,
                capBoxY,
                capXYLock,
                form,
                0,
                capLabel,
                new ActiveValueLabelXY(
                    new ActiveValueLabel(capActiveXLabel, activeValueTitle),
                    new ActiveValueLabel(capActiveYLabel, activeValueTitle)),
                "Cap");

            var offset = new Option(
                offsetBox,
                form,
                0,
                offsetLabel,
                new ActiveValueLabel(offsetActiveLabel, activeValueTitle),
                "Offset");

            // The name and layout of these options is handled by AccelerationOptions object.
            var acceleration = new Option(
                new Field(accelerationBox, form, 0),
                constantOneLabel,
                new ActiveValueLabel(accelerationActiveLabel, activeValueTitle));

            var limitOrExponent = new Option(
                new Field(limitBox, form, 2),
                constantTwoLabel,
                new ActiveValueLabel(limitExpActiveLabel, activeValueTitle));

            var midpoint = new Option(
                new Field(midpointBox, form, 0),
                constantThreeLabel,
                new ActiveValueLabel(midpointActiveLabel, activeValueTitle));

            var accelerationOptions = new AccelOptions(
                accelTypeDrop,
                new Option[]
                {
                    offset,
                    acceleration,
                    limitOrExponent,
                    midpoint,
                },
                new OptionXY[]
                {
                    weight,
                    cap,
                },
                writeButton,
                new ActiveValueLabel(accelTypeActiveLabel, activeValueTitle));

            var capOptions = new CapOptions(
                sensitivityToolStripMenuItem,
                velocityGainToolStripMenuItem,
                cap,
                weight);

            var accelCalculator = new AccelCalculator(
                new Field(dpiTextBox.TextBox, form, Constants.DefaultDPI),
                new Field(pollRateTextBox.TextBox, form, Constants.DefaultPollRate));

            var settings = new SettingsManager(
                activeAccel,
                accelCalculator.DPI,
                accelCalculator.PollRate,
                autoWriteMenuItem);

            return new AccelGUI(
                form,
                accelCalculator,
                accelCharts,
                settings,
                applyOptions,
                accelerationOptions,
                sensitivity,
                rotation,
                weight,
                capOptions,
                offset,
                acceleration,
                limitOrExponent,
                midpoint,
                writeButton,
                mouseLabel,
                scaleMenuItem);
        }

        #endregion Methods
    }
}