forked from syncfusion/xamarin-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slider.cs
110 lines (94 loc) · 3.43 KB
/
Slider.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
#region Copyright Syncfusion Inc. 2001 - 2019
// Copyright Syncfusion Inc. 2001 - 2019. 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.SfRangeSlider.iOS;
#if __UNIFIED__
using Foundation;
using UIKit;
using CoreGraphics;
#else
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using nint = System.Int32;
using nuint = System.Int32;
using CGSize = System.Drawing.SizeF;
using CGRect = System.Drawing.RectangleF;
using nfloat = System.Single;
#endif
namespace SampleBrowser
{
public class Slider : SampleView
{
UIImageView mountImg;
SfRangeSlider RangeSliderSample;
UILabel opacityLabel;
public Slider ()
{
//RangeSlider
RangeSliderSample = new SfRangeSlider();
RangeSliderSample.Maximum=100;
RangeSliderSample.Minimum=0;
RangeSliderSample.Value = 100;
RangeSliderSample.RangeStart=0;
RangeSliderSample.RangeEnd=100;
RangeSliderSample.TickPlacement=SFTickPlacement.SFTickPlacementBottomRight;
RangeSliderSample.ValuePlacement=SFValuePlacement.SFValuePlacementBottomRight;
RangeSliderSample.TickFrequency=20;
RangeSliderSample.ToolTipPlacement = SFToolTipPlacement.SFToolTipPlacementTopLeft;
RangeSliderSample.SnapsTo = SFSnapsTo.SFSnapsToNone;
RangeSliderSample.ShowRange=false;
RangeSliderSample.KnobColor=UIColor.White;
RangeSliderSample.TrackSelectionColor=UIColor.FromRGB(66,115,185);
RangeSliderSample.TrackColor=UIColor.FromRGB(182,182,182);
RangeSliderSample.ValueChange += Slider_ValueChange;
this.AddSubview (RangeSliderSample);
mainPageDesign();
}
void Slider_ValueChange(object sender, ValueEventArgs e)
{
SetValue(e.Value);
}
public void mainPageDesign()
{
//Image
mountImg = new UIImageView();
mountImg.Image = UIImage.FromBundle("Images/mount.png");
//opacityLabel
opacityLabel = new UILabel();
opacityLabel.TextColor = UIColor.Black;
opacityLabel.Text = "Opacity";
opacityLabel.TextAlignment = UITextAlignment.Left;
opacityLabel.Font = UIFont.FromName("Helvetica", 20f);
this.AddSubview(mountImg);
this.AddSubview(opacityLabel);
}
public void SetValue(nfloat value)
{
mountImg.Alpha = value / 100;
}
public override void LayoutSubviews ()
{
foreach (var view in this.Subviews) {
view.Frame = Bounds;
if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) {
mountImg.Frame = new CGRect (this.Frame.X + 120, this.Frame.Y, this.Frame.Size.Width - 240, this.Frame.Size.Height / 2);
opacityLabel.Frame = new CGRect (this.Frame.X + 120, this.Frame.Y + this.Frame.Size.Height / 2 + 10, this.Frame.Size.Width - 60, 30);
RangeSliderSample.Frame = new CGRect (this.Frame.X + 120, this.Frame.Y + this.Frame.Size.Height / 2 + 20, this.Frame.Size.Width - 220, 100);
}
else
{
mountImg.Frame = new CGRect (this.Frame.X + 20, this.Frame.Y, this.Frame.Size.Width - 40, this.Frame.Size.Height / 2);
opacityLabel.Frame = new CGRect (this.Frame.X + 20, this.Frame.Y + this.Frame.Size.Height / 2 + 10, this.Frame.Size.Width - 40, 30);
RangeSliderSample.Frame = new CGRect (this.Frame.X + 10, this.Frame.Y + this.Frame.Size.Height / 2 + 20, this.Frame.Size.Width - 20, 100);
}
}
base.LayoutSubviews ();
}
}
}