diff options
Diffstat (limited to 'grapher/Models')
| -rw-r--r-- | grapher/Models/AccelGUI.cs | 69 | ||||
| -rw-r--r-- | grapher/Models/AccelGUIFactory.cs | 208 | ||||
| -rw-r--r-- | grapher/Models/Fields/Field.cs | 48 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelOptionSet.cs | 169 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs (renamed from grapher/Models/Options/AccelOptions.cs) | 91 | ||||
| -rw-r--r-- | grapher/Models/Options/CapOptions.cs | 58 | ||||
| -rw-r--r-- | grapher/Models/Options/Option.cs | 48 |
7 files changed, 527 insertions, 164 deletions
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index b9a578f..5ea3595 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -25,15 +25,10 @@ namespace grapher AccelCharts accelCharts, SettingsManager settings, ApplyOptions applyOptions, - AccelOptions accelOptions, OptionXY sensitivity, Option rotation, - OptionXY weight, - CapOptions cap, - Option offset, - Option acceleration, - Option limtOrExp, - Option midpoint, + AccelOptionSet optionSetX, + AccelOptionSet optionSetY, Button writeButton, Label mouseMoveLabel, ToolStripMenuItem scaleMenuItem) @@ -41,21 +36,14 @@ namespace grapher AccelForm = accelForm; AccelCalculator = accelCalculator; AccelCharts = accelCharts; - AccelerationOptions = accelOptions; ApplyOptions = applyOptions; Sensitivity = sensitivity; Rotation = rotation; - Weight = weight; - Cap = cap; - Offset = offset; - Acceleration = acceleration; - LimitOrExponent = limtOrExp; - Midpoint = midpoint; WriteButton = writeButton; ScaleMenuItem = scaleMenuItem; Settings = settings; Settings.Startup(); - UpdateGraph(); + RefreshOnRead(); MouseWatcher = new MouseWatcher(AccelForm, mouseMoveLabel, AccelCharts); @@ -76,23 +64,13 @@ namespace grapher public ApplyOptions ApplyOptions { get; } - public AccelOptions AccelerationOptions { get; } - public OptionXY Sensitivity { get; } public Option Rotation { get; } - public OptionXY Weight { get; } - - public CapOptions Cap { get; } - - public Option Offset { get; } - - public Option Acceleration { get; } - - public Option LimitOrExponent { get; } + public AccelOptionSet OptionSetX { get; } - public Option Midpoint { get; } + public AccelOptionSet OptionSetY { get; } public Button WriteButton { get; } @@ -117,28 +95,23 @@ namespace grapher combineMagnitudes = ApplyOptions.IsWhole, modes = new Vec2<AccelMode> { - x = (AccelMode)AccelerationOptions.AccelerationIndex + x = (AccelMode)OptionSetX.AccelTypeOptions.AccelerationIndex, + y = (AccelMode)OptionSetY.AccelTypeOptions.AccelerationIndex }, args = new Vec2<AccelArgs> { - x = new AccelArgs - { - offset = Offset.Field.Data, - weight = Weight.Fields.X, - gainCap = Cap.VelocityGainCap, - scaleCap = Cap.SensitivityCapX, - accel = Acceleration.Field.Data, - rate = Acceleration.Field.Data, - powerScale = Acceleration.Field.Data, - limit = LimitOrExponent.Field.Data, - exponent = LimitOrExponent.Field.Data, - powerExponent = LimitOrExponent.Field.Data, - midpoint = Midpoint.Field.Data - } + x = OptionSetX.GenerateArgs(), + y = OptionSetY.GenerateArgs() }, minimumTime = .4 }); + RefreshOnRead(); + } + + public void RefreshOnRead() + { UpdateGraph(); + UpdateShownActiveValues(); } public void UpdateGraph() @@ -148,23 +121,17 @@ namespace grapher Settings.ActiveAccel, Settings.RawAccelSettings.AccelerationSettings); AccelCharts.Bind(); - UpdateShownActiveValues(); } public void UpdateShownActiveValues() { var settings = Settings.RawAccelSettings.AccelerationSettings; - + Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y); Rotation.SetActiveValue(settings.rotation); - AccelerationOptions.SetActiveValue((int)settings.modes.x); - Offset.SetActiveValue(settings.args.x.offset); - Weight.SetActiveValues(settings.args.x.weight, settings.args.x.weight); - Acceleration.SetActiveValue(settings.args.x.accel); // rate, powerscale - LimitOrExponent.SetActiveValue(settings.args.x.limit); //exp, powerexp - Midpoint.SetActiveValue(settings.args.x.midpoint); ApplyOptions.SetActive(settings.combineMagnitudes); - Cap.SetActiveValues(settings.args.x.gainCap, settings.args.x.scaleCap, settings.args.y.scaleCap, settings.args.x.gainCap > 0); + OptionSetX.SetActiveValues((int)settings.modes.x, settings.args.x); + OptionSetY.SetActiveValues((int)settings.modes.y, settings.args.y); AccelCharts.RefreshXY(settings.combineMagnitudes); } diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index e7167e9..e4637ec 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -24,7 +24,8 @@ namespace grapher.Models Chart velocityChartY, Chart gainChart, Chart gainChartY, - ComboBox accelTypeDrop, + ComboBox accelTypeDropX, + ComboBox accelTypeDropY, Button writeButton, ToolStripMenuItem showVelocityGainToolStripMenuItem, ToolStripMenuItem wholeVectorToolStripMenuItem, @@ -42,21 +43,31 @@ namespace grapher.Models TextBox weightBoxY, TextBox capBoxX, TextBox capBoxY, - TextBox offsetBox, - TextBox accelerationBox, - TextBox limitBox, - TextBox midpointBox, + TextBox offsetBoxX, + TextBox offsetBoxY, + TextBox accelerationBoxX, + TextBox accelerationBoxY, + TextBox limitBoxX, + TextBox limitBoxY, + TextBox midpointBoxX, + TextBox midpointBoxY, CheckBox sensXYLock, CheckBox weightXYLock, CheckBox capXYLock, Label sensitivityLabel, Label rotationLabel, - Label weightLabel, - Label capLabel, - Label offsetLabel, - Label constantOneLabel, - Label constantTwoLabel, - Label constantThreeLabel, + Label weightLabelX, + Label weightLabelY, + Label capLabelX, + Label capLabelY, + Label offsetLabelX, + Label offsetLabelY, + Label constantOneLabelX, + Label constantOneLabelY, + Label constantTwoLabelX, + Label constantTwoLabelY, + Label constantThreeLabelX, + Label constantThreeLabelY, Label activeValueTitle, Label sensitivityActiveXLabel, Label sensitivityActiveYLabel, @@ -65,11 +76,17 @@ namespace grapher.Models Label weightActiveYLabel, Label capActiveXLabel, Label capActiveYLabel, - Label offsetActiveLabel, - Label accelerationActiveLabel, - Label limitExpActiveLabel, - Label midpointActiveLabel, + Label offsetActiveLabelX, + Label offsetActiveLabelY, + Label accelerationActiveLabelX, + Label accelerationActiveLabelY, + Label limitExpActiveLabelX, + Label limitExpActiveLabelY, + Label midpointActiveLabelX, + Label midpointActiveLabelY, Label accelTypeActiveLabel, + Label optionSetXTitle, + Label optionSetYTitle, Label mouseLabel) { var accelCharts = new AccelCharts( @@ -101,76 +118,142 @@ namespace grapher.Models new ActiveValueLabel(rotationActiveLabel, activeValueTitle), "Rotation"); - var weight = new OptionXY( + var weightX = new Option( weightBoxX, + form, + 1, + weightLabelX, + new ActiveValueLabel(weightActiveXLabel, activeValueTitle), + "Weight"); + + var weightY = new Option( weightBoxY, - weightXYLock, form, 1, - weightLabel, - new ActiveValueLabelXY( - new ActiveValueLabel(weightActiveXLabel, activeValueTitle), - new ActiveValueLabel(weightActiveYLabel, activeValueTitle)), + weightLabelY, + new ActiveValueLabel(weightActiveYLabel, activeValueTitle), "Weight"); - var cap = new OptionXY( + var capX = new Option( capBoxX, + form, + 0, + capLabelX, + new ActiveValueLabel(capActiveXLabel, activeValueTitle), + "Cap"); + + var capY = new Option( capBoxY, - capXYLock, form, 0, - capLabel, - new ActiveValueLabelXY( - new ActiveValueLabel(capActiveXLabel, activeValueTitle), - new ActiveValueLabel(capActiveYLabel, activeValueTitle)), + capLabelY, + new ActiveValueLabel(capActiveYLabel, activeValueTitle), "Cap"); - var offset = new Option( - offsetBox, + var offsetX = new Option( + offsetBoxX, form, 0, - offsetLabel, - new ActiveValueLabel(offsetActiveLabel, activeValueTitle), + offsetLabelX, + new ActiveValueLabel(offsetActiveLabelX, activeValueTitle), + "Offset"); + + var offsetY = new Option( + offsetBoxY, + form, + 0, + offsetLabelY, + new ActiveValueLabel(offsetActiveLabelY, 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, + var accelerationX = new Option( + new Field(accelerationBoxX, form, 0), + constantOneLabelX, + new ActiveValueLabel(accelerationActiveLabelX, activeValueTitle)); + + var accelerationY = new Option( + new Field(accelerationBoxY, form, 0), + constantOneLabelY, + new ActiveValueLabel(accelerationActiveLabelY, activeValueTitle)); + + var limitOrExponentX = new Option( + new Field(limitBoxX, form, 2), + constantTwoLabelX, + new ActiveValueLabel(limitExpActiveLabelX, activeValueTitle)); + + var limitOrExponentY = new Option( + new Field(limitBoxY, form, 2), + constantTwoLabelY, + new ActiveValueLabel(limitExpActiveLabelY, activeValueTitle)); + + var midpointX = new Option( + new Field(midpointBoxX, form, 0), + constantThreeLabelX, + new ActiveValueLabel(midpointActiveLabelX, activeValueTitle)); + + var midpointY = new Option( + new Field(midpointBoxY, form, 0), + constantThreeLabelY, + new ActiveValueLabel(midpointActiveLabelY, activeValueTitle)); + + var accelerationOptionsX = new AccelTypeOptions( + accelTypeDropX, new Option[] { - offset, - acceleration, - limitOrExponent, - midpoint, + offsetX, + accelerationX, + limitOrExponentX, + midpointX, + capX, + weightX }, - new OptionXY[] + writeButton, + new ActiveValueLabel(accelTypeActiveLabel, activeValueTitle)); + + var accelerationOptionsY = new AccelTypeOptions( + accelTypeDropY, + new Option[] { - weight, - cap, + offsetY, + accelerationY, + limitOrExponentY, + midpointY, + capY, + weightY }, writeButton, new ActiveValueLabel(accelTypeActiveLabel, activeValueTitle)); - var capOptions = new CapOptions( + var capOptionsX = new CapOptions( sensitivityToolStripMenuItem, velocityGainToolStripMenuItem, - cap, - weight); + capX); + + var capOptionsY = new CapOptions( + sensitivityToolStripMenuItem, + velocityGainToolStripMenuItem, + capY); + + var optionsSetX = new AccelOptionSet( + optionSetXTitle, + accelerationOptionsX, + accelerationX, + capOptionsX, + weightX, + offsetX, + limitOrExponentX, + midpointX); + + var optionsSetY = new AccelOptionSet( + optionSetYTitle, + accelerationOptionsY, + accelerationY, + capOptionsY, + weightY, + offsetY, + limitOrExponentY, + midpointY); var accelCalculator = new AccelCalculator( new Field(dpiTextBox.TextBox, form, Constants.DefaultDPI), @@ -188,15 +271,10 @@ namespace grapher.Models accelCharts, settings, applyOptions, - accelerationOptions, sensitivity, rotation, - weight, - capOptions, - offset, - acceleration, - limitOrExponent, - midpoint, + optionsSetX, + optionsSetY, writeButton, mouseLabel, scaleMenuItem); diff --git a/grapher/Models/Fields/Field.cs b/grapher/Models/Fields/Field.cs index 7651a37..6f38314 100644 --- a/grapher/Models/Fields/Field.cs +++ b/grapher/Models/Fields/Field.cs @@ -58,6 +58,54 @@ namespace grapher public FieldState PreviousState { get; private set; } + public int Top + { + get + { + return Box.Top; + } + set + { + Box.Top = value; + } + } + + public int Height + { + get + { + return Box.Height; + } + set + { + Box.Height = value; + } + } + + public int Left + { + get + { + return Box.Left; + } + set + { + Box.Left = value; + } + } + + public int Width + { + get + { + return Box.Width; + } + set + { + Box.Width = value; + } + } + private double DefaultData { get; } #endregion Properties diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs new file mode 100644 index 0000000..2d15ad6 --- /dev/null +++ b/grapher/Models/Options/AccelOptionSet.cs @@ -0,0 +1,169 @@ +using grapher.Models.Serialized; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Options +{ + public class AccelOptionSet + { + public AccelOptionSet( + Label titleLabel, + AccelTypeOptions accelTypeOptions, + Option acceleration, + CapOptions cap, + Option weight, + Option offset, + Option limitOrExp, + Option midpoint) + { + TitleLabel = titleLabel; + AccelTypeOptions = accelTypeOptions; + Acceleration = acceleration; + Cap = cap; + Weight = weight; + Offset = offset; + LimitOrExponent = limitOrExp; + Midpoint = midpoint; + + AccelTypeOptions.ShowFullText(); + + TitleLabel.Top = TopAnchor; + } + + public int TopAnchor { get; } + + public Label TitleLabel { get; } + + public AccelTypeOptions AccelTypeOptions { get; } + + public Option Acceleration { get; } + + public CapOptions Cap { get; } + + public Option Weight { get; } + + public Option Offset { get; } + + public Option LimitOrExponent { get; } + + public Option Midpoint { get; } + + public bool IsTitleMode { get; private set; } + + public void SetRegularMode() + { + if (IsTitleMode) + { + IsTitleMode = false; + + HideTitle(); + AccelTypeOptions.Left = Acceleration.Left; + AccelTypeOptions.Width = Acceleration.Width; + AccelTypeOptions.ShowFullText(); + } + } + + public void SetTitleMode() + { + if (!IsTitleMode) + { + IsTitleMode = true; + + AccelTypeOptions.Left = Acceleration.Field.Left; + AccelTypeOptions.Width = Acceleration.Field.Width; + AccelTypeOptions.ShowFullText(); + DisplayTitle(); + } + } + + public void Hide() + { + TitleLabel.Hide(); + AccelTypeOptions.Hide(); + Acceleration.Hide(); + Cap.Hide(); + Weight.Hide(); + Offset.Hide(); + LimitOrExponent.Hide(); + Midpoint.Hide(); + } + + public void Show() + { + if (IsTitleMode) + { + TitleLabel.Show(); + } + + AccelTypeOptions.Show(); + Acceleration.Show(); + Cap.Show(); + Weight.Show(); + Offset.Show(); + LimitOrExponent.Show(); + Midpoint.Show(); + } + + public void DisplayTitle() + { + TitleLabel.Show(); + + SetOptionsTop(TitleLabel.Top + TitleLabel.Height + Constants.OptionVerticalSeperation); + } + + public void HideTitle() + { + TitleLabel.Hide(); + + SetOptionsTop(TopAnchor); + } + + public void SetArgs(AccelArgs args) + { + args.accel = Acceleration.Field.Data; + args.rate = Acceleration.Field.Data; + args.powerScale = Acceleration.Field.Data; + args.gainCap = Cap.VelocityGainCap; + args.scaleCap = Cap.SensitivityCap; + args.limit = LimitOrExponent.Field.Data; + args.exponent = LimitOrExponent.Field.Data; + args.powerExponent = LimitOrExponent.Field.Data; + args.offset = Offset.Field.Data; + args.midpoint = Midpoint.Field.Data; + args.weight = Weight.Field.Data; + } + + public AccelArgs GenerateArgs() + { + AccelArgs args = new AccelArgs(); + SetArgs(args); + return args; + } + + public void SetActiveValues(int mode, AccelArgs args) + { + AccelTypeOptions.SetActiveValue(mode); + Weight.SetActiveValue(args.weight); + Cap.SetActiveValues(args.gainCap, args.scaleCap, args.gainCap > 0); + Offset.SetActiveValue(args.offset); + Acceleration.SetActiveValue(args.accel); + LimitOrExponent.SetActiveValue(args.exponent); + Midpoint.SetActiveValue(args.midpoint); + } + + private void SetOptionsTop(int top) + { + AccelTypeOptions.Top = top; + Acceleration.Top = AccelTypeOptions.Top+ AccelTypeOptions.Height + Constants.OptionVerticalSeperation; + Cap.SnapTo(Acceleration); + Weight.SnapTo(Cap); + Offset.SnapTo(Weight); + LimitOrExponent.SnapTo(Offset); + Midpoint.SnapTo(LimitOrExponent); + } + } +} diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index 8c01585..2359b8d 100644 --- a/grapher/Models/Options/AccelOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -9,7 +9,7 @@ using System.Windows.Forms; namespace grapher { - public class AccelOptions + public class AccelTypeOptions { #region Fields @@ -30,10 +30,9 @@ namespace grapher #region Constructors - public AccelOptions( + public AccelTypeOptions( ComboBox accelDropdown, Option[] options, - OptionXY[] optionsXY, Button writeButton, ActiveValueLabel activeValueLabel) { @@ -47,17 +46,12 @@ namespace grapher throw new Exception("Layout given too many options."); } - if (optionsXY.Length > Constants.PossibleOptionsXYCount) - { - throw new Exception("Layout given too many options."); - } - Options = options; - OptionsXY = optionsXY; WriteButton = writeButton; ActiveValueLabel = activeValueLabel; Layout("Off"); + ShowingDefault = true; } #endregion Constructors @@ -74,29 +68,104 @@ namespace grapher public Option[] Options { get; } - public OptionXY[] OptionsXY { get; } + public int Top + { + get + { + return AccelDropdown.Top; + } + set + { + AccelDropdown.Top = value; + } + } + + public int Height + { + get + { + return AccelDropdown.Height; + } + set + { + AccelDropdown.Height = value; + } + } + + public int Left + { + get + { + return AccelDropdown.Left; + } + set + { + AccelDropdown.Left = value; + } + } + + public int Width + { + get + { + return AccelDropdown.Width; + } + set + { + AccelDropdown.Width = value; + } + } + + private bool ShowingDefault { get; set; } #endregion Properties #region Methods + public void Hide() + { + AccelDropdown.Hide(); + } + + public void Show() + { + AccelDropdown.Show(); + } + public void SetActiveValue(int index) { var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name; ActiveValueLabel.SetValue(name); } + public void ShowFullText() + { + if (ShowingDefault) + { + AccelDropdown.Text = Constants.AccelDropDownDefaultFullText; + } + } + + public void ShowShortenedText() + { + if (ShowingDefault) + { + AccelDropdown.Text = Constants.AccelDropDownDefaultShortText; + } + } + private void OnIndexChanged(object sender, EventArgs e) { var accelerationTypeString = AccelDropdown.SelectedItem.ToString(); Layout(accelerationTypeString); + ShowingDefault = false; } private void Layout(string type) { var accelerationType = AccelerationTypes[type]; AccelerationIndex = accelerationType.Index; - accelerationType.Layout(Options, OptionsXY, WriteButton); + accelerationType.Layout(Options, WriteButton); } #endregion Methods diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs index 62f74a3..6768a85 100644 --- a/grapher/Models/Options/CapOptions.cs +++ b/grapher/Models/Options/CapOptions.cs @@ -20,14 +20,12 @@ namespace grapher public CapOptions( ToolStripMenuItem sensitivityCapCheck, ToolStripMenuItem velocityGainCapCheck, - OptionXY capOption, - OptionXY weightOption) + Option capOption) { SensitivityCapCheck = sensitivityCapCheck; VelocityGainCapCheck = velocityGainCapCheck; CapOption = capOption; - WeightOption = weightOption; SensitivityCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick); VelocityGainCapCheck.Click += new System.EventHandler(OnVelocityGainCapCheckClick); @@ -46,32 +44,16 @@ namespace grapher public ToolStripMenuItem VelocityGainCapCheck { get; } - public OptionXY CapOption { get; } - - public OptionXY WeightOption { get; } + public Option CapOption { get; } public bool IsSensitivityGain { get; private set; } - public double SensitivityCapX { + public double SensitivityCap { get { if (IsSensitivityGain) { - return CapOption.Fields.X; - } - else - { - return 0; - } - } - } - - public double SensitivityCapY { - get - { - if (IsSensitivityGain) - { - return CapOption.Fields.Y; + return CapOption.Field.Data; } else { @@ -89,7 +71,7 @@ namespace grapher } else { - return CapOption.Fields.X; + return CapOption.Field.Data; } } } @@ -98,21 +80,31 @@ namespace grapher #region Methods - public void SetActiveValues(double gainCap, double sensCapX, double sensCapY, bool capGainEnabled) + public void Hide() + { + CapOption.Hide(); + } + + public void Show() + { + CapOption.Show(); + } + + public void SetActiveValues(double gainCap, double sensCap, bool capGainEnabled) { if (capGainEnabled) { - CapOption.ActiveValueLabels.X.FormatString = Constants.GainCapFormatString; - CapOption.ActiveValueLabels.X.Prefix = "Gain"; - CapOption.SetActiveValues(gainCap, gainCap); + CapOption.ActiveValueLabel.FormatString = Constants.GainCapFormatString; + CapOption.ActiveValueLabel.Prefix = "Gain"; + CapOption.SetActiveValue(gainCap); SensitivityCapCheck.Checked = true; VelocityGainCapCheck.Checked = false; } else { - CapOption.ActiveValueLabels.X.FormatString = Constants.DefaultActiveValueFormatString; - CapOption.ActiveValueLabels.X.Prefix = string.Empty; - CapOption.SetActiveValues(sensCapX, sensCapY); + CapOption.ActiveValueLabel.FormatString = Constants.DefaultActiveValueFormatString; + CapOption.ActiveValueLabel.Prefix = string.Empty; + CapOption.SetActiveValue(sensCap); SensitivityCapCheck.Checked = false; VelocityGainCapCheck.Checked = true; } @@ -155,18 +147,12 @@ namespace grapher void EnableSensitivityCap() { IsSensitivityGain = true; - CapOption.Fields.LockCheckBox.Enabled = true; - WeightOption.Fields.LockCheckBox.Enabled = true; CapOption.SetName("Sensitivity Cap"); } void EnableVelocityGainCap() { IsSensitivityGain = false; - CapOption.Fields.LockCheckBox.Checked = true; - CapOption.Fields.LockCheckBox.Enabled = false; - WeightOption.Fields.LockCheckBox.Checked = true; - WeightOption.Fields.LockCheckBox.Enabled = false; CapOption.SetName("Velocity Gain Cap"); } diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs index c5336a6..bd2c9a1 100644 --- a/grapher/Models/Options/Option.cs +++ b/grapher/Models/Options/Option.cs @@ -62,6 +62,47 @@ namespace grapher public ActiveValueLabel ActiveValueLabel { get; } + public int Top + { + get + { + return Field.Top; + } + set + { + Field.Top = value; + Label.Top = value; + } + } + + public int Height + { + get + { + return Field.Height; + } + } + + public int Left + { + get + { + return Label.Left; + } + set + { + Label.Left = value; + Field.Left = value + Label.Width + Constants.OptionLabelBoxSeperation; + } + } + public int Width + { + get + { + return Field.Left + Field.Width - Label.Left; + } + } + #endregion Properties #region Methods @@ -70,7 +111,7 @@ namespace grapher { Label.Text = name; //Label.Left = Convert.ToInt32((Field.Box.Left / 2.0) - (Label.Width / 2.0)); //Centered - Label.Left = Convert.ToInt32(Field.Box.Left - Label.Width - 10); //Right-aligned + Left = Label.Left; } public void SetActiveValue(double value) @@ -103,6 +144,11 @@ namespace grapher Show(); } + + public void SnapTo(Option option) + { + Top = option.Top + option.Height + Constants.OptionVerticalSeperation; + } #endregion Methods } |