From fea8e8c559416d7fbf60168dc6d21f2c297f431f Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 12 Aug 2020 18:05:19 -0700 Subject: Nicer decimals, enter press not needed to enter values --- grapher/FieldXY.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'grapher/FieldXY.cs') diff --git a/grapher/FieldXY.cs b/grapher/FieldXY.cs index 7338962..87bda18 100644 --- a/grapher/FieldXY.cs +++ b/grapher/FieldXY.cs @@ -9,14 +9,26 @@ namespace grapher { public class FieldXY { + public const int DefaultSeparation = 6; + + public const string ShortenedFormatString = "#.###"; + 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; LockCheckBox = lockCheckBox; LockCheckBox.CheckedChanged += new System.EventHandler(CheckChanged); + + XField.Box.Width = (YField.Box.Left + YField.Box.Width - XField.Box.Left - DefaultSeparation) / 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; + CombinedWidth = DefaultWidthX + DefaultWidthY + YField.Box.Left - (XField.Box.Left + DefaultWidthX); SetCombined(); } @@ -72,6 +84,7 @@ namespace grapher YField.SetToUnavailable(); YField.Box.Hide(); XField.Box.Width = CombinedWidth; + XField.FormatString = Field.DefaultFormatString; } public void SetSeparate() @@ -81,6 +94,8 @@ namespace grapher XField.Box.Width = DefaultWidthX; YField.Box.Width = DefaultWidthY; + XField.FormatString = ShortenedFormatString; + if (XField.State == Field.FieldState.Default) { YField.SetToDefault(); -- cgit v1.2.3 From ae18a1a06060ef66d317af521032ac22fcd88eb3 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 12 Aug 2020 18:18:34 -0700 Subject: Fixed some edge cases around not using enter --- grapher/FieldXY.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'grapher/FieldXY.cs') diff --git a/grapher/FieldXY.cs b/grapher/FieldXY.cs index 87bda18..87e0b9c 100644 --- a/grapher/FieldXY.cs +++ b/grapher/FieldXY.cs @@ -9,9 +9,9 @@ namespace grapher { public class FieldXY { - public const int DefaultSeparation = 6; + public const int DefaultSeparation = 4; - public const string ShortenedFormatString = "#.###"; + public const string ShortenedFormatString = "0.###"; public FieldXY(TextBox xBox, TextBox yBox, CheckBox lockCheckBox, Form containingForm, double defaultData) { -- cgit v1.2.3 From cc531c79f2bd664551071ef315a54814bd9ab914 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 12 Aug 2020 19:22:21 -0700 Subject: Reorganized solution into directories --- grapher/FieldXY.cs | 130 ----------------------------------------------------- 1 file changed, 130 deletions(-) delete mode 100644 grapher/FieldXY.cs (limited to 'grapher/FieldXY.cs') diff --git a/grapher/FieldXY.cs b/grapher/FieldXY.cs deleted file mode 100644 index 87e0b9c..0000000 --- a/grapher/FieldXY.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace grapher -{ - public class FieldXY - { - public const int DefaultSeparation = 4; - - public const string ShortenedFormatString = "0.###"; - - 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; - LockCheckBox = lockCheckBox; - LockCheckBox.CheckedChanged += new System.EventHandler(CheckChanged); - - XField.Box.Width = (YField.Box.Left + YField.Box.Width - XField.Box.Left - DefaultSeparation) / 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; - - CombinedWidth = DefaultWidthX + DefaultWidthY + YField.Box.Left - (XField.Box.Left + DefaultWidthX); - SetCombined(); - } - public double X - { - get => XField.Data; - } - - public double Y - { - get - { - if (Combined) - { - return X; - } - else - { - return YField.Data; - } - } - } - - public CheckBox LockCheckBox { get; } - - public Field XField { get; } - - public Field YField { get; } - - private bool Combined { get; set; } - - private int DefaultWidthX { get; } - - private int DefaultWidthY { get; } - - private int CombinedWidth { get; } - - private void CheckChanged(object sender, EventArgs e) - { - if (LockCheckBox.CheckState == CheckState.Checked) - { - SetCombined(); - } - else - { - SetSeparate(); - } - } - - public void SetCombined() - { - Combined = true; - YField.SetToUnavailable(); - YField.Box.Hide(); - XField.Box.Width = CombinedWidth; - XField.FormatString = Field.DefaultFormatString; - } - - public void SetSeparate() - { - Combined = false; - - XField.Box.Width = DefaultWidthX; - YField.Box.Width = DefaultWidthY; - - XField.FormatString = ShortenedFormatString; - - if (XField.State == Field.FieldState.Default) - { - YField.SetToDefault(); - } - else - { - YField.SetToEntered(XField.Data); - } - - if (XField.Box.Visible) - { - YField.Box.Show(); - } - } - - public void Show() - { - XField.Box.Show(); - - if (!Combined) - { - YField.Box.Show(); - } - } - - public void Hide() - { - XField.Box.Hide(); - YField.Box.Hide(); - } - } -} -- cgit v1.2.3