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()); } } }
public void RefreshStyles(ElementTheme theme, bool clearExisting = false) { if (theme == ElementTheme.Default && RequestedTheme == ElementTheme.Default) { RefreshStyles(AccentColor); } else { RefreshStyles(RequestedTheme.ToApplicationTheme(), clearExisting); } }
/// <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; }
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()); } }
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()); }
public void RefreshStyles(ElementTheme theme) { DebugWrite($"Theme: {theme}"); if (theme == ElementTheme.Default && RequestedTheme == ElementTheme.Default) { RefreshStyles(AccentColor); } else { RefreshStyles(RequestedTheme.ToApplicationTheme()); } }
/// <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; }
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(); } }
/// <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; }
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)); }
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()); }
private void saveThemeInSettings() { var localSettings = ApplicationData.Current.LocalSettings; localSettings.Values["AppTheme"] = RequestedTheme.ToString(); }
public void Set(RequestedTheme r) { Theme = r; if (Theme != RequestedTheme.Default) { MainColor = Colors.Transparent; } }