diff options
Diffstat (limited to 'grapher/Models/Fields')
| -rw-r--r-- | grapher/Models/Fields/Field.cs | 93 | ||||
| -rw-r--r-- | grapher/Models/Fields/FieldXY.cs | 88 |
2 files changed, 144 insertions, 37 deletions
diff --git a/grapher/Models/Fields/Field.cs b/grapher/Models/Fields/Field.cs index 1810081..0d1813e 100644 --- a/grapher/Models/Fields/Field.cs +++ b/grapher/Models/Fields/Field.cs @@ -1,22 +1,12 @@ using System; -using System.Collections.Generic; using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace grapher { public class Field { - #region Constants - - public const string DefaultFormatString = "0.#########"; - - #endregion Constants - - #region Enums + #region Enumerations public enum FieldState { @@ -27,8 +17,13 @@ namespace grapher Unavailable, } - #endregion Enums + #endregion Enumerations + + #region Fields + + private double _data; + #endregion Fields #region Constructors @@ -36,11 +31,11 @@ namespace grapher { DefaultText = DecimalString(defaultData); Box = box; - Data = defaultData; + _data = defaultData; DefaultData = defaultData; State = FieldState.Undefined; ContainingForm = containingForm; - FormatString = DefaultFormatString; + FormatString = Constants.DefaultFieldFormatString; box.KeyDown += new System.Windows.Forms.KeyEventHandler(KeyDown); box.Leave += new System.EventHandler(FocusLeave); @@ -55,8 +50,6 @@ namespace grapher private Form ContainingForm { get; } - public double Data { get; private set; } - public string FormatString { get; set; } public string DefaultText { get; } @@ -65,6 +58,68 @@ namespace grapher public FieldState PreviousState { get; private set; } + public double Data { + get + { + if (Box.Visible) + { + return _data; + } + else + { + return DefaultData; + } + } + } + + 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 @@ -81,7 +136,7 @@ namespace grapher PreviousState = FieldState.Default; } - Data = DefaultData; + _data = DefaultData; Box.Text = DefaultText; ContainingForm.ActiveControl = null; } @@ -118,7 +173,7 @@ namespace grapher { SetToEntered(); - Data = value; + _data = value; Box.Text = DecimalString(Data); } @@ -197,7 +252,7 @@ namespace grapher { try { - Data = Convert.ToDouble(Box.Text); + _data = Convert.ToDouble(Box.Text); } catch { diff --git a/grapher/Models/Fields/FieldXY.cs b/grapher/Models/Fields/FieldXY.cs index 609af9d..15e6800 100644 --- a/grapher/Models/Fields/FieldXY.cs +++ b/grapher/Models/Fields/FieldXY.cs @@ -1,38 +1,36 @@ 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; + #region Constructors - public const string ShortenedFormatString = "0.###"; - - public FieldXY(TextBox xBox, TextBox yBox, CheckBox lockCheckBox, Form containingForm, double defaultData, AccelCharts accelCharts) + 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; + YField.FormatString = Constants.ShortenedFormatString; LockCheckBox = lockCheckBox; LockCheckBox.CheckedChanged += new System.EventHandler(CheckChanged); - AccelCharts = accelCharts; - XField.Box.Width = (YField.Box.Left + YField.Box.Width - XField.Box.Left - DefaultSeparation) / 2; + XField.Box.Width = (YField.Box.Left + YField.Box.Width - XField.Box.Left - Constants.DefaultFieldSeparation) / 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; + YField.Box.Left = XField.Box.Left + XField.Box.Width + Constants.DefaultFieldSeparation; CombinedWidth = DefaultWidthX + DefaultWidthY + YField.Box.Left - (XField.Box.Left + DefaultWidthX); SetCombined(); } + + #endregion Constructors + + #region Properties + public double X { get => XField.Data; @@ -59,7 +57,58 @@ namespace grapher public Field YField { get; } - private AccelCharts AccelCharts { get; } + public int CombinedWidth { get; } + + public int Left { + get + { + return XField.Left; + } + set + { + } + } + + public int Width + { + get + { + return CombinedWidth; + } + set + { + } + } + + public int Top + { + get + { + return XField.Top; + } + set + { + } + } + + public int Height + { + get + { + return XField.Height; + } + set + { + } + } + + public bool Visible + { + get + { + return XField.Box.Visible; + } + } private bool Combined { get; set; } @@ -67,7 +116,10 @@ namespace grapher private int DefaultWidthY { get; } - private int CombinedWidth { get; } + + #endregion Properties + + #region Methods private void CheckChanged(object sender, EventArgs e) { @@ -79,8 +131,6 @@ namespace grapher { SetSeparate(); } - - AccelCharts.RefreshXY(); } public void SetCombined() @@ -89,7 +139,7 @@ namespace grapher YField.SetToUnavailable(); YField.Box.Hide(); XField.Box.Width = CombinedWidth; - XField.FormatString = Field.DefaultFormatString; + XField.FormatString = Constants.DefaultFieldFormatString; } public void SetSeparate() @@ -99,7 +149,7 @@ namespace grapher XField.Box.Width = DefaultWidthX; YField.Box.Width = DefaultWidthY; - XField.FormatString = ShortenedFormatString; + XField.FormatString = Constants.ShortenedFormatString; if (XField.State == Field.FieldState.Default) { @@ -131,5 +181,7 @@ namespace grapher XField.Box.Hide(); YField.Box.Hide(); } + + #endregion Methods } } |