This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
Form1.cs
179 lines (151 loc) · 7.39 KB
/
Form1.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
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraGauges.Core.Model;
using DevExpress.XtraGauges.Core.Drawing;
using System.Drawing.Drawing2D;
using DevExpress.XtraGauges.Core.Base;
using DevExpress.XtraEditors;
namespace Q269849 {
public partial class Form1 :XtraForm {
public Form1() {
InitializeComponent();
CreatePathNeedle(arcScaleNeedleComponent1);
}
private void CreatePathNeedle(INeedle needle) {
ComplexShape needleShape = (ComplexShape)needle.Shape;
needleShape.Collection.Clear();
PathShape shape = new PathShape();
shape.Points = new ShapePoint[] {
new ShapePoint(new PointF(0, 20), PathPointType.Start),
new ShapePoint(new PointF(50, 0), PathPointType.Line),
new ShapePoint(new PointF(0, -20), PathPointType.Line),
new ShapePoint(new PointF(100, 0), PathPointType.Line),
new ShapePoint(new PointF(0, 20), PathPointType.CloseSubpath | PathPointType.Line)
};
SolidBrushObject brush = new SolidBrushObject(Color.Red);
shape.Appearance.ContentBrush = brush;
shape.Name = "pathNeedle";
needleShape.Add(shape);
}
private void CreatePolygonNeedle(INeedle needle) {
ComplexShape needleShape = (ComplexShape)needle.Shape;
needleShape.Collection.Clear();
PolygonShape shape = new PolygonShape();
shape.Points = new PointF[] {
new PointF(0, 10),
new PointF(75, 10),
new PointF(70, -5),
new PointF(100, 0),
new PointF(65, -10),
new PointF(70, 5),
new PointF(0, -10)
};
shape.Appearance.ContentBrush = new SolidBrushObject(Color.AliceBlue);
shape.Name = "polygonNeedle";
needleShape.Add(shape);
}
private void CreatePolylineNeedle(INeedle needle) {
ComplexShape needleShape = (ComplexShape)needle.Shape;
needleShape.Collection.Clear();
PolylineShape shape = new PolylineShape();
shape.Points = new PointF[] {
new PointF(0, 20), new PointF(-40, 25),
new PointF(20, 5), new PointF(100, 0),
new PointF(20, -5), new PointF(-40, -25),
new PointF(0, -20)
};
shape.Appearance.ContentBrush = new SolidBrushObject(Color.Yellow);
shape.Name = "polylineNeedle";
needleShape.Add(shape);
}
private void CreateBoxNeedle(INeedle needle) {
ComplexShape needleShape = (ComplexShape)needle.Shape;
needleShape.Collection.Clear();
BoxShape shape = new BoxShape(new RectangleF2D(new PointF(-10, 0), new SizeF(100, 10)));
shape.Appearance.ContentBrush = new SolidBrushObject(Color.Gray);
shape.Name = "boxNeedle";
needleShape.Add(shape);
}
private void CreateEllipseNeedle(INeedle needle) {
ComplexShape needleShape = (ComplexShape)needle.Shape;
needleShape.Collection.Clear();
EllipseShape shape = new EllipseShape(new RectangleF2D(new PointF(-10, 0), new SizeF(100, 10)));
LinearGradientBrushObject brush = new LinearGradientBrushObject(new PointF2D(2, 0), new PointF2D(0, 2));
brush.StartColor = Color.Yellow;
brush.EndColor = Color.Magenta;
shape.Appearance.ContentBrush = brush;
shape.Name = "ellipseNeedle";
needleShape.Add(shape);
}
private void CreateArcNeedle(INeedle needle) {
ComplexShape needleShape = (ComplexShape)needle.Shape;
needleShape.Collection.Clear();
ArcShape shape = new ArcShape(new RectangleF2D(new PointF(-10, 0), new SizeF(20, 10)), 180, -60);
shape.Appearance.ContentBrush = new SolidBrushObject(Color.White);
shape.Name = "arcNeedle";
needleShape.Add(shape);
}
private void CreatePieShape(INeedle needle) {
ComplexShape needleShape = (ComplexShape)needle.Shape;
needleShape.Collection.Clear();
PieShape shape = new PieShape(new RectangleF2D(new PointF(0, 30), new SizeF(80, 10)), 40, 270);
shape.Appearance.ContentBrush = new SolidBrushObject(Color.Blue);
shape.Name = "pieNeedle";
needleShape.Add(shape);
}
private void CreateSectorShape(INeedle needle) {
ComplexShape needleShape = (ComplexShape)needle.Shape;
needleShape.Collection.Clear();
SectorShape shape = new SectorShape(new RectangleF2D(new PointF(0, 30), new SizeF(80, 10)), 40, 270);
shape.Appearance.ContentBrush = new SolidBrushObject(Color.Red);
shape.Name = "sectorShape";
needleShape.Add(shape);
}
private void CreateTextShape(INeedle needle) {
ComplexShape needleShape = (ComplexShape)needle.Shape;
needleShape.Collection.Clear();
TextShape shape = new TextShape();
shape.Box = new RectangleF2D(new PointF(-10, 0), new SizeF(100, 10));
shape.Text = " > > > > > ";
shape.AppearanceText.TextBrush = new SolidBrushObject(Color.Salmon);
needleShape.Add(shape);
}
private void CreateComplexNeedle(INeedle needle) {
ComplexShape needleShape = (ComplexShape)needle.Shape;
needleShape.Collection.Clear();
PolylineShape basic = new PolylineShape(new PointF[] {
new PointF(25, 20), new PointF(100, 0), new PointF(25, -20),
new PointF(95, 0), new PointF(25, 20)
});
basic.Appearance.ContentBrush = new SolidBrushObject(Color.Azure);
basic.Name = "basic";
PolylineShape cap = new PolylineShape(new PointF[] {
new PointF(100, 0), new PointF(105, 5),
new PointF(110, 0), new PointF(105, -5)
});
cap.Appearance.ContentBrush = new SolidBrushObject(Color.BurlyWood);
cap.Name = "cap";
needleShape.AddRange(new BaseShape[] { basic, cap });
}
private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e) {
switch (cmbNeedle.SelectedText) {
case "Path": CreatePathNeedle(arcScaleNeedleComponent1); break;
case "Polygon": CreatePolygonNeedle(arcScaleNeedleComponent1); break;
case "Polyline": CreatePolylineNeedle(arcScaleNeedleComponent1); break;
case "Box": CreateBoxNeedle(arcScaleNeedleComponent1); break;
case "Ellipse": CreateEllipseNeedle(arcScaleNeedleComponent1); break;
case "Arc": CreateArcNeedle(arcScaleNeedleComponent1); break;
case "Pie": CreatePieShape(arcScaleNeedleComponent1); break;
case "Sector": CreateSectorShape(arcScaleNeedleComponent1); break;
case "Text": CreateTextShape(arcScaleNeedleComponent1); break;
case "Complex": CreateComplexNeedle(arcScaleNeedleComponent1); break;
default: CreateComplexNeedle(arcScaleNeedleComponent1); break;
}
}
}
}