summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-01 03:15:45 -0700
committerJacob Palecki <[email protected]>2020-09-01 03:15:45 -0700
commitfa497a2a20b02b4a44690d55ffa1cac26bafe35f (patch)
treee53983fb782dce4962e7e432217af914cfdec06c
parentMove constants to central class (diff)
downloadrawaccel-fa497a2a20b02b4a44690d55ffa1cac26bafe35f.tar.xz
rawaccel-fa497a2a20b02b4a44690d55ffa1cac26bafe35f.zip
Add factory to create AccelGUI
-rw-r--r--grapher/Form1.cs159
-rw-r--r--grapher/Models/AccelGUI.cs3
-rw-r--r--grapher/Models/AccelGUIFactory.cs207
-rw-r--r--grapher/grapher.csproj1
4 files changed, 253 insertions, 117 deletions
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
index 93b841c..20768ef 100644
--- a/grapher/Form1.cs
+++ b/grapher/Form1.cs
@@ -12,6 +12,7 @@ using System.Runtime.InteropServices;
using grapher.Models.Calculations;
using grapher.Models.Options;
using grapher.Models.Serialized;
+using grapher.Models;
namespace grapher
{
@@ -36,140 +37,68 @@ namespace grapher
throw;
}
- var accelCharts = new AccelCharts(
- this,
- new ChartXY(AccelerationChart, AccelerationChartY),
- new ChartXY(VelocityChart, VelocityChartY),
- new ChartXY(GainChart, GainChartY),
- showVelocityGainToolStripMenuItem);
-
ActiveValueTitle.AutoSize = false;
ActiveValueTitle.Left = LockXYLabel.Left + LockXYLabel.Width;
ActiveValueTitle.Width = AccelerationChart.Left - ActiveValueTitle.Left;
ActiveValueTitle.TextAlign = ContentAlignment.MiddleCenter;
- var applyOptions = new ApplyOptions(wholeVectorToolStripMenuItem, byVectorComponentToolStripMenuItem);
-
- var sensitivity = new OptionXY(
+ AccelGUI = AccelGUIFactory.Construct(
+ this,
+ activeAccel,
+ AccelerationChart,
+ AccelerationChartY,
+ VelocityChart,
+ VelocityChartY,
+ GainChart,
+ GainChartY,
+ accelTypeDrop,
+ writeButton,
+ showVelocityGainToolStripMenuItem,
+ wholeVectorToolStripMenuItem,
+ byVectorComponentToolStripMenuItem,
+ sensitivityToolStripMenuItem,
+ velocityGainToolStripMenuItem,
+ AutoWriteMenuItem,
+ scaleByDPIToolStripMenuItem,
+ DPITextBox,
+ PollRateTextBox,
sensitivityBoxX,
sensitivityBoxY,
- sensXYLock,
- this,
- 1,
- sensitivityLabel,
- new ActiveValueLabelXY(
- new ActiveValueLabel(SensitivityActiveXLabel, ActiveValueTitle),
- new ActiveValueLabel(SensitivityActiveYLabel, ActiveValueTitle)),
- "Sensitivity");
-
- var rotation = new Option(
rotationBox,
- this,
- 0,
- rotationLabel,
- new ActiveValueLabel(RotationActiveLabel, ActiveValueTitle),
- "Rotation");
-
- var weight = new OptionXY(
weightBoxFirst,
weightBoxSecond,
- weightXYLock,
- this,
- 1,
- weightLabel,
- new ActiveValueLabelXY(
- new ActiveValueLabel(WeightActiveXLabel, ActiveValueTitle),
- new ActiveValueLabel(WeightActiveYLabel, ActiveValueTitle)),
- "Weight");
-
- var cap = new OptionXY(
capBoxX,
capBoxY,
+ offsetBox,
+ accelerationBox,
+ limitBox,
+ midpointBox,
+ sensXYLock,
+ weightXYLock,
capXYLock,
- this,
- 0,
+ sensitivityLabel,
+ rotationLabel,
+ weightLabel,
capLabel,
- new ActiveValueLabelXY(
- new ActiveValueLabel(CapActiveXLabel, ActiveValueTitle),
- new ActiveValueLabel(CapActiveYLabel, ActiveValueTitle)),
- "Cap");
-
- var offset = new Option(
- offsetBox,
- this,
- 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, this, 0),
constantOneLabel,
- new ActiveValueLabel(AccelerationActiveLabel, ActiveValueTitle));
-
- var limitOrExponent = new Option(
- new Field(limitBox, this, 2),
constantTwoLabel,
- new ActiveValueLabel(LimitExpActiveLabel, ActiveValueTitle));
-
- var midpoint = new Option(
- new Field(midpointBox, this, 0),
constantThreeLabel,
- new ActiveValueLabel(MidpointActiveLabel, ActiveValueTitle));
+ ActiveValueTitle,
+ SensitivityActiveXLabel,
+ SensitivityActiveYLabel,
+ RotationActiveLabel,
+ WeightActiveXLabel,
+ WeightActiveYLabel,
+ CapActiveXLabel,
+ CapActiveYLabel,
+ OffsetActiveLabel,
+ AccelerationActiveLabel,
+ LimitExpActiveLabel,
+ MidpointActiveLabel,
+ AccelTypeActiveLabel,
+ MouseLabel);
- 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, this, Constants.DefaultDPI),
- new Field(PollRateTextBox.TextBox, this, Constants.DefaultPollRate));
-
- var settings = new SettingsManager(
- activeAccel,
- accelCalculator.DPI,
- accelCalculator.PollRate,
- AutoWriteMenuItem);
-
- AccelGUI = new AccelGUI(
- this,
- accelCalculator,
- accelCharts,
- settings,
- applyOptions,
- accelerationOptions,
- sensitivity,
- rotation,
- weight,
- capOptions,
- offset,
- acceleration,
- limitOrExponent,
- midpoint,
- writeButton,
- MouseLabel,
- ScaleMenuItem,
- AutoWriteMenuItem);
}
#endregion Constructor
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index 8fe752c..b9a578f 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -36,8 +36,7 @@ namespace grapher
Option midpoint,
Button writeButton,
Label mouseMoveLabel,
- ToolStripMenuItem scaleMenuItem,
- ToolStripMenuItem autoWriteMenuItem)
+ ToolStripMenuItem scaleMenuItem)
{
AccelForm = accelForm;
AccelCalculator = accelCalculator;
diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs
new file mode 100644
index 0000000..e7167e9
--- /dev/null
+++ b/grapher/Models/AccelGUIFactory.cs
@@ -0,0 +1,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
+ }
+}
diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj
index a726b1b..d382041 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -56,6 +56,7 @@
<Compile Include="Constants\Constants.cs" />
<Compile Include="Layouts\NaturalGainLayout.cs" />
<Compile Include="Layouts\SigmoidGainLayout.cs" />
+ <Compile Include="Models\AccelGUIFactory.cs" />
<Compile Include="Models\Calculations\AccelCalculator.cs" />
<Compile Include="Models\Calculations\AccelChartData.cs" />
<Compile Include="Models\Calculations\AccelData.cs" />