diff options
| -rw-r--r-- | grapher/Constants/AccelGUIConstants.cs | 36 | ||||
| -rw-r--r-- | grapher/Constants/Constants.cs | 76 | ||||
| -rw-r--r-- | grapher/Form1.cs | 4 | ||||
| -rw-r--r-- | grapher/Models/Calculations/AccelCalculator.cs | 9 | ||||
| -rw-r--r-- | grapher/Models/Charts/AccelCharts.cs | 13 | ||||
| -rw-r--r-- | grapher/Models/Charts/ChartXY.cs | 8 | ||||
| -rw-r--r-- | grapher/Models/Fields/Field.cs | 8 | ||||
| -rw-r--r-- | grapher/Models/Fields/FieldXY.cs | 18 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelOptions.cs | 11 | ||||
| -rw-r--r-- | grapher/Models/Options/ActiveValueLabel.cs | 6 | ||||
| -rw-r--r-- | grapher/Models/Options/ActiveValueLabelXY.cs | 14 | ||||
| -rw-r--r-- | grapher/Models/Options/ApplyOptions.cs | 1 | ||||
| -rw-r--r-- | grapher/Models/Options/CapOptions.cs | 5 | ||||
| -rw-r--r-- | grapher/Models/Serialized/RawAccelSettings.cs | 8 | ||||
| -rw-r--r-- | grapher/grapher.csproj | 1 |
15 files changed, 110 insertions, 108 deletions
diff --git a/grapher/Constants/AccelGUIConstants.cs b/grapher/Constants/AccelGUIConstants.cs deleted file mode 100644 index 20ec6d0..0000000 --- a/grapher/Constants/AccelGUIConstants.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace grapher.Constants -{ - public static class AccelGUIConstants - { - #region Constants - - /// <summary> Vertical separation between charts, in pixels. </summary> - public const int ChartSeparationVertical = 10; - - /// <summary> Needed to show full contents in form. Unsure why. </summary> - public const int FormHeightPadding = 35; - - /// <summary> DPI by which charts are scaled if none is set by user. </summary> - public const int DefaultDPI = 1200; - - /// <summary> Poll rate by which charts are scaled if none is set by user. </summary> - public const int DefaultPollRate = 1000; - - /// <summary> Resolution of chart calulation. </summary> - public const int Resolution = 100; - - /// <summary> Multiplied by DPI over poll rate to find rough max expected velocity. </summary> - public const double MaxMultiplier = 85; - - /// <summary> Ratio of max (X, Y) used in "by component" calulations to those used in "whole vector" calculations. </summary> - public const double XYToCombinedRatio = 1.4; - - #endregion Constants - } -} diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs new file mode 100644 index 0000000..61fa663 --- /dev/null +++ b/grapher/Constants/Constants.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace grapher +{ + public static class Constants + { + #region Constants + + /// <summary> Vertical separation between charts, in pixels. </summary> + public const int ChartSeparationVertical = 10; + + /// <summary> Default name of settings file. </summary> + public const string DefaultSettingsFileName = @"settings.json"; + + /// <summary> Needed to show full contents in form. Unsure why. </summary> + public const int FormHeightPadding = 35; + + /// <summary> Format string for gain cap active value label. </summary> + public const string GainCapFormatString = "0.##"; + + /// <summary> DPI by which charts are scaled if none is set by user. </summary> + public const int DefaultDPI = 1200; + + /// <summary> Poll rate by which charts are scaled if none is set by user. </summary> + public const int DefaultPollRate = 1000; + + /// <summary> Resolution of chart calulation. </summary> + public const int Resolution = 100; + + /// <summary> Multiplied by DPI over poll rate to find rough max expected velocity. </summary> + public const double MaxMultiplier = 85; + + /// <summary> Ratio of max (X, Y) used in "by component" calulations to those used in "whole vector" calculations. </summary> + public const double XYToCombinedRatio = 1.4; + + /// <summary> Separation between X and Y active value labels, in pixels. </summary> + public const int ActiveLabelXYSeparation = 2; + + /// <summary> Format string for shortened x and y textboxes. </summary> + public const string ShortenedFormatString = "0.###"; + + /// <summary> Format string for default active value labels. </summary> + public const string DefaultActiveValueFormatString = "0.######"; + + /// <summary> Format string for default textboxes. </summary> + public const string DefaultFieldFormatString = "0.#########"; + + /// <summary> Possible options to display in a layout. </summary> + public const int PossibleOptionsCount = 4; + + /// <summary> Possible x/y options to display in a layout. </summary> + public const int PossibleOptionsXYCount = 2; + + /// <summary> Horizontal separation between charts, in pixels. </summary> + public const int ChartSeparationHorizontal = 10; + + /// <summary> Default horizontal separation between x and y fields, in pixels. </summary> + public const int DefaultFieldSeparation = 4; + + /// <summary> Format string for shortened x and y fields. </summary> + public const string ShortenedFieldFormatString = "0.###"; + #endregion Constants + + #region ReadOnly + + /// <summary> Color of font in active value labels. </summary> + public static readonly Color ActiveValueFontColor = Color.FromArgb(255, 65, 65, 65); + + #endregion ReadOnly + } +} diff --git a/grapher/Form1.cs b/grapher/Form1.cs index f496293..93b841c 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -142,8 +142,8 @@ namespace grapher weight); var accelCalculator = new AccelCalculator( - new Field(DPITextBox.TextBox, this, AccelCalculator.DefaultDPI), - new Field(PollRateTextBox.TextBox, this, AccelCalculator.DefaultPollRate)); + new Field(DPITextBox.TextBox, this, Constants.DefaultDPI), + new Field(PollRateTextBox.TextBox, this, Constants.DefaultPollRate)); var settings = new SettingsManager( activeAccel, diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 0f0a60a..4e44902 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -1,5 +1,4 @@ -using grapher.Constants; -using grapher.Models.Serialized; +using grapher.Models.Serialized; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -179,9 +178,9 @@ namespace grapher.Models.Calculations public void ScaleByMouseSettings() { var dpiPollFactor = DPI.Data / PollRate.Data; - CombinedMaxVelocity = dpiPollFactor * AccelGUIConstants.MaxMultiplier; - Increment = (int) Math.Floor(CombinedMaxVelocity / AccelGUIConstants.Resolution); - XYMaxVelocity = CombinedMaxVelocity * AccelGUIConstants.XYToCombinedRatio; + CombinedMaxVelocity = dpiPollFactor * Constants.MaxMultiplier; + Increment = (int)Math.Floor(CombinedMaxVelocity / Constants.Resolution); + XYMaxVelocity = CombinedMaxVelocity * Constants.XYToCombinedRatio; MagnitudesCombined = GetMagnitudes(); MagnitudesX = GetMagnitudesX(); MagnitudesY = GetMagnitudesY(); diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 1574ce2..5e4b3de 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -1,5 +1,4 @@ -using grapher.Constants; -using grapher.Models.Calculations; +using grapher.Models.Calculations; using grapher.Models.Charts; using System; using System.Collections.Generic; @@ -41,9 +40,9 @@ namespace grapher SensitivityChart.SetTop(0); VelocityChart.SetHeight(SensitivityChart.Height); - VelocityChart.SetTop(SensitivityChart.Height + AccelGUIConstants.ChartSeparationVertical); + VelocityChart.SetTop(SensitivityChart.Height + Constants.ChartSeparationVertical); GainChart.SetHeight(SensitivityChart.Height); - GainChart.SetTop(VelocityChart.Top + VelocityChart.Height + AccelGUIConstants.ChartSeparationVertical); + GainChart.SetTop(VelocityChart.Top + VelocityChart.Height + Constants.ChartSeparationVertical); Rectangle screenRectangle = ContaingForm.RectangleToScreen(ContaingForm.ClientRectangle); FormBorderHeight = screenRectangle.Top - ContaingForm.Top; @@ -154,10 +153,10 @@ namespace grapher { VelocityChart.Show(); GainChart.Show(); - ContaingForm.Height = SensitivityChart.Height + - AccelGUIConstants.ChartSeparationVertical + + ContaingForm.Height = SensitivityChart.Height + + Constants.ChartSeparationVertical + VelocityChart.Height + - AccelGUIConstants.ChartSeparationVertical + + Constants.ChartSeparationVertical + GainChart.Height + FormBorderHeight; } diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index e5a948a..6a65e41 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -15,12 +15,6 @@ namespace grapher { public class ChartXY { - #region Constants - - public const int ChartSeparationHorizontal = 10; - - #endregion Constants - #region Constructors public ChartXY(Chart chartX, Chart chartY) @@ -31,7 +25,7 @@ namespace grapher ChartY.Top = ChartX.Top; ChartY.Height = ChartX.Height; ChartY.Width = ChartX.Width; - ChartY.Left = ChartX.Left + ChartX.Width + ChartSeparationHorizontal; + ChartY.Left = ChartX.Left + ChartX.Width + Constants.ChartSeparationHorizontal; SetupChart(ChartX); SetupChart(ChartY); diff --git a/grapher/Models/Fields/Field.cs b/grapher/Models/Fields/Field.cs index 03693ed..7651a37 100644 --- a/grapher/Models/Fields/Field.cs +++ b/grapher/Models/Fields/Field.cs @@ -10,12 +10,6 @@ namespace grapher { public class Field { - #region Constants - - public const string DefaultFormatString = "0.#########"; - - #endregion Constants - #region Enumerations public enum FieldState @@ -39,7 +33,7 @@ namespace grapher DefaultData = defaultData; State = FieldState.Undefined; ContainingForm = containingForm; - FormatString = DefaultFormatString; + FormatString = Constants.DefaultFieldFormatString; box.KeyDown += new System.Windows.Forms.KeyEventHandler(KeyDown); box.Leave += new System.EventHandler(FocusLeave); diff --git a/grapher/Models/Fields/FieldXY.cs b/grapher/Models/Fields/FieldXY.cs index 83f6434..826be27 100644 --- a/grapher/Models/Fields/FieldXY.cs +++ b/grapher/Models/Fields/FieldXY.cs @@ -9,31 +9,23 @@ namespace grapher { public class FieldXY { - #region Constants - - public const int DefaultSeparation = 4; - - public const string ShortenedFormatString = "0.###"; - - #endregion Constants - #region Constructors public FieldXY(TextBox xBox, TextBox yBox, CheckBox lockCheckBox, Form containingForm, double defaultData) { XField = new Field(xBox, containingForm, defaultData); YField = new Field(yBox, containingForm, defaultData); - YField.FormatString = ShortenedFormatString; + YField.FormatString = Constants.ShortenedFormatString; LockCheckBox = lockCheckBox; LockCheckBox.CheckedChanged += new System.EventHandler(CheckChanged); - XField.Box.Width = (YField.Box.Left + YField.Box.Width - XField.Box.Left - DefaultSeparation) / 2; + XField.Box.Width = (YField.Box.Left + YField.Box.Width - XField.Box.Left - Constants.DefaultFieldSeparation) / 2; YField.Box.Width = XField.Box.Width; DefaultWidthX = XField.Box.Width; DefaultWidthY = YField.Box.Width; - YField.Box.Left = XField.Box.Left + XField.Box.Width + DefaultSeparation; + YField.Box.Left = XField.Box.Left + XField.Box.Width + Constants.DefaultFieldSeparation; CombinedWidth = DefaultWidthX + DefaultWidthY + YField.Box.Left - (XField.Box.Left + DefaultWidthX); SetCombined(); @@ -99,7 +91,7 @@ namespace grapher YField.SetToUnavailable(); YField.Box.Hide(); XField.Box.Width = CombinedWidth; - XField.FormatString = Field.DefaultFormatString; + XField.FormatString = Constants.DefaultFieldFormatString; } public void SetSeparate() @@ -109,7 +101,7 @@ namespace grapher XField.Box.Width = DefaultWidthX; YField.Box.Width = DefaultWidthY; - XField.FormatString = ShortenedFormatString; + XField.FormatString = Constants.ShortenedFormatString; if (XField.State == Field.FieldState.Default) { diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelOptions.cs index 224c5cb..8c01585 100644 --- a/grapher/Models/Options/AccelOptions.cs +++ b/grapher/Models/Options/AccelOptions.cs @@ -11,13 +11,6 @@ namespace grapher { public class AccelOptions { - #region Constants - - public const int PossibleOptionsCount = 4; - public const int PossibleOptionsXYCount = 2; - - #endregion Constants - #region Fields public static readonly Dictionary<string, LayoutBase> AccelerationTypes = new List<LayoutBase> @@ -49,12 +42,12 @@ namespace grapher AccelDropdown.Items.AddRange(AccelerationTypes.Keys.ToArray()); AccelDropdown.SelectedIndexChanged += new System.EventHandler(OnIndexChanged); - if (options.Length > PossibleOptionsCount) + if (options.Length > Constants.PossibleOptionsCount) { throw new Exception("Layout given too many options."); } - if (optionsXY.Length > PossibleOptionsXYCount) + if (optionsXY.Length > Constants.PossibleOptionsXYCount) { throw new Exception("Layout given too many options."); } diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs index b2355b5..d2b43ab 100644 --- a/grapher/Models/Options/ActiveValueLabel.cs +++ b/grapher/Models/Options/ActiveValueLabel.cs @@ -12,8 +12,6 @@ namespace grapher.Models.Options { #region Constants - public const string DefaultFormatString = "0.######"; - public static readonly Color ActiveValueFontColor = Color.FromArgb(255, 65, 65, 65); #endregion Constants @@ -29,13 +27,13 @@ namespace grapher.Models.Options public ActiveValueLabel(Label valueLabel, Label centeringLabel) { ValueLabel = valueLabel; - ValueLabel.ForeColor = ActiveValueFontColor; + ValueLabel.ForeColor = Constants.ActiveValueFontColor; Left = centeringLabel.Left; Width = centeringLabel.Width; ValueLabel.AutoSize = false; ValueLabel.TextAlign = ContentAlignment.MiddleCenter; - FormatString = DefaultFormatString; + FormatString = Constants.DefaultActiveValueFormatString; Prefix = string.Empty; } diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index 553ce48..c8caddf 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -10,8 +10,6 @@ namespace grapher.Models.Options { #region Constants - public const int ActiveLabelXYSeparation = 2; - public const string ShortenedFormatString = "0.###"; #endregion Constants @@ -25,11 +23,11 @@ namespace grapher.Models.Options Y = y; FullWidth = x.Width; - ShortenedWidth = (FullWidth - ActiveLabelXYSeparation) / 2; + ShortenedWidth = (FullWidth - Constants.ActiveLabelXYSeparation) / 2; - Y.Left = X.Left + ShortenedWidth + ActiveLabelXYSeparation; + Y.Left = X.Left + ShortenedWidth + Constants.ActiveLabelXYSeparation; Y.Width = ShortenedWidth; - Y.FormatString = ShortenedFormatString; + Y.FormatString = Constants.ShortenedFormatString; Combined = false; SetCombined(); @@ -72,7 +70,7 @@ namespace grapher.Models.Options { if (!Combined) { - X.FormatString = ActiveValueLabel.DefaultFormatString; + X.FormatString = Constants.DefaultActiveValueFormatString; X.Width = FullWidth; X.Prefix = string.Empty; Y.Hide(); @@ -85,7 +83,7 @@ namespace grapher.Models.Options { if (Combined) { - X.FormatString = ShortenedFormatString; + X.FormatString = Constants.ShortenedFormatString; X.Width = ShortenedWidth; X.Prefix = "X"; Y.Prefix = "Y"; @@ -95,6 +93,6 @@ namespace grapher.Models.Options Combined = false; } - #region Methods + #endregion Methods } } diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs index a269b49..703f0d5 100644 --- a/grapher/Models/Options/ApplyOptions.cs +++ b/grapher/Models/Options/ApplyOptions.cs @@ -31,6 +31,7 @@ namespace grapher.Models.Options #endregion Constructors #region Properties + public ToolStripMenuItem WholeVectorMenuItem { get; } public ToolStripMenuItem ByComponentVectorMenuItem { get; } diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs index 9d903ec..62f74a3 100644 --- a/grapher/Models/Options/CapOptions.cs +++ b/grapher/Models/Options/CapOptions.cs @@ -12,7 +12,6 @@ namespace grapher { #region Constants - public const string GainCapFormatString = "0.##"; #endregion Constants @@ -103,7 +102,7 @@ namespace grapher { if (capGainEnabled) { - CapOption.ActiveValueLabels.X.FormatString = GainCapFormatString; + CapOption.ActiveValueLabels.X.FormatString = Constants.GainCapFormatString; CapOption.ActiveValueLabels.X.Prefix = "Gain"; CapOption.SetActiveValues(gainCap, gainCap); SensitivityCapCheck.Checked = true; @@ -111,7 +110,7 @@ namespace grapher } else { - CapOption.ActiveValueLabels.X.FormatString = ActiveValueLabel.DefaultFormatString; + CapOption.ActiveValueLabels.X.FormatString = Constants.DefaultActiveValueFormatString; CapOption.ActiveValueLabels.X.Prefix = string.Empty; CapOption.SetActiveValues(sensCapX, sensCapY); SensitivityCapCheck.Checked = false; diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs index 768841a..7466e82 100644 --- a/grapher/Models/Serialized/RawAccelSettings.cs +++ b/grapher/Models/Serialized/RawAccelSettings.cs @@ -13,16 +13,10 @@ namespace grapher.Models.Serialized [Serializable] public class RawAccelSettings { - #region Constants - - public const string DefaultSettingsFileName = @"settings.json"; - - #endregion Constants - #region Fields public static readonly string ExecutingDirectory = AppDomain.CurrentDomain.BaseDirectory; - public static readonly string DefaultSettingsFile = Path.Combine(ExecutingDirectory, DefaultSettingsFileName); + public static readonly string DefaultSettingsFile = Path.Combine(ExecutingDirectory, Constants.DefaultSettingsFileName); public static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error, diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 277db21..a726b1b 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -53,6 +53,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Constants\Constants.cs" /> <Compile Include="Layouts\NaturalGainLayout.cs" /> <Compile Include="Layouts\SigmoidGainLayout.cs" /> <Compile Include="Models\Calculations\AccelCalculator.cs" /> |