-
Notifications
You must be signed in to change notification settings - Fork 1
/
RadioButtons.cs
114 lines (96 loc) · 3.67 KB
/
RadioButtons.cs
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
using System.Collections.Generic;
using sapfewse;
namespace RoboSAPiens {
public abstract class RadioButton: IHighlightable {
protected bool focused;
public abstract bool isEnabled(GuiSession session);
public abstract void select(GuiSession session);
public abstract void toggleHighlight(GuiSession session);
}
public class SAPRadioButton: RadioButton, ILabeled, ILocatable, ISelectable {
string id;
Position position;
string text;
string tooltip;
string vLabel;
public SAPRadioButton(GuiRadioButton radioButton) {
this.id = radioButton.Id;
this.position = new Position(height: radioButton.Height,
left: radioButton.ScreenLeft,
top: radioButton.ScreenTop,
width: radioButton.Width);
this.text = radioButton.Text;
this.tooltip = radioButton.DefaultTooltip.Trim();
this.vLabel = getVLabel(radioButton);
}
public List<string> getLabels()
{
return new List<string>
{
tooltip
};
}
public string getVLabel(GuiRadioButton radioButton)
{
var leftLabel = radioButton.LeftLabel;
if (leftLabel != null && leftLabel.ScreenTop < radioButton.ScreenTop)
{
return leftLabel.Text;
}
return "";
}
public Position getPosition() {
return position;
}
public override bool isEnabled(GuiSession session)
{
var radioButton = (GuiRadioButton)session.FindById(id);
return radioButton.Changeable;
}
public bool isHorizontalAlignedWithLabel(SAPLabel? label) {
return label switch {
SAPLabel => label.position.horizontalAlignedWith(position),
_ => false
};
}
public bool isHorizontalAlignedWithTextField(SAPTextField? textField) {
return textField switch {
SAPTextField => textField.position.horizontalAlignedWith(position),
_ => false
};
}
public bool isHLabeled(string label) {
return text == label;
}
public bool isVLabeled(string label) {
return vLabel.Equals(label);
}
public bool hasTooltip(string tooltip) {
return this.tooltip == tooltip;
}
public bool isLocated(ILocator locator, LabelStore labels, TextFieldRepository textFieldLabels) {
return locator switch {
HLabelVLabel(var hLabel, var vLabel) =>
(isHorizontalAlignedWithLabel(labels.getByName(hLabel)) ||
isHorizontalAlignedWithTextField(textFieldLabels.getByContent(hLabel))) &&
isVerticalAlignedWithLabel(labels.getByName(vLabel)),
_ => false
};
}
public bool isVerticalAlignedWithLabel(SAPLabel? label) {
return label switch {
SAPLabel => label.position.verticalAlignedWith(position),
_ => false
};
}
public override void select(GuiSession session) {
var guiRadioButton = (GuiRadioButton)session.FindById(id);
guiRadioButton.Select();
}
public override void toggleHighlight(GuiSession session) {
focused = !focused;
var guiRadioButton = (GuiRadioButton)session.FindById(id);
guiRadioButton.Visualize(focused);
}
}
}