/// The instance of ResourceManager.
/// </summary>
private static System.Resources.ResourceManager resourceManager = null;
+ private static string currentLoadedXaml = null;
+
+ /// <summary>
+ /// Xaml loaded delegate.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public delegate void XamlLoadedHandler(string xamlName);
static NUIApplication()
{
[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>
[EditorBrowsable(EditorBrowsableState.Never)]
public NUIApplication(Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
{
- ExternalThemeManager.Initialize();
}
/// <summary>
[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>
[EditorBrowsable(EditorBrowsableState.Never)]
public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, WindowMode.Opaque, windowSize, windowPosition))
{
- ExternalThemeManager.Initialize();
}
/// <summary>
[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>
[EditorBrowsable(EditorBrowsableState.Never)]
public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
{
- ExternalThemeManager.Initialize();
}
/// <summary>
/// <param name="windowSize"></param>
/// <param name="windowPosition"></param>
/// <param name="styleSheet"></param>
- /// InhouseAPI, this could be opend in NextTizen
+ /// InhouseAPI, this could be opened in NextTizen
[Obsolete("Please do not use! This will be deprecated!")]
[EditorBrowsable(EditorBrowsableState.Never)]
public NUIApplication(Graphics.BackendType backend, WindowMode windowMode = WindowMode.Opaque, Size2D windowSize = null, Position2D windowPosition = null, string styleSheet = "") : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
{
- //windowMode and styleSheet will be added later. currenlty it's not working as expected.
+ //windowMode and styleSheet will be added later. currently 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!");
+ }
+
+ /// <summary>
+ /// The constructor with theme option.
+ /// </summary>
+ /// <param name="option">The theme option.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
+ public NUIApplication(ThemeOptions option) : base(new NUICoreBackend())
+ {
+ ApplyThemeOption(option);
+ }
+
+ /// <summary>
+ /// The constructor with window size and position and theme option.
+ /// </summary>
+ /// <param name="windowSize">The window size.</param>
+ /// <param name="windowPosition">The window position.</param>
+ /// <param name="option">The theme option.</param>
+ [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public NUIApplication(Size2D windowSize, Position2D windowPosition, ThemeOptions option) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
+ {
+ ApplyThemeOption(option);
+ }
+
+ /// <summary>
+ /// The constructor with a stylesheet, window mode and default window type.
+ /// It is the only way to create an IME window.
+ /// </summary>
+ /// <param name="styleSheet">The styleSheet URL.</param>
+ /// <param name="windowMode">The windowMode.</param>
+ /// <param name="type">The default window type.</param>
+ /// <since_tizen> 9 </since_tizen>
+ public NUIApplication(string styleSheet, WindowMode windowMode, WindowType type) : base(new NUICoreBackend(styleSheet, windowMode, type))
+ {
ExternalThemeManager.Initialize();
}
public event EventHandler Paused;
/// <summary>
+ /// Xaml loaded event.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static event XamlLoadedHandler XamlLoaded;
+
+ /// <summary>
/// Enumeration for deciding whether a NUI application window is opaque or transparent.
/// </summary>
/// <since_tizen> 3 </since_tizen>
}
/// <summary>
+ /// Enumeration for theme options of the NUIApplication.
+ /// </summary>
+ [Flags]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum ThemeOptions : int
+ {
+ /// <summary>
+ /// No option specified.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ None = 0,
+
+ /// <summary>
+ /// Enable platform theme.
+ /// When this option is on, all views in the NUIApplication is affected by platform theme (e.g. light/dark).
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ PlatformThemeEnabled = 1 << 0,
+
+ /// <summary>
+ /// Sets the default value of View.ThemeChangeSensitive.
+ /// when this option is on, all views are made sensitive on theme changing by default.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ ThemeChangeSensitive = 1 << 1,
+ };
+
+ /// <summary>
+ /// Current loaded xaml's full name.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static string CurrentLoadedXaml
+ {
+ get
+ {
+ return currentLoadedXaml;
+ }
+ set
+ {
+ if (currentLoadedXaml != value)
+ {
+ currentLoadedXaml = value;
+ XamlLoaded?.Invoke(value);
+ }
+ }
+ }
+
+ /// <summary>
/// ResourceManager to handle multilingual.
/// </summary>
/// <since_tizen> 4 </since_tizen>
static public void Preload()
{
Interop.Application.PreInitialize();
- ThemeManager.AddPackageTheme(DefaultThemeCreator.Instance);
+#if ExternalThemeEnabled
+ ThemeManager.Preload();
+#endif
IsPreload = true;
}
/// Check if it is loaded as dotnet-loader-nui.
/// </summary>
static internal bool IsPreload { get; set; }
+
+ private void ApplyThemeOption(ThemeOptions option)
+ {
+ if ((option & ThemeOptions.PlatformThemeEnabled) != 0)
+ {
+ ThemeManager.PlatformThemeEnabled = true;
+ }
+
+ if ((option & ThemeOptions.ThemeChangeSensitive) != 0)
+ {
+ ThemeManager.ApplicationThemeChangeSensitive = true;
+ }
+ }
}
/// <summary>