This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
60 lines (54 loc) · 2.22 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
using System;
using System.Windows.Forms;
using DevExpress.XtraGauges.Core.Model;
using System.Collections.Generic;
using DevExpress.XtraGauges.Core.Drawing;
using System.Drawing;
using DevExpress.XtraGauges.Core.Base;
namespace WindowsApplication1 {
public partial class Form1 : Form {
TextShape txt;
public Form1() {
InitializeComponent();
arcScale.ValueChanged += OnScaleValueChanged;
txt = CreateCustomTextualMarker((ComplexShape)marker.Shape);
UpdateGauge();
}
TextShape CreateCustomTextualMarker(ComplexShape markerShape) {
RectangleF2D box = new RectangleF2D(-15, -15, 30, 30);
EllipseShape eShape = new EllipseShape(box);
TextShape txt = new TextShape();
eShape.BeginUpdate();
eShape.Name = "bg";
eShape.Appearance.ContentBrush = new SolidBrushObject(Color.White);
eShape.Appearance.BorderBrush = new SolidBrushObject(Color.Black);
eShape.Appearance.BorderWidth = 2;
eShape.EndUpdate();
txt.BeginUpdate();
txt.Name = "marketText";
txt.Text = "Test";
txt.Box = box;
txt.AppearanceText.TextBrush = new SolidBrushObject(Color.Black);
txt.AppearanceText.Font = new Font("Tahoma", 8f);
txt.ShadingFlags = ShadingFlags.NoShading;
txt.EndUpdate();
markerShape.AddRange(new BaseShape[] { eShape, txt });
return txt;
}
void OnCustomTickmarkText(CustomTickmarkTextEventArgs ea) {
if(ea.Value == arcScale.MinValue || ea.Value == arcScale.MaxValue) return;
ea.Result = string.Empty;
}
void trackBar1_ValueChanged(object sender, EventArgs e) {
UpdateGauge();
}
void UpdateGauge() {
arcScale.Value = trackBar1.Value;
}
void OnScaleValueChanged(object sender, EventArgs e) {
leftRange.AnchorValue = Math.Max(arcScale.MinValue, arcScale.Value - 10);
rightRange.AnchorValue = Math.Min(arcScale.MaxValue, arcScale.Value + 10);
txt.Text = string.Format("{0:P0}", arcScale.Percent);
}
}
}