예제 #1
3
        private void CreateThemeSettings()
        {
            var roamingSettings = ApplicationData.Current.RoamingSettings;

            if (roamingSettings.Containers.ContainsKey("settings") == true)
            {
                // Retrieve settings and set the setting
                var theme = roamingSettings.Containers["settings"].Values["apptheme"];

                // set the initial SelectedItem
                if (theme != null)
                {
                    SetTheme(theme.ToString());
                }
            }
            else
            {
                var container = roamingSettings.CreateContainer("settings", ApplicationDataCreateDisposition.Always);

                // Create the key and save the theme setting
                string myKey = "apptheme";

                if (!roamingSettings.Containers["settings"].Values.ContainsKey(myKey))
                {
                    roamingSettings.Containers["settings"].Values.Add(myKey.ToString(), RequestedTheme.ToString());
                }
                else
                {
                    // Replace the key
                    roamingSettings.Containers["settings"].Values.Remove(myKey.ToString());
                    roamingSettings.Containers["settings"].Values.Add(myKey.ToString(), RequestedTheme.ToString());
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            Object value = ApplicationData.Current.LocalSettings.Values["SelectedTheme"];
            var    theme = Enum.Parse(typeof(ApplicationTheme), value.ToString());

            this.RequestedTheme = (ApplicationTheme)theme;
            Debug.Write("ApplicationTheme: " + RequestedTheme.ToString());
            this.Suspending        += OnSuspending;
            this.EnteredBackground += App_EnteredBackground;
        }
예제 #3
0
 private void _HamburgerView_ItemClick(object sender, MaterialLibs.Controls.HamburgerViewItemClickEventArgs e)
 {
     if (e.ClickedItem == ThemeItem)
     {
         UpdateTheme(RequestedTheme == ElementTheme.Dark);
         ApplicationData.Current.LocalSettings.Values["Theme"] = RequestedTheme.ToString();
     }
     else
     {
         ContentFrame.Navigate((Type)((HamburgerViewItem)e.ClickedItem).Tag, null, new SuppressNavigationTransitionInfo());
     }
 }
예제 #4
0
        public App()
        {
            this.InitializeComponent();
            this.Suspending         += OnSuspending;
            this.UnhandledException += App_UnhandledException;

            AppCenter.Start("682666d1-51d3-4e4a-93d0-d028d43baaa0", typeof(Analytics), typeof(Crashes));

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            if (localSettings.Values["theme"] == null)
            {
                localSettings.Values["theme"] = "Default";
            }

            if (localSettings.Values["datetimeformat"] == null)
            {
                localSettings.Values["datetimeformat"] = "Application";
            }

            if (localSettings.Values["theme"] != null)
            {
                if (localSettings.Values["theme"].ToString() == "Light")
                {
                    SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Light;
                    Debug.WriteLine("Theme Requested as Light");
                }
                else if (localSettings.Values["theme"].ToString() == "Dark")
                {
                    SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Dark;
                    Debug.WriteLine("Theme Requested as Dark");
                }
                else
                {
                    var uiSettings = new Windows.UI.ViewManagement.UISettings();
                    var color      = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
                    if (color == Colors.White)
                    {
                        SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Light;
                        Debug.WriteLine("Theme Requested as Default (Light)");
                    }
                    else
                    {
                        SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Dark;
                        Debug.WriteLine("Theme Requested as Default (Dark)");
                    }
                }
            }

            this.RequestedTheme = SettingsPages.Personalization.TV.ThemeValue;
            Debug.WriteLine("!!Requested Theme!!" + RequestedTheme.ToString());
        }
예제 #5
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            var value = ApplicationData.Current.LocalSettings.Values["SelectedTheme"];

            if (value != null)
            {
                var theme = Enum.Parse(typeof(ApplicationTheme), value.ToString());
                this.RequestedTheme = (ApplicationTheme)theme;
                Debug.Write("ApplicationTheme: " + RequestedTheme.ToString());
            }
            //Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(10, 10));
            this.Suspending        += OnSuspending;
            this.EnteredBackground += App_EnteredBackground;
        }
예제 #6
0
        private void InitializeTheme()
        {
            var value = ApplicationData.Current.LocalSettings.Values["SelectedTheme"];

            if (value != null)
            {
                var theme = Enum.Parse(typeof(ApplicationTheme), value.ToString());
                this.RequestedTheme = (ApplicationTheme)theme;
                Debug.Write("ApplicationTheme: " + RequestedTheme);
            }
            else
            {
                ApplicationData.Current.LocalSettings.Values["SelectedTheme"] = RequestedTheme.ToString();
            }
        }
예제 #7
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            CoreApplication.EnablePrelaunch(true);
            var value = ApplicationData.Current.LocalSettings.Values["SelectedTheme"];

            if (value != null)
            {
                var theme = Enum.Parse(typeof(ApplicationTheme), value.ToString());
                this.RequestedTheme = (ApplicationTheme)theme;
                Debug.Write("ApplicationTheme: " + RequestedTheme.ToString());
            }
            this.Suspending        += OnSuspending;
            this.EnteredBackground += App_EnteredBackground;
            this.LeavingBackground += App_LeavingBackground;
        }
예제 #8
0
        private void SwitchThemeButton_Click(object sender, RoutedEventArgs e)
        {
            if (ActualTheme == ElementTheme.Dark)
            {
                RequestedTheme = ElementTheme.Light;
                AppTelemetry.Current.TrackEvent(TelemetryEvents.LightThemeButton);
            }
            else
            {
                RequestedTheme = ElementTheme.Dark;
                AppTelemetry.Current.TrackEvent(TelemetryEvents.DarkThemeButton);
            }

            SetTitleBarButtonForeground(RequestedTheme);
            ApplicationData.Current.LocalSettings.Values[nameof(RequestedTheme)] = RequestedTheme.ToString();
            OnPropertyChanged(nameof(CurrentTheme));
        }
예제 #9
0
        public App()
        {
            this.InitializeComponent();
            this.Suspending         += OnSuspending;
            this.UnhandledException += App_UnhandledException;
            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            if (localSettings.Values["theme"] != null)
            {
                if (localSettings.Values["theme"].ToString() == "Light")
                {
                    SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Light;
                    Debug.WriteLine("Theme Requested as Light");
                }
                else if (localSettings.Values["theme"].ToString() == "Dark")
                {
                    SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Dark;
                    Debug.WriteLine("Theme Requested as Dark");
                }
                else
                {
                    var uiSettings = new Windows.UI.ViewManagement.UISettings();
                    var color      = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
                    if (color == Colors.White)
                    {
                        SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Light;
                        Debug.WriteLine("Theme Requested as Default (Light)");
                    }
                    else
                    {
                        SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Dark;
                        Debug.WriteLine("Theme Requested as Default (Dark)");
                    }
                }
            }
            else
            {
                localSettings.Values["theme"] = "Default";
            }

            this.RequestedTheme = SettingsPages.Personalization.TV.ThemeValue;
            Debug.WriteLine("!!Requested Theme!!" + RequestedTheme.ToString());
        }
예제 #10
0
        private void saveThemeInSettings()
        {
            var localSettings = ApplicationData.Current.LocalSettings;

            localSettings.Values["AppTheme"] = RequestedTheme.ToString();
        }