summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT.Phone/WindowsPhonePlatform.cs
blob: 7564e67315ab768f8ecdf6bef03fbb8a0f9d28dd (plain)
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
using System.Threading.Tasks;
using Windows.UI.ViewManagement;

namespace Xamarin.Forms.Platform.WinRT
{
	internal sealed class WindowsPhonePlatform
		: Platform
	{
		public WindowsPhonePlatform (Windows.UI.Xaml.Controls.Page page)
			: base (page)
		{
			_status = StatusBar.GetForCurrentView ();
			_status.Showing += OnStatusBarShowing;
			_status.Hiding += OnStatusBarHiding;
		}

		internal override Rectangle WindowBounds
		{
			get
			{
				bool landscape = Device.Info.CurrentOrientation.IsLandscape ();
				double offset = (landscape) ? _status.OccludedRect.Width : _status.OccludedRect.Height;

				Rectangle original = base.WindowBounds;
				return new Rectangle (original.X, original.Y, original.Width - ((landscape) ? offset : 0), original.Height - ((landscape) ? 0 : offset));
			}
		}

		readonly StatusBar _status;

		void OnStatusBarHiding (StatusBar sender, object args)
		{
			UpdatePageSizes ();
		}

		void OnStatusBarShowing (StatusBar sender, object args)
		{
			UpdatePageSizes ();
		}
	}
}