diff options
| author | Jacob Palecki <[email protected]> | 2020-09-07 15:19:39 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-07 15:19:39 -0700 |
| commit | aff3a066575f4bfa429f67a5104a1fcffc5f326e (patch) | |
| tree | 975c8cf984e97d818ebf530b68a246f4a4b1aefb /grapher/Models/Fields/Field.cs | |
| parent | Pass args by ref for setting (diff) | |
| download | rawaccel-aff3a066575f4bfa429f67a5104a1fcffc5f326e.tar.xz rawaccel-aff3a066575f4bfa429f67a5104a1fcffc5f326e.zip | |
Refactor type options
Diffstat (limited to 'grapher/Models/Fields/Field.cs')
| -rw-r--r-- | grapher/Models/Fields/Field.cs | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/grapher/Models/Fields/Field.cs b/grapher/Models/Fields/Field.cs index 6f38314..f8a9c2d 100644 --- a/grapher/Models/Fields/Field.cs +++ b/grapher/Models/Fields/Field.cs @@ -23,13 +23,19 @@ namespace grapher #endregion Enumerations + #region Fields + + private double _data; + + #endregion Fields + #region Constructors public Field(TextBox box, Form containingForm, double defaultData) { DefaultText = DecimalString(defaultData); Box = box; - Data = defaultData; + _data = defaultData; DefaultData = defaultData; State = FieldState.Undefined; ContainingForm = containingForm; @@ -48,8 +54,6 @@ namespace grapher private Form ContainingForm { get; } - public double Data { get; private set; } - public string FormatString { get; set; } public string DefaultText { get; } @@ -58,6 +62,20 @@ namespace grapher public FieldState PreviousState { get; private set; } + public double Data { + get + { + if (Box.Visible) + { + return _data; + } + else + { + return DefaultData; + } + } + } + public int Top { get @@ -122,7 +140,7 @@ namespace grapher PreviousState = FieldState.Default; } - Data = DefaultData; + _data = DefaultData; Box.Text = DefaultText; ContainingForm.ActiveControl = null; } @@ -159,7 +177,7 @@ namespace grapher { SetToEntered(); - Data = value; + _data = value; Box.Text = DecimalString(Data); } @@ -238,7 +256,7 @@ namespace grapher { try { - Data = Convert.ToDouble(Box.Text); + _data = Convert.ToDouble(Box.Text); } catch { |