diff options
| author | a1xd <[email protected]> | 2020-08-22 22:33:45 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-08-22 22:33:45 -0400 |
| commit | 252637e53ca42353061dc3118e8625af6edc348f (patch) | |
| tree | 26ea73edae996242eaef559485309fb9c66f4d30 /grapher/Models/Options/ActiveValueLabel.cs | |
| parent | Merge pull request #15 from JacobPalecki/GUI (diff) | |
| parent | delete personal settings.json left in repo (diff) | |
| download | rawaccel-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/ActiveValueLabel.cs')
| -rw-r--r-- | grapher/Models/Options/ActiveValueLabel.cs | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs new file mode 100644 index 0000000..138775a --- /dev/null +++ b/grapher/Models/Options/ActiveValueLabel.cs @@ -0,0 +1,107 @@ +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.Models.Options +{ + public class ActiveValueLabel + { + public const string DefaultFormatString = "0.######"; + public static readonly Color ActiveValueFontColor = Color.FromArgb(255, 65, 65, 65); + + private string _prefix; + private string _value; + + public ActiveValueLabel(Label valueLabel, Label centeringLabel) + { + ValueLabel = valueLabel; + ValueLabel.ForeColor = ActiveValueFontColor; + Left = centeringLabel.Left; + Width = centeringLabel.Width; + ValueLabel.AutoSize = false; + ValueLabel.TextAlign = ContentAlignment.MiddleCenter; + + FormatString = DefaultFormatString; + Prefix = string.Empty; + } + + public Label ValueLabel { get; } + + public string FormatString { get; set; } + + public string Prefix + { + get { return _prefix; } + set + { + _prefix = value; + RefreshText(); + } + } + + private string Value + { + get { return _value; } + set + { + _value = value; + RefreshText(); + } + } + + public int Left + { + get + { + return ValueLabel.Left; + } + + set + { + ValueLabel.Left = value; + } + } + + public int Width + { + get + { + return ValueLabel.Width; + } + + set + { + ValueLabel.Width = value; + } + } + + public void Hide() + { + ValueLabel.Hide(); + } + + public void Show() + { + ValueLabel.Show(); + } + + public void SetValue(double value) + { + SetValue(value.ToString(FormatString)); + } + + public void SetValue(string value) + { + Value = value; + } + + public void RefreshText() + { + ValueLabel.Text = string.IsNullOrWhiteSpace(Prefix) ? Value: $"{Prefix}: {Value}"; + } + } +} |