Add ScriptUI to support XAML file (#320)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / Device.cs
index d012c33..c223287 100755 (executable)
@@ -5,7 +5,7 @@ using System.IO;
 using System.Reflection;
 using System.Threading;
 using System.Threading.Tasks;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
 
 namespace Tizen.NUI.Binding
 {
@@ -17,7 +17,7 @@ namespace Tizen.NUI.Binding
         public const string macOS = "macOS";
         public const string GTK = "GTK";
         public const string Tizen = "Tizen";
-               public const string WPF = "WPF";
+        public const string WPF = "WPF";
 
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static DeviceInfo info;
@@ -28,9 +28,9 @@ namespace Tizen.NUI.Binding
         public static void SetIdiom(TargetIdiom value) => Idiom = value;
         public static TargetIdiom Idiom { get; internal set; }
 
-               //TODO: Why are there two of these? This is never used...?
-               [EditorBrowsable(EditorBrowsableState.Never)]
-               public static void SetTargetIdiom(TargetIdiom value) => Idiom = value;
+        //TODO: Why are there two of these? This is never used...?
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static void SetTargetIdiom(TargetIdiom value) => Idiom = value;
 
         [Obsolete("TargetPlatform is obsolete as of version 2.3.4. Please use RuntimePlatform instead.")]
 #pragma warning disable 0618
@@ -53,66 +53,72 @@ namespace Tizen.NUI.Binding
         }
 #pragma warning restore 0618
 
-               public static string RuntimePlatform => PlatformServices?.RuntimePlatform;
-
-               [EditorBrowsable(EditorBrowsableState.Never)]
-               public static DeviceInfo Info
-               {
-                       get
-                       {
-                               // if (info == null)
-                               //      throw new InvalidOperationException("You MUST call Xamarin.Forms.Init(); prior to using it.");
-                               return info;
-                       }
-                       set { info = value; }
-               }
-
-               [EditorBrowsable(EditorBrowsableState.Never)]
-               public static void SetFlowDirection(FlowDirection value) => FlowDirection = value;
-               public static FlowDirection FlowDirection { get; internal set; }
-
-               [EditorBrowsable(EditorBrowsableState.Never)]
-               public static bool IsInvokeRequired
-               {
-                       get { return PlatformServices.IsInvokeRequired; }
-               }
-
-               [EditorBrowsable(EditorBrowsableState.Never)]
-               public static IPlatformServices PlatformServices
-               {
-                       get
-                       {
-                               // if (s_platformServices == null)
-                               //      throw new InvalidOperationException("You MUST call Tizen.NUI.Init(); prior to using it.");
-                               return s_platformServices;
-                       }
-                       set { s_platformServices = value; }
-               }
-
-               [EditorBrowsable(EditorBrowsableState.Never)]
-               public static IReadOnlyList<string> Flags { get; private set; }
-
-               [EditorBrowsable(EditorBrowsableState.Never)]
-               public static void SetFlags(IReadOnlyList<string> flags)
-               {
-                       Flags = flags;
-               }
-
-               public static void BeginInvokeOnMainThread(Action action)
-               {
-                       PlatformServices?.BeginInvokeOnMainThread(action);
-               }
-
-        public static double GetNamedSize(NamedSize size, Element targetElement)
+        public static string RuntimePlatform => PlatformServices?.RuntimePlatform;
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static DeviceInfo Info
         {
-            return GetNamedSize(size, targetElement.GetType());
+            get
+            {
+                // if (info == null)
+                //     throw new InvalidOperationException("You MUST call Xamarin.Forms.Init(); prior to using it.");
+                return info;
+            }
+            set { info = value; }
         }
 
-        public static double GetNamedSize(NamedSize size, Type targetElementType)
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static void SetFlowDirection(FlowDirection value) => FlowDirection = value;
+        public static FlowDirection FlowDirection { get; internal set; }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static bool IsInvokeRequired
         {
-            return GetNamedSize(size, targetElementType, false);
+            get { return PlatformServices.IsInvokeRequired; }
         }
 
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static IPlatformServices PlatformServices
+        {
+            get
+            {
+                if (s_platformServices == null)
+                    throw new InvalidOperationException("You MUST call Tizen.NUI.Init(); prior to using it.");
+                return s_platformServices;
+            }
+            set
+            {
+                s_platformServices = value;
+                Console.WriteLine("Device s_platformServices : " + s_platformServices );
+            }
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static IReadOnlyList<string> Flags { get; private set; }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static void SetFlags(IReadOnlyList<string> flags)
+        {
+            Flags = flags;
+        }
+
+        public static void BeginInvokeOnMainThread(Action action)
+        {
+            PlatformServices?.BeginInvokeOnMainThread(action);
+            action();
+            Console.WriteLine("Device BeginInvokeOnMainThread action called");
+        }
+
+        // public static double GetNamedSize(NamedSize size, Element targetElement)
+        // {
+        //     return GetNamedSize(size, targetElement.GetType());
+        // }
+
+        // public static double GetNamedSize(NamedSize size, Type targetElementType)
+        // {
+        //     return GetNamedSize(size, targetElementType, false);
+        // }
+
         [Obsolete("OnPlatform is obsolete as of version 2.3.4. Please use switch(RuntimePlatform) instead.")]
         public static void OnPlatform(Action iOS = null, Action Android = null, Action WinPhone = null, Action Default = null)
         {
@@ -163,12 +169,12 @@ namespace Tizen.NUI.Binding
 
         public static void OpenUri(Uri uri)
         {
-            PlatformServices?.OpenUriAction(uri);
+            // PlatformServices?.OpenUriAction(uri);
         }
 
         public static void StartTimer(TimeSpan interval, Func<bool> callback)
         {
-            PlatformServices?.StartTimer(interval, callback);
+            PlatformServices.StartTimer(interval, callback);
         }
 
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -177,11 +183,11 @@ namespace Tizen.NUI.Binding
             return PlatformServices?.GetAssemblies();
         }
 
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public static double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes)
-        {
-            return PlatformServices.GetNamedSize(size, targetElementType, useOldSizes);
-        }
+        // [EditorBrowsable(EditorBrowsableState.Never)]
+        // public static double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes)
+        // {
+        //     return PlatformServices.GetNamedSize(size, targetElementType, useOldSizes);
+        // }
 
         internal static Task<Stream> GetStreamAsync(Uri uri, CancellationToken cancellationToken)
         {
@@ -192,27 +198,27 @@ namespace Tizen.NUI.Binding
         {
             public static readonly string TitleStyleKey = "TitleStyle";
 
-                       public static readonly string SubtitleStyleKey = "SubtitleStyle";
+            public static readonly string SubtitleStyleKey = "SubtitleStyle";
 
-                       public static readonly string BodyStyleKey = "BodyStyle";
+            public static readonly string BodyStyleKey = "BodyStyle";
 
-                       public static readonly string ListItemTextStyleKey = "ListItemTextStyle";
+            public static readonly string ListItemTextStyleKey = "ListItemTextStyle";
 
-                       public static readonly string ListItemDetailTextStyleKey = "ListItemDetailTextStyle";
+            public static readonly string ListItemDetailTextStyleKey = "ListItemDetailTextStyle";
 
-                       public static readonly string CaptionStyleKey = "CaptionStyle";
+            public static readonly string CaptionStyleKey = "CaptionStyle";
 
-                       public static readonly Style TitleStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = TitleStyleKey };
+            public static readonly Style TitleStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = TitleStyleKey };
 
-                       public static readonly Style SubtitleStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = SubtitleStyleKey };
+            public static readonly Style SubtitleStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = SubtitleStyleKey };
 
-                       public static readonly Style BodyStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = BodyStyleKey };
+            public static readonly Style BodyStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = BodyStyleKey };
 
-                       public static readonly Style ListItemTextStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = ListItemTextStyleKey };
+            public static readonly Style ListItemTextStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = ListItemTextStyleKey };
 
-                       public static readonly Style ListItemDetailTextStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = ListItemDetailTextStyleKey };
+            public static readonly Style ListItemDetailTextStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = ListItemDetailTextStyleKey };
 
-                       public static readonly Style CaptionStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = CaptionStyleKey };
-               }
-       }
+            public static readonly Style CaptionStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = CaptionStyleKey };
+        }
+    }
 }