From 246fb772c5bf7dd6a85143fadebece3b4d9f1e04 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 1 Sep 2020 02:18:41 -0700 Subject: Add constants class and separate classes into regions --- grapher/Models/Options/ActiveValueLabelXY.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'grapher/Models/Options/ActiveValueLabelXY.cs') diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index 12506e9..553ce48 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -8,9 +8,15 @@ namespace grapher.Models.Options { public class ActiveValueLabelXY { + #region Constants + public const int ActiveLabelXYSeparation = 2; public const string ShortenedFormatString = "0.###"; + #endregion Constants + + #region Constructors + public ActiveValueLabelXY( ActiveValueLabel x, ActiveValueLabel y) @@ -29,6 +35,10 @@ namespace grapher.Models.Options SetCombined(); } + #endregion Constructors + + #region Properties + public ActiveValueLabel X { get; } public ActiveValueLabel Y { get; } @@ -39,6 +49,10 @@ namespace grapher.Models.Options private int ShortenedWidth { get; } + #endregion Properties + + #region Methods + public void SetValues(double x, double y) { X.SetValue(x); @@ -80,5 +94,7 @@ namespace grapher.Models.Options Combined = false; } + + #region Methods } } -- cgit v1.2.3 From 4aa2f3ed741dcbd39233e125a34cac8163267d8d Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 1 Sep 2020 02:39:09 -0700 Subject: Move constants to central class --- grapher/Models/Options/ActiveValueLabelXY.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'grapher/Models/Options/ActiveValueLabelXY.cs') 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 } } -- cgit v1.2.3 From f2322540dd904474587ddebfa8d96dc66a902530 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 8 Sep 2020 00:51:05 -0700 Subject: Alignment for whole mode works --- grapher/Models/Options/ActiveValueLabelXY.cs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'grapher/Models/Options/ActiveValueLabelXY.cs') diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index c8caddf..3f94847 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -43,9 +43,9 @@ namespace grapher.Models.Options public bool Combined { get; private set; } - private int FullWidth { get; } + private int FullWidth { get; set; } - private int ShortenedWidth { get; } + private int ShortenedWidth { get; set; } #endregion Properties @@ -93,6 +93,29 @@ namespace grapher.Models.Options Combined = false; } + public void AlignActiveValues(int width) + { + Align(width); + + if (Combined) + { + X.Width = FullWidth; + } + else + { + X.Width = ShortenedWidth; + } + } + + private void Align (int width) + { + FullWidth = width; + ShortenedWidth = (FullWidth - Constants.ActiveLabelXYSeparation) / 2; + + Y.Left = X.Left + ShortenedWidth + Constants.ActiveLabelXYSeparation; + Y.Width = ShortenedWidth; + } + #endregion Methods } } -- cgit v1.2.3 From 254a66eda9d9f6add21937b3570d29f64af4ab1e Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 8 Sep 2020 01:09:19 -0700 Subject: Fix few small bugs --- grapher/Models/Options/ActiveValueLabelXY.cs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'grapher/Models/Options/ActiveValueLabelXY.cs') diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index 3f94847..e6e4f52 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -22,10 +22,7 @@ namespace grapher.Models.Options X = x; Y = y; - FullWidth = x.Width; - ShortenedWidth = (FullWidth - Constants.ActiveLabelXYSeparation) / 2; - - Y.Left = X.Left + ShortenedWidth + Constants.ActiveLabelXYSeparation; + Align(x.Width); Y.Width = ShortenedWidth; Y.FormatString = Constants.ShortenedFormatString; @@ -43,6 +40,19 @@ namespace grapher.Models.Options public bool Combined { get; private set; } + public int Left + { + get + { + return X.Left; + } + set + { + X.Left = value; + SetYLeft(); + } + } + private int FullWidth { get; set; } private int ShortenedWidth { get; set; } @@ -112,10 +122,15 @@ namespace grapher.Models.Options FullWidth = width; ShortenedWidth = (FullWidth - Constants.ActiveLabelXYSeparation) / 2; - Y.Left = X.Left + ShortenedWidth + Constants.ActiveLabelXYSeparation; + SetYLeft(); Y.Width = ShortenedWidth; } + private void SetYLeft() + { + Y.Left = X.Left + ShortenedWidth + Constants.ActiveLabelXYSeparation; + } + #endregion Methods } } -- cgit v1.2.3 From 9502dcf7608475857b1487375997d20a9d29622e Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 8 Sep 2020 01:26:22 -0700 Subject: Remove and sort usings en masse --- grapher/Models/Options/ActiveValueLabelXY.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'grapher/Models/Options/ActiveValueLabelXY.cs') diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index e6e4f52..ffe57b7 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -1,10 +1,4 @@ -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 { -- cgit v1.2.3 From a6448c4a2447a090558da5f52dea3dc418389e8a Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 8 Sep 2020 12:35:23 -0700 Subject: Fix few small bugs --- grapher/Models/Options/ActiveValueLabelXY.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'grapher/Models/Options/ActiveValueLabelXY.cs') diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index ffe57b7..9498c66 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -47,6 +47,19 @@ } } + public int Height + { + get + { + return X.Height; + } + set + { + X.Height = value; + Y.Height = value; + } + } + private int FullWidth { get; set; } private int ShortenedWidth { get; set; } @@ -97,9 +110,9 @@ Combined = false; } - public void AlignActiveValues(int width) + public void AlignActiveValues() { - Align(width); + Align(X.CenteringLabel.Width); if (Combined) { -- cgit v1.2.3