blob: 553ce4800398ce426820cf6f7e73f2a3e46ed55b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace grapher.Models.Options
{
public class ActiveValueLabelXY
{
#region Constants
public const int ActiveLabelXYSeparation = 2;
public const string ShortenedFormatString = "0.###";
#endregion Constants
#region Constructors
public ActiveValueLabelXY(
ActiveValueLabel x,
ActiveValueLabel y)
{
X = x;
Y = y;
FullWidth = x.Width;
ShortenedWidth = (FullWidth - ActiveLabelXYSeparation) / 2;
Y.Left = X.Left + ShortenedWidth + ActiveLabelXYSeparation;
Y.Width = ShortenedWidth;
Y.FormatString = ShortenedFormatString;
Combined = false;
SetCombined();
}
#endregion Constructors
#region Properties
public ActiveValueLabel X { get; }
public ActiveValueLabel Y { get; }
public bool Combined { get; private set; }
private int FullWidth { get; }
private int ShortenedWidth { get; }
#endregion Properties
#region Methods
public void SetValues(double x, double y)
{
X.SetValue(x);
Y.SetValue(y);
if (x == y)
{
SetCombined();
}
else
{
SetSeparate();
}
}
public void SetCombined()
{
if (!Combined)
{
X.FormatString = ActiveValueLabel.DefaultFormatString;
X.Width = FullWidth;
X.Prefix = string.Empty;
Y.Hide();
}
Combined = true;
}
public void SetSeparate()
{
if (Combined)
{
X.FormatString = ShortenedFormatString;
X.Width = ShortenedWidth;
X.Prefix = "X";
Y.Prefix = "Y";
Y.Show();
}
Combined = false;
}
#region Methods
}
}
|