-
Notifications
You must be signed in to change notification settings - Fork 1
/
XRRoundLabel.cs
67 lines (60 loc) · 2.43 KB
/
XRRoundLabel.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
using DevExpress.Utils.Design;
using DevExpress.Utils.Serializing;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.Localization;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UserDesigner;
using System;
using System.ComponentModel;
namespace DevExpress.XtraReports.CustomControls.RoundBordersControls {
[ToolboxItem(true)]
[XRToolboxSubcategory(0, 1)]
[DefaultBindableProperty(nameof(Text))]
[ToolboxSvgImage("DevExpress.XtraReports.CustomControls.RoundedControls.Resources.XRLabel.svg,DevExpress.XtraReports.CustomControls.RoundedControls")]
public class XRRoundLabel : XRLabel {
int borderCornerRadius = 8;
[XtraSerializableProperty]
[DefaultValue(8)]
[SRCategory(ReportStringId.CatAppearance)]
public int BorderCornerRadius {
get {
return borderCornerRadius;
}
set {
float maxRadius = HeightF / 2 - BorderWidth;
if(value <= maxRadius || IsDeserializing) {
borderCornerRadius = value;
} else {
throw new Exception($"Value should be between 0-{(int)maxRadius}");
}
}
}
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
public override BorderSide Borders {
get { return BorderSide.All; }
set { base.Borders = value; }
}
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
public override BorderDashStyle BorderDashStyle {
get { return BorderDashStyle.Solid; }
set { }
}
public XRRoundLabel() {
BorderWidth = 2;
TextAlignment = TextAlignment.MiddleCenter;
Borders = BorderSide.All;
}
protected override VisualBrick CreateBrick(VisualBrick[] childrenBricks) {
return new RoundLabelBrick(this, null);
}
protected override void PutStateToBrick(VisualBrick brick, PrintingSystemBase ps) {
var roundedBrick = (RoundLabelBrick)brick;
roundedBrick.BorderCornerRadius = BorderCornerRadius;
base.PutStateToBrick(brick, ps);
}
}
}