17156aa18b22e9d63e1235433a33857d770b19cf
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / Device.cs
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.IO;
5 using System.Reflection;
6 using System.Threading;
7 using System.Threading.Tasks;
8 using Tizen.NUI.Binding.Internals;
9
10 namespace Tizen.NUI.Binding
11 {
12     internal static class Device
13     {
14         public const string iOS = "iOS";
15         public const string Android = "Android";
16         public const string UWP = "UWP";
17         public const string macOS = "macOS";
18         public const string GTK = "GTK";
19         public const string Tizen = "Tizen";
20         public const string WPF = "WPF";
21
22         [EditorBrowsable(EditorBrowsableState.Never)]
23         public static DeviceInfo info;
24
25         [EditorBrowsable(EditorBrowsableState.Never)]
26         public static void SetIdiom(TargetIdiom value) => Idiom = value;
27         public static TargetIdiom Idiom { get; internal set; }
28
29         //TODO: Why are there two of these? This is never used...?
30         [EditorBrowsable(EditorBrowsableState.Never)]
31         public static void SetTargetIdiom(TargetIdiom value) => Idiom = value;
32
33         [Obsolete("TargetPlatform is obsolete as of version 2.3.4. Please use RuntimePlatform instead.")]
34 #pragma warning disable 0618
35         public static TargetPlatform OS
36         {
37             get
38             {
39                 TargetPlatform platform;
40                 if (Enum.TryParse(RuntimePlatform, out platform))
41                     return platform;
42
43                 // In the old TargetPlatform, there was no distinction between WinRT/UWP
44                 if (RuntimePlatform == UWP)
45                 {
46                     return TargetPlatform.Windows;
47                 }
48
49                 return TargetPlatform.Other;
50             }
51         }
52 #pragma warning restore 0618
53
54         public static string RuntimePlatform => null;
55
56         [EditorBrowsable(EditorBrowsableState.Never)]
57         public static DeviceInfo Info
58         {
59             get
60             {
61                 // if (info == null)
62                 //      throw new InvalidOperationException("You MUST call Tizen.NUI.Xaml.Init(); prior to using it.");
63                 return info;
64             }
65             set { info = value; }
66         }
67
68         [EditorBrowsable(EditorBrowsableState.Never)]
69         public static void SetFlowDirection(FlowDirection value) => FlowDirection = value;
70         public static FlowDirection FlowDirection { get; internal set; }
71
72         [EditorBrowsable(EditorBrowsableState.Never)]
73         public static IReadOnlyList<string> Flags { get; private set; }
74
75         [EditorBrowsable(EditorBrowsableState.Never)]
76         public static void SetFlags(IReadOnlyList<string> flags)
77         {
78             Flags = flags;
79         }
80
81         public static void BeginInvokeOnMainThread(Action action)
82         {
83             action();
84             Console.WriteLine("Device BeginInvokeOnMainThread action called");
85         }
86
87         // public static double GetNamedSize(NamedSize size, Element targetElement)
88         // {
89         //     return GetNamedSize(size, targetElement.GetType());
90         // }
91
92         // public static double GetNamedSize(NamedSize size, Type targetElementType)
93         // {
94         //     return GetNamedSize(size, targetElementType, false);
95         // }
96
97         [Obsolete("OnPlatform<> (generic) is obsolete as of version 2.3.4. Please use switch(RuntimePlatform) instead.")]
98         public static T OnPlatform<T>(T iOS, T Android, T WinPhone)
99         {
100             switch (OS)
101             {
102                 case TargetPlatform.iOS:
103                     return iOS;
104                 case TargetPlatform.Android:
105                     return Android;
106                 case TargetPlatform.Windows:
107                 case TargetPlatform.WinPhone:
108                     return WinPhone;
109             }
110
111             return iOS;
112         }
113
114         public static void OpenUri(Uri uri)
115         {
116             // PlatformServices?.OpenUriAction(uri);
117         }
118
119         [EditorBrowsable(EditorBrowsableState.Never)]
120         public static Assembly[] GetAssemblies()
121         {
122             return null;
123         }
124
125         // [EditorBrowsable(EditorBrowsableState.Never)]
126         // public static double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes)
127         // {
128         //     return PlatformServices.GetNamedSize(size, targetElementType, useOldSizes);
129         // }
130
131         public static class Styles
132         {
133             public static readonly string TitleStyleKey = "TitleStyle";
134
135             public static readonly string SubtitleStyleKey = "SubtitleStyle";
136
137             public static readonly string BodyStyleKey = "BodyStyle";
138
139             public static readonly string ListItemTextStyleKey = "ListItemTextStyle";
140
141             public static readonly string ListItemDetailTextStyleKey = "ListItemDetailTextStyle";
142
143             public static readonly string CaptionStyleKey = "CaptionStyle";
144
145             public static readonly Style TitleStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = TitleStyleKey };
146
147             public static readonly Style SubtitleStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = SubtitleStyleKey };
148
149             public static readonly Style BodyStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = BodyStyleKey };
150
151             public static readonly Style ListItemTextStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = ListItemTextStyleKey };
152
153             public static readonly Style ListItemDetailTextStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = ListItemDetailTextStyleKey };
154
155             public static readonly Style CaptionStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = CaptionStyleKey };
156         }
157     }
158 }