summaryrefslogtreecommitdiff
path: root/grapher/Models/Options/ActiveValueLabelXY.cs
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-08-22 22:33:45 -0400
committerGitHub <[email protected]>2020-08-22 22:33:45 -0400
commit252637e53ca42353061dc3118e8625af6edc348f (patch)
tree26ea73edae996242eaef559485309fb9c66f4d30 /grapher/Models/Options/ActiveValueLabelXY.cs
parentMerge pull request #15 from JacobPalecki/GUI (diff)
parentdelete personal settings.json left in repo (diff)
downloadrawaccel-252637e53ca42353061dc3118e8625af6edc348f.tar.xz
rawaccel-252637e53ca42353061dc3118e8625af6edc348f.zip
Merge pull request #16 from JacobPalecki/Misc
Gain Styles, Settings File, and other miscellaneous
Diffstat (limited to 'grapher/Models/Options/ActiveValueLabelXY.cs')
-rw-r--r--grapher/Models/Options/ActiveValueLabelXY.cs84
1 files changed, 84 insertions, 0 deletions
diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs
new file mode 100644
index 0000000..12506e9
--- /dev/null
+++ b/grapher/Models/Options/ActiveValueLabelXY.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Models.Options
+{
+ public class ActiveValueLabelXY
+ {
+ public const int ActiveLabelXYSeparation = 2;
+ public const string ShortenedFormatString = "0.###";
+
+ public ActiveValueLabelXY(
+ ActiveValueLabel x,
+ ActiveValueLabel y)
+ {
+ X = x;
+ Y = y;
+
+ FullWidth = x.Width;
+ ShortenedWidth = (FullWidth - ActiveLabelXYSeparation) / 2;
+
+ Y.Left = X.Left + ShortenedWidth + ActiveLabelXYSeparation;
+ Y.Width = ShortenedWidth;
+ Y.FormatString = ShortenedFormatString;
+
+ Combined = false;
+ SetCombined();
+ }
+
+ public ActiveValueLabel X { get; }
+
+ public ActiveValueLabel Y { get; }
+
+ public bool Combined { get; private set; }
+
+ private int FullWidth { get; }
+
+ private int ShortenedWidth { get; }
+
+ public void SetValues(double x, double y)
+ {
+ X.SetValue(x);
+ Y.SetValue(y);
+
+ if (x == y)
+ {
+ SetCombined();
+ }
+ else
+ {
+ SetSeparate();
+ }
+ }
+
+ public void SetCombined()
+ {
+ if (!Combined)
+ {
+ X.FormatString = ActiveValueLabel.DefaultFormatString;
+ X.Width = FullWidth;
+ X.Prefix = string.Empty;
+ Y.Hide();
+ }
+
+ Combined = true;
+ }
+
+ public void SetSeparate()
+ {
+ if (Combined)
+ {
+ X.FormatString = ShortenedFormatString;
+ X.Width = ShortenedWidth;
+ X.Prefix = "X";
+ Y.Prefix = "Y";
+ Y.Show();
+ }
+
+ Combined = false;
+ }
+ }
+}