diff options
| author | JacobPalecki <[email protected]> | 2020-09-08 16:00:05 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-08 16:00:05 -0700 |
| commit | e5461fa84e65d78823d0022339fa2d8864f7e63c (patch) | |
| tree | b486ef524c93bfeb29a86403114b6805bf9decf1 /grapher/Models/Options/ActiveValueLabelXY.cs | |
| parent | Merge pull request #19 from JacobPalecki/gainOffset (diff) | |
| parent | Save show last mouse value (diff) | |
| download | rawaccel-e5461fa84e65d78823d0022339fa2d8864f7e63c.tar.xz rawaccel-e5461fa84e65d78823d0022339fa2d8864f7e63c.zip | |
Merge pull request #20 from JacobPalecki/GUI
GUI: Add By Component & Anisotropy; Remove Logarithm and Sigmoid; Delete Console; Some Refactoring
Diffstat (limited to 'grapher/Models/Options/ActiveValueLabelXY.cs')
| -rw-r--r-- | grapher/Models/Options/ActiveValueLabelXY.cs | 95 |
1 files changed, 77 insertions, 18 deletions
diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index 12506e9..9498c66 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -1,15 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace grapher.Models.Options +namespace grapher.Models.Options { public class ActiveValueLabelXY { - public const int ActiveLabelXYSeparation = 2; - public const string ShortenedFormatString = "0.###"; + #region Constants + + + #endregion Constants + + #region Constructors public ActiveValueLabelXY( ActiveValueLabel x, @@ -18,26 +16,57 @@ namespace grapher.Models.Options X = x; Y = y; - FullWidth = x.Width; - ShortenedWidth = (FullWidth - ActiveLabelXYSeparation) / 2; - - Y.Left = X.Left + ShortenedWidth + ActiveLabelXYSeparation; + Align(x.Width); Y.Width = ShortenedWidth; - Y.FormatString = ShortenedFormatString; + Y.FormatString = Constants.ShortenedFormatString; Combined = false; SetCombined(); } + #endregion Constructors + + #region Properties + public ActiveValueLabel X { get; } public ActiveValueLabel Y { get; } public bool Combined { get; private set; } - private int FullWidth { get; } + public int Left + { + get + { + return X.Left; + } + set + { + X.Left = value; + SetYLeft(); + } + } + + public int Height + { + get + { + return X.Height; + } + set + { + X.Height = value; + Y.Height = value; + } + } + + private int FullWidth { get; set; } + + private int ShortenedWidth { get; set; } - private int ShortenedWidth { get; } + #endregion Properties + + #region Methods public void SetValues(double x, double y) { @@ -58,7 +87,7 @@ namespace grapher.Models.Options { if (!Combined) { - X.FormatString = ActiveValueLabel.DefaultFormatString; + X.FormatString = Constants.DefaultActiveValueFormatString; X.Width = FullWidth; X.Prefix = string.Empty; Y.Hide(); @@ -71,7 +100,7 @@ namespace grapher.Models.Options { if (Combined) { - X.FormatString = ShortenedFormatString; + X.FormatString = Constants.ShortenedFormatString; X.Width = ShortenedWidth; X.Prefix = "X"; Y.Prefix = "Y"; @@ -80,5 +109,35 @@ namespace grapher.Models.Options Combined = false; } + + public void AlignActiveValues() + { + Align(X.CenteringLabel.Width); + + if (Combined) + { + X.Width = FullWidth; + } + else + { + X.Width = ShortenedWidth; + } + } + + private void Align (int width) + { + FullWidth = width; + ShortenedWidth = (FullWidth - Constants.ActiveLabelXYSeparation) / 2; + + SetYLeft(); + Y.Width = ShortenedWidth; + } + + private void SetYLeft() + { + Y.Left = X.Left + ShortenedWidth + Constants.ActiveLabelXYSeparation; + } + + #endregion Methods } } |