-
Notifications
You must be signed in to change notification settings - Fork 204
/
CircularGaugeSample.cs
139 lines (118 loc) · 4.28 KB
/
CircularGaugeSample.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
#region Copyright Syncfusion Inc. 2001-2024.
// Copyright Syncfusion Inc. 2001-2024. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// [email protected]. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using Syncfusion.SfGauge.iOS;
using System.Collections.ObjectModel;
#if __UNIFIED__
using Foundation;
using UIKit;
using CoreGraphics;
using System.Drawing;
#else
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using CGRect = System.Drawing.RectangleF;
using CGPoint = System.Drawing.PointF;
using CGSize = System.Drawing.SizeF;
using nfloat = System.Single;
using System.Drawing;
#endif
namespace SampleBrowser
{
public class CircularGaugeSample : SampleView
{
static bool UserInterfaceIdiomIsPhone
{
get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; }
}
#region View lifecycle
SFCircularGauge gauge;
SFNeedlePointer needlePointer;
UISlider slider;
UIView option = new UIView();
public override void LayoutSubviews()
{
foreach (var view in this.Subviews)
{
view.Frame = Bounds;
}
if (Utility.IsIPad)
{
gauge.Frame = new CGRect(50, 50, (float)this.Frame.Width - 100, (float)this.Frame.Height - 100);
}
else
{
gauge.Frame = new CGRect(10, 10, (float)this.Frame.Width - 20, (float)this.Frame.Height - 20);
}
base.LayoutSubviews();
}
public CircularGaugeSample()
{
gauge = new SFCircularGauge();
gauge.Scales.Add(new SFCircularScale());
ObservableCollection<SFCircularScale> scales = new ObservableCollection<SFCircularScale>();
SFCircularScale scale = new SFCircularScale();
scale.StartValue = 0;
scale.EndValue = 100;
scale.Interval = 10;
//scale.StartAngle = 35;
// scale.SweepAngle = 320;
scale.RimWidth = 5;
scale.ShowTicks = false;
scale.ShowLabels = true;
scale.RimColor = UIColor.FromRGB(224, 224, 224);
scale.LabelColor = UIColor.Black;
scale.LabelOffset = 0.8f;
scale.MinorTicksPerInterval = 0;
ObservableCollection<SFCircularPointer> pointers = new ObservableCollection<SFCircularPointer>();
needlePointer = new SFNeedlePointer();
needlePointer.Value = 60;
needlePointer.Color = UIColor.FromRGB(117, 117, 117);
needlePointer.KnobRadius = 12;
needlePointer.KnobColor = UIColor.FromRGB(117, 117, 117);
needlePointer.Width = 3;
needlePointer.LengthFactor = 0.6f;
needlePointer.PointerType = SFCiruclarGaugePointerType.SFCiruclarGaugePointerTypeTriangle;
scale.Pointers.Add(needlePointer);
scales.Add(scale);
gauge.Scales = scales;
this.AddSubview(gauge);
CreateOptionView();
this.OptionView = option;
}
private void CreateOptionView()
{
slider = new UISlider();
slider.Frame = new CGRect(5, 50, 320, 60);
slider.MinValue = 0f;
slider.MaxValue = 100f;
slider.Value = 60f;
slider.ValueChanged += (object sender, EventArgs e) =>
{
needlePointer.Value = slider.Value;
};
UILabel text1 = new UILabel();
text1.Text = "Change Pointer Value";
text1.TextAlignment = UITextAlignment.Left;
text1.TextColor = UIColor.Black;
text1.Frame = new CGRect(10, 25, 320, 40);
text1.Font = UIFont.FromName("Helvetica", 14f);
this.option.AddSubview(text1);
this.option.AddSubview(slider);
}
protected override void Dispose(bool disposing)
{
//gauge.Scales[0].Pointers.Clear();
//gauge.Scales.Clear();
//gauge.Dispose();
base.Dispose(disposing);
}
#endregion
}
}