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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
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.Directionality
{
public class DirectionalityOptions
{
public DirectionalityOptions(
Panel containingPanel,
Label directionalityLabel,
Label directionalityX,
Label directionalityY,
Label directionalityActiveValueTitle,
Option lpNorm,
OptionXY domain,
OptionXY range,
CheckBox wholeCheckBox,
CheckBox byComponentCheckBox,
int top)
{
ContainingPanel = containingPanel;
DirectionalityLabel = directionalityLabel;
DirectionalityX = directionalityX;
DirectionalityY = directionalityY;
DirectionalityActiveValueTitle = directionalityActiveValueTitle;
LpNorm = lpNorm;
Domain = domain;
Range = range;
WholeCheckBox = wholeCheckBox;
ByComponentCheckBox = byComponentCheckBox;
ContainingPanel.Paint += Panel_Paint;
DirectionalityLabel.Click += Title_click;
ContainingPanel.Top = top;
DirectionalityLabel.Left = Constants.DirectionalityTitlePad;
DirectionalityLabel.Top = Constants.DirectionalityTitlePad;
IsHidden = false;
ToWhole();
Hide();
}
public Panel ContainingPanel { get; }
public Label DirectionalityLabel { get; }
public Label DirectionalityX { get; }
public Label DirectionalityY { get; }
public Label DirectionalityActiveValueTitle { get; }
public Option LpNorm { get; }
public OptionXY Domain { get; }
public OptionXY Range { get; }
public CheckBox WholeCheckBox { get; }
public CheckBox ByComponentCheckBox { get; }
public int OpenHeight { get => WholeCheckBox.Bottom - DirectionalityLabel.Top + 2 * Constants.DirectionalityTitlePad; }
public int ClosedHeight { get => DirectionalityLabel.Height + 2 * Constants.DirectionalityTitlePad; }
private bool IsHidden { get; set; }
public Tuple<Vec2<double>, double> GetDomainArgs()
{
var weights = new Vec2<double>
{
x = Domain.Fields.X,
y = Domain.Fields.Y
};
double p = ByComponentCheckBox.Checked ? 2 : LpNorm.Field.Data;
return new Tuple<Vec2<double>, double>(weights, p);
}
public Vec2<double> GetRangeXY()
{
return new Vec2<double>
{
x = Range.Fields.X,
y = Range.Fields.Y,
};
}
public void SetActiveValues(Profile settings)
{
Domain.SetActiveValues(settings.domainXY.x, settings.domainXY.y);
Range.SetActiveValues(settings.rangeXY.x, settings.rangeXY.y);
if (settings.combineMagnitudes)
{
LpNorm.SetActiveValue(settings.lpNorm);
}
else
{
LpNorm.SetToUnavailable();
}
}
public void Hide()
{
if (!IsHidden)
{
DirectionalityX.Hide();
DirectionalityY.Hide();
DirectionalityActiveValueTitle.Hide();
LpNorm.Hide();
Domain.Hide();
Range.Hide();
WholeCheckBox.Hide();
ByComponentCheckBox.Hide();
DirectionalityLabel.Text = Constants.DirectionalityTitleClosed;
DrawHidden();
IsHidden = true;
}
}
public void Show()
{
if (IsHidden)
{
DirectionalityX.Show();
DirectionalityY.Show();
DirectionalityActiveValueTitle.Show();
LpNorm.Show();
Domain.Show();
Range.Show();
Range.Fields.LockCheckBox.Hide();
WholeCheckBox.Show();
ByComponentCheckBox.Show();
DirectionalityLabel.Text = Constants.DirectionalityTitleOpen;
DrawShown();
IsHidden = false;
}
}
public void ToByComponent()
{
LpNorm.SetToUnavailable();
}
public void ToWhole()
{
LpNorm.SetToAvailable();
}
private void DrawHidden()
{
ContainingPanel.Height = ClosedHeight;
ContainingPanel.Invalidate();
}
private void DrawShown()
{
ContainingPanel.Height = OpenHeight;
ContainingPanel.Invalidate();
}
private void Panel_Paint(object sender, PaintEventArgs e)
{
Color col = Color.DarkGray;
ButtonBorderStyle bbs = ButtonBorderStyle.Dashed;
int thickness = 2;
ControlPaint.DrawBorder(e.Graphics, this.ContainingPanel.ClientRectangle, col, thickness, bbs, col, thickness, bbs, col, thickness, bbs, col, thickness, bbs);
}
private void Title_click(object sender, EventArgs e)
{
if (IsHidden)
{
Show();
}
else
{
Hide();
}
}
}
}
|