diff options
| author | Jacob Palecki <[email protected]> | 2020-08-20 14:22:14 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-08-20 14:22:14 -0700 |
| commit | 7dbeae9d4cf108e78072b356d832123f12e42a90 (patch) | |
| tree | 9711fddfb5241a3dc859cd421aa4937d38a8852f /grapher/Models/Options/ActiveValueLabel.cs | |
| parent | Display active values (diff) | |
| download | rawaccel-7dbeae9d4cf108e78072b356d832123f12e42a90.tar.xz rawaccel-7dbeae9d4cf108e78072b356d832123f12e42a90.zip | |
Add accel type to active values and tweak color
Diffstat (limited to 'grapher/Models/Options/ActiveValueLabel.cs')
| -rw-r--r-- | grapher/Models/Options/ActiveValueLabel.cs | 73 |
1 files changed, 67 insertions, 6 deletions
diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs index ecafaba..138775a 100644 --- a/grapher/Models/Options/ActiveValueLabel.cs +++ b/grapher/Models/Options/ActiveValueLabel.cs @@ -11,22 +11,73 @@ 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 = Color.DarkGray; - ValueLabel.Left = centeringLabel.Left; - ValueLabel.Width = centeringLabel.Width; + 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; } - private int Left { 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(); + } + } - private int Width { get; } + 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() { @@ -40,7 +91,17 @@ namespace grapher.Models.Options public void SetValue(double value) { - ValueLabel.Text = value.ToString(DefaultFormatString); + SetValue(value.ToString(FormatString)); + } + + public void SetValue(string value) + { + Value = value; + } + + public void RefreshText() + { + ValueLabel.Text = string.IsNullOrWhiteSpace(Prefix) ? Value: $"{Prefix}: {Value}"; } } } |