-
Notifications
You must be signed in to change notification settings - Fork 204
/
GradientRange.cs
152 lines (127 loc) · 4.97 KB
/
GradientRange.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
#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 GradientRange : SampleView
{
static bool UserInterfaceIdiomIsPhone
{
get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; }
}
SFCircularGauge gauge;
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 GradientRange()
{
gauge = new SFCircularGauge();
gauge.BackgroundColor = UIColor.White;
ObservableCollection<SFCircularScale> scales = new ObservableCollection<SFCircularScale>();
SFCircularScale scale = new SFCircularScale();
scale.StartValue = 0;
scale.EndValue = 100;
scale.Interval = 10;
scale.ShowRim = false;
scale.ShowTicks = false;
scale.ShowLabels = false;
SFCircularRange range = new SFCircularRange();
range.Offset = 0.8f;
range.StartValue = 0;
range.EndValue = 100;
range.Width = 25;
GaugeGradientStop color1 = new GaugeGradientStop();
color1.Value = 0;
color1.Color = UIColor.FromRGB(240, 62, 62);
range.GradientStops.Add(color1);
GaugeGradientStop color2 = new GaugeGradientStop();
color2.Value = 35;
color2.Color = UIColor.FromRGB(255, 221, 0);
range.GradientStops.Add(color2);
GaugeGradientStop color3 = new GaugeGradientStop();
color3.Value = 75;
color3.Color = UIColor.FromRGB(255, 221, 0);
range.GradientStops.Add(color3);
GaugeGradientStop color4 = new GaugeGradientStop();
color4.Value = 100;
color4.Color = UIColor.FromRGB(48, 179, 45);
range.GradientStops.Add(color4);
scale.Ranges.Add(range);
ObservableCollection<SFMarkerPointer> pointers = new ObservableCollection<SFMarkerPointer>();
SFMarkerPointer pointer = new SFMarkerPointer();
pointer.MarkerShape = MarkerShape.InvertedTriangle;
pointer.Offset = 0.8f;
pointer.Value = 55;
pointer.MarkerWidth = 15;
pointer.MarkerHeight = 15;
pointer.Color = UIColor.Red;
pointers.Add(pointer);
scale.Pointers.Add(pointer);
SFGaugeHeader header1 = new SFGaugeHeader();
header1.Text = (Foundation.NSString)"0";
header1.TextColor = UIColor.FromRGB(240, 62, 62);
header1.Position = new CGPoint(0.28, 0.86);
header1.TextStyle = UIFont.BoldSystemFontOfSize(12);
gauge.Headers.Add(header1);
SFGaugeHeader header2 = new SFGaugeHeader();
header2.Text = (Foundation.NSString)"100";
header2.TextColor = UIColor.FromRGB(48, 179, 45);
header2.Position = new CGPoint(0.75, 0.86);
header2.TextStyle = UIFont.BoldSystemFontOfSize(12);
gauge.Headers.Add(header2);
SFGaugeHeader header3 = new SFGaugeHeader();
header3.Text = (Foundation.NSString)"55%";
header3.TextColor = UIColor.FromRGB(240, 62, 62);
header3.Position = new CGPoint(0.5, 0.5);
header1.TextStyle = UIFont.BoldSystemFontOfSize(16);
gauge.Headers.Add(header3);
scales.Add(scale);
gauge.Scales = scales;
this.AddSubview(gauge);
}
protected override void Dispose(bool disposing)
{
//gauge.Scales[0].Pointers.Clear();
//gauge.Scales[0].Ranges[0].GradientColors.Clear();
//gauge.Scales[0].Ranges.Clear();
//gauge.Scales.Clear();
//gauge.Dispose();
base.Dispose(disposing);
}
}
}