From fe17d04e571d180e663c7014e803ce790693f4b1 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 12:51:33 -0700 Subject: Display active values --- grapher/Models/Options/ActiveValueLabel.cs | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 grapher/Models/Options/ActiveValueLabel.cs (limited to 'grapher/Models/Options/ActiveValueLabel.cs') diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs new file mode 100644 index 0000000..ecafaba --- /dev/null +++ b/grapher/Models/Options/ActiveValueLabel.cs @@ -0,0 +1,46 @@ +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 ActiveValueLabel(Label valueLabel, Label centeringLabel) + { + ValueLabel = valueLabel; + ValueLabel.ForeColor = Color.DarkGray; + ValueLabel.Left = centeringLabel.Left; + ValueLabel.Width = centeringLabel.Width; + ValueLabel.AutoSize = false; + ValueLabel.TextAlign = ContentAlignment.MiddleCenter; + } + + public Label ValueLabel { get; } + + private int Left { get; } + + private int Width { get; } + + public void Hide() + { + ValueLabel.Hide(); + } + + public void Show() + { + ValueLabel.Show(); + } + + public void SetValue(double value) + { + ValueLabel.Text = value.ToString(DefaultFormatString); + } + } +} -- cgit v1.2.3 From 7dbeae9d4cf108e78072b356d832123f12e42a90 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 14:22:14 -0700 Subject: Add accel type to active values and tweak color --- grapher/Models/Options/ActiveValueLabel.cs | 73 +++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 6 deletions(-) (limited to 'grapher/Models/Options/ActiveValueLabel.cs') 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}"; } } } -- cgit v1.2.3