diff options
| author | a1xd <[email protected]> | 2020-07-31 17:56:46 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-07-31 17:56:46 -0400 |
| commit | 1fcbb0fa51dbc35958d211026e4d40384a049049 (patch) | |
| tree | efb65bf3f305f376ea75f4f687b08bf8998c020f /grapher/FieldXY.cs | |
| parent | Merge pull request #6 from a1xd/st-refactor (diff) | |
| parent | Show no settings for off, remove unused class for PR (diff) | |
| download | rawaccel-1fcbb0fa51dbc35958d211026e4d40384a049049.tar.xz rawaccel-1fcbb0fa51dbc35958d211026e4d40384a049049.zip | |
Merge pull request #7 from JacobPalecki/GUI
Add GUI
Diffstat (limited to 'grapher/FieldXY.cs')
| -rw-r--r-- | grapher/FieldXY.cs | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/grapher/FieldXY.cs b/grapher/FieldXY.cs new file mode 100644 index 0000000..23c5de1 --- /dev/null +++ b/grapher/FieldXY.cs @@ -0,0 +1,79 @@ +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 FieldXY(TextBox xBox, TextBox yBox, CheckBox lockCheckBox, Form containingForm, double defaultData) + { + XField = new Field(xBox, containingForm, defaultData); + YField = new Field(yBox, containingForm, defaultData); + LockCheckBox = lockCheckBox; + LockCheckBox.CheckedChanged += new System.EventHandler(CheckChanged); + SetLocked(); + } + public double X + { + get => XField.Data; + } + + public double Y + { + get + { + if (Locked) + { + return X; + } + else + { + return YField.Data; + } + } + } + + public CheckBox LockCheckBox { get; } + + public Field XField { get; } + + public Field YField { get; } + + private bool Locked { get; set; } + + private void CheckChanged(object sender, EventArgs e) + { + if (LockCheckBox.CheckState == CheckState.Checked) + { + SetLocked(); + } + else + { + SetUnlocked(); + } + } + + private void SetLocked() + { + Locked = true; + YField.SetToUnavailable(); + } + + private void SetUnlocked() + { + Locked = false; + if (XField.State == Field.FieldState.Default) + { + YField.SetToDefault(); + } + else + { + YField.SetToEntered(XField.Data); + } + } + } +} |