-
Notifications
You must be signed in to change notification settings - Fork 204
/
Picker.cs
74 lines (66 loc) · 1.97 KB
/
Picker.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
using System;
using Android.Content;
using Android.Util;
namespace SampleBrowser
{
public class Picker: SamplePage
{
SfPickerDemo mobile;
SfPickerDemo_Tab tab;
Context contextTablet;
public Picker()
{
}
public override Android.Views.View GetSampleContent(Context context)
{
if (IsTabletDevice(context))
{
tab = new SfPickerDemo_Tab();
contextTablet = context;
return tab.GetSampleContent(context);
}
else
{
mobile = new SfPickerDemo();
return mobile.GetSampleContent(context);
}
}
public override Android.Views.View GetPropertyWindowLayout(Context context)
{
if (IsTabletDevice(context))
{
return tab.GetPropertyWindowLayout(context);
}
else
{
return mobile.GetPropertyWindowLayout(context);
}
}
public override void OnApplyChanges()
{
if (IsTabletDevice(contextTablet))
tab.OnApplyChanges();
else
mobile.OnApplyChanges();
}
public static bool IsTabletDevice(Android.Content.Context context)
{
if (context != null)
{
try
{
DisplayMetrics displayMetrics = context.Resources.DisplayMetrics;
float screenWidth = displayMetrics.WidthPixels / displayMetrics.Xdpi;
float screenHeight = displayMetrics.HeightPixels / displayMetrics.Ydpi;
double size = Math.Sqrt(Math.Pow(screenWidth, 2) + Math.Pow(screenHeight, 2));
return size >= 6;
}
catch
{
return false;
}
}
return false;
}
}
}