forked from Esri/arcgis-maps-sdk-dotnet-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompassHeading.xaml.cs
More file actions
43 lines (37 loc) · 1.07 KB
/
CompassHeading.xaml.cs
File metadata and controls
43 lines (37 loc) · 1.07 KB
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
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace KmlViewer
{
public sealed partial class CompassHeading : UserControl
{
public CompassHeading()
{
this.InitializeComponent();
SizeChanged += CompassHeading_SizeChanged;
}
private void CompassHeading_SizeChanged(object sender, SizeChangedEventArgs e)
{
SetHeading(Heading);
}
private void SetHeading(double heading)
{
var offset = this.ActualWidth * .5;
if(heading > 180)
offset += (heading - 720) * 3;
else
offset += (heading - 360) * 3;
trans.X = offset;
}
public double Heading
{
get { return (double)GetValue(HeadingProperty); }
set { SetValue(HeadingProperty, value); }
}
public static readonly DependencyProperty HeadingProperty =
DependencyProperty.Register("Heading", typeof(double), typeof(CompassHeading), new PropertyMetadata(0d, OnCompassHeadingPropertyChanged));
private static void OnCompassHeadingPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((CompassHeading)d).SetHeading((double)e.NewValue);
}
}
}