-
Notifications
You must be signed in to change notification settings - Fork 500
/
Copy pathSkew_Transform.xaml.cs
77 lines (67 loc) · 2.56 KB
/
Skew_Transform.xaml.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Graphics.Display;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
namespace transforms
{
public sealed partial class Skew_Transform : Page
{
public Skew_Transform()
{
InitializeComponent();
}
// View state management for switching among Full, Fill, Snapped, and Portrait states
private DisplayPropertiesEventHandler _displayHandler;
private TypedEventHandler<ApplicationLayout, ApplicationLayoutChangedEventArgs> _layoutHandler;
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (_displayHandler == null)
{
_displayHandler = Page_OrientationChanged;
_layoutHandler = Page_LayoutChanged;
}
DisplayProperties.OrientationChanged += _displayHandler;
ApplicationLayout.GetForCurrentView().LayoutChanged += _layoutHandler;
SetCurrentOrientation(this);
}
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
DisplayProperties.OrientationChanged -= _displayHandler;
ApplicationLayout.GetForCurrentView().LayoutChanged -= _layoutHandler;
}
private void Page_LayoutChanged(object sender, ApplicationLayoutChangedEventArgs e)
{
SetCurrentOrientation(this);
}
private void Page_OrientationChanged(object sender)
{
SetCurrentOrientation(this);
}
private void SetCurrentOrientation(Control viewStateAwareControl)
{
VisualStateManager.GoToState(viewStateAwareControl, this.GetViewState(), false);
}
private String GetViewState()
{
var orientation = DisplayProperties.CurrentOrientation;
if (orientation == DisplayOrientations.Portrait ||
orientation == DisplayOrientations.PortraitFlipped) return "Portrait";
var layout = ApplicationLayout.Value;
if (layout == ApplicationLayoutState.Filled) return "Fill";
if (layout == ApplicationLayoutState.Snapped) return "Snapped";
return "Full";
}
// <SnippetSkewTransform_code>
public void IncreaseSkew(object sender, RoutedEventArgs e)
{
mySkewTransform.AngleX = mySkewTransform.AngleX + 5;
}
// </SnippetSkewTransform_code>
}
}