[NUI] Re-design theme resource structure from the tizen-theme-manager (#2633)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Application / NUIApplication.cs
index e5579eb..8299d7e 100755 (executable)
@@ -38,14 +38,9 @@ namespace Tizen.NUI
         /// </summary>
         private static System.Resources.ResourceManager resourceManager = null;
 
-        // TODO Enable this after tizen-theme-manager is released.
-        // private readonly ThemeLoader themeLoader = new ThemeLoader();
-
         static NUIApplication()
         {
             Registry.Instance.SavedApplicationThread = Thread.CurrentThread;
-            // TODO Enable this after tizen-theme-manager is released.
-            // themeLoader.ThemeChanged += TizenThemeChanged;
         }
 
         /// <summary>
@@ -55,6 +50,7 @@ namespace Tizen.NUI
         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
         public NUIApplication() : base(new NUICoreBackend())
         {
+            ExternalThemeManager.Initialize();
         }
 
         /// <summary>
@@ -68,6 +64,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public NUIApplication(Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
         {
+            ExternalThemeManager.Initialize();
         }
 
         /// <summary>
@@ -78,6 +75,7 @@ namespace Tizen.NUI
         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
         public NUIApplication(string styleSheet) : base(new NUICoreBackend(styleSheet))
         {
+            ExternalThemeManager.Initialize();
         }
 
         /// <summary>
@@ -92,6 +90,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, WindowMode.Opaque, windowSize, windowPosition))
         {
+            ExternalThemeManager.Initialize();
         }
 
         /// <summary>
@@ -103,6 +102,7 @@ namespace Tizen.NUI
         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
         public NUIApplication(string styleSheet, WindowMode windowMode) : base(new NUICoreBackend(styleSheet, windowMode))
         {
+            ExternalThemeManager.Initialize();
         }
 
         /// <summary>
@@ -118,6 +118,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
         {
+            ExternalThemeManager.Initialize();
         }
 
         /// <summary>
@@ -136,6 +137,7 @@ namespace Tizen.NUI
             //windowMode and styleSheet will be added later. currenlty it's not working as expected.
             Graphics.Backend = backend;
             Tizen.Log.Error("NUI", "Plaese DO NOT set graphical backend type with this constructor! This will give no effect!");
+            ExternalThemeManager.Initialize();
         }
 
         /// <summary>
@@ -393,6 +395,7 @@ namespace Tizen.NUI
         static public void Preload()
         {
             Interop.Application.PreInitialize();
+            ThemeManager.AddPackageTheme(DefaultThemeCreator.Instance);
             IsPreload = true;
         }
 
@@ -411,29 +414,6 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public TransitionOptions TransitionOptions { get; set; }
 
-        // TODO Enable this after tizen-theme-manager is released.
-        // private void TizenThemeChanged(object sender, ThemeEventArgs e)
-        // {
-        //     string prefix = "/theme/";
-
-        //     Dictionary<string, string> changedResources = new Dictionary<string, string>();
-        //     foreach (string key in ThemeManager.DefaultTheme.Resources.Keys)
-        //     {
-        //         // NOTE Need improve this code by checking HasKey
-        //         string newValue = null;
-        //         try
-        //         {
-        //             newValue = e.Theme.GetString(prefix + key);
-        //         }
-        //         catch { }
-        //         if (newValue != null)
-        //         {
-        //             changedResources[key] = newValue;
-        //         }
-        //     }
-        //     ThemeManager.UpdateCurrentThemeResources(changedResources);
-        // }
-
         /// <summary>
         /// Check if it is loaded as dotnet-loader-nui.
         /// </summary>