forked from syncfusion/xamarin-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sublayer.cs
124 lines (105 loc) · 4.05 KB
/
Sublayer.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
#region Copyright Syncfusion Inc. 2001-2022.
// Copyright Syncfusion Inc. 2001-2022. 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 Syncfusion.SfBusyIndicator.iOS;
using System;
using Syncfusion.SfMaps.iOS;
#if __UNIFIED__
using Foundation;
using CoreGraphics;
using UIKit;
#else
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using nint = System.Int32;
using nuint = System.Int32;
using CGPoint= System.Drawing.PointF;
using CGSize = System.Drawing.SizeF;
using CGRect = System.Drawing.RectangleF;
using nfloat = System.Single;
#endif
namespace SampleBrowser
{
public class Sublayer : SampleView
{
internal SfBusyIndicator busyindicator;
UIView view;
UILabel label;
bool isDisposed;
public override void LayoutSubviews()
{
view.Frame = new CGRect(Frame.Location.X, 0, Frame.Size.Width, Frame.Size.Height);
busyindicator.Frame = new CGRect(Frame.Location.X, 0, Frame.Size.Width, Frame.Size.Height);
label.Frame = new CGRect(0f, 0f, Frame.Size.Width, 40);
SetNeedsDisplay();
}
protected override void Dispose(bool disposing)
{
isDisposed = true;
base.Dispose(disposing);
}
public Sublayer()
{
SFMap maps = new SFMap();
view = new UIView();
view.Frame = new CGRect(0, 0, 300, 400);
busyindicator = new SfBusyIndicator();
busyindicator.ViewBoxWidth = 75;
busyindicator.ViewBoxHeight = 75;
busyindicator.Foreground = UIColor.FromRGB(0x77, 0x97, 0x72); /*#779772*/
busyindicator.AnimationType = SFBusyIndicatorAnimationType.SFBusyIndicatorAnimationTypeSlicedCircle;
view.AddSubview(busyindicator);
label = new UILabel();
label.TextAlignment = UITextAlignment.Center;
label.Text = "Rivers in Australia";
label.Font = UIFont.SystemFontOfSize(18);
label.Frame = new CGRect(0, 0, 400, 40);
label.TextColor = UIColor.Black;
view.AddSubview(label);
NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(0.3), delegate {
if (isDisposed)
return;
maps.Frame = new CGRect(Frame.Location.X, 60, Frame.Size.Width - 6, Frame.Size.Height - 60);
view.AddSubview(maps);
});
SFShapeFileLayer layer = new SFShapeFileLayer();
layer.Uri = (NSString)NSBundle.MainBundle.PathForResource("australia", "shp");
SFShapeSetting shapeSettings = new SFShapeSetting();
shapeSettings.StrokeThickness = 1;
shapeSettings.StrokeColor = UIColor.White;
shapeSettings.Fill = UIColor.FromRGB(172, 249, 247);
layer.ShapeSettings = shapeSettings;
SFShapeFileLayer subLayer = new SFShapeFileLayer();
subLayer.Uri = (NSString)NSBundle.MainBundle.PathForResource("river", "shp");
SFShapeSetting subLayerSettings = new SFShapeSetting();
subLayerSettings.StrokeThickness = 2;
subLayerSettings.Fill = UIColor.FromRGB(0, 168, 204);
subLayer.ShapeSettings = subLayerSettings;
layer.Sublayers.Add(subLayer);
maps.Layers.Add(layer);
AddSubview(view);
maps.Delegate = new MapsSublayerDelegate(this);
}
}
public class MapsSublayerDelegate : SFMapsDelegate
{
public MapsSublayerDelegate(Sublayer sublayer)
{
sample = sublayer;
}
Sublayer sample;
public override void DidLoad(SFMap map)
{
if (sample.busyindicator != null)
{
sample.busyindicator.RemoveFromSuperview();
sample.busyindicator = null;
}
}
}
}