public object Convert(object value, Type targetType, object parameter, string language) { bool isEnabled = (bool)value; GeneralSettings generalSettings = settingsUtils.GetSettings <GeneralSettings>(string.Empty); var defaultTheme = new Windows.UI.ViewManagement.UISettings(); var uiTheme = defaultTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString(); string selectedTheme = generalSettings.Theme.ToLower(); if (selectedTheme == "dark" || (selectedTheme == "system" && uiTheme == "#FF000000")) { // DARK if (isEnabled) { return((SolidColorBrush)Application.Current.Resources["DarkForegroundBrush"]); } else { return((SolidColorBrush)Application.Current.Resources["DarkForegroundDisabledBrush"]); } } else { // LIGHT if (isEnabled) { return((SolidColorBrush)Application.Current.Resources["LightForegroundBrush"]); } else { return((SolidColorBrush)Application.Current.Resources["LightForegroundDisabledBrush"]); } } }
public static void InitializeTheme() { // Get system theme. var defaultTheme = new Windows.UI.ViewManagement.UISettings(); var uiTheme = defaultTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString(); // Set app settings accordingly. if (uiTheme == "#FF000000") { Windows.Storage.ApplicationData.Current.LocalSettings.Values["systemThemeSetting"] = 1; } else if (uiTheme == "#FFFFFFFF") { Windows.Storage.ApplicationData.Current.LocalSettings.Values["systemThemeSetting"] = 0; } // Check if user has set a theme pref in the app object userThemeValue = Windows.Storage.ApplicationData.Current.LocalSettings.Values["userThemeSetting"]; if (userThemeValue != null) { // If so, apply theme choice. Application.Current.RequestedTheme = (ApplicationTheme)(int)userThemeValue; } else { // Otherwise, use system theme. object sysThemeValue = Windows.Storage.ApplicationData.Current.LocalSettings.Values["systemThemeSetting"]; Application.Current.RequestedTheme = (ApplicationTheme)(int)sysThemeValue; } }
public static bool IsAccentColorDark() { var uiSettings = new Windows.UI.ViewManagement.UISettings(); var c = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent); var isDark = (5 * c.G + 2 * c.R + c.B) <= 8 * 128; return(isDark); }
public MainPage() { this.InitializeComponent(); UpdatePreview(); highlightedItem = RValue; myCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch; RValue.ValueChanged += Slider_ValueChanged; GValue.ValueChanged += Slider_ValueChanged; BValue.ValueChanged += Slider_ValueChanged; //Hide our custom tool's UI until it is activated ToolPanel.Visibility = Visibility.Collapsed; // Create a reference to the RadialController. myController = RadialController.CreateForCurrentView(); // Create a menu item for the custom tool. //RadialControllerMenuItem myItem = // RadialControllerMenuItem.CreateFromKnownIcon("Background", RadialControllerMenuKnownIcon.InkColor); RadialControllerMenuItem myItem = RadialControllerMenuItem.CreateFromFontGlyph("Background", "\xE7B5", "Segoe MDL2 Assets"); //Add the custom tool's menu item to the menu myController.Menu.Items.Add(myItem); //Create a handler for when the menu item is selected myItem.Invoked += MyItem_Invoked; //Create handlers for button and rotational input myController.RotationChanged += MyController_RotationChanged; myController.ButtonClicked += MyController_ButtonClicked; myController.ButtonPressed += MyController_ButtonPressed; myController.ButtonReleased += MyController_ButtonReleased; //Remove Scroll/Zoom/Undo tools as app doesn't support them RadialControllerConfiguration config = RadialControllerConfiguration.GetForCurrentView(); config.SetDefaultMenuItems(new RadialControllerSystemMenuItemKind[] { RadialControllerSystemMenuItemKind.Volume }); //Query user's handedness for on-screen UI Windows.UI.ViewManagement.UISettings settings = new Windows.UI.ViewManagement.UISettings(); isRightHanded = (settings.HandPreference == Windows.UI.ViewManagement.HandPreference.RightHanded); //Create handlers for when RadialController provides an on-screen position myController.ScreenContactStarted += MyController_ScreenContactStarted; myController.ScreenContactContinued += MyController_ScreenContactContinued; myController.ScreenContactEnded += MyController_ScreenContactEnded; //Create handlers for when RadialController focus changes myController.ControlAcquired += MyController_ControlAcquired; myController.ControlLost += MyController_ControlLost; }
public static bool IsDarkTheme() { var selectedTheme = SettingsRepository <GeneralSettings> .GetInstance(settingsUtils).SettingsConfig.Theme.ToUpper(CultureInfo.InvariantCulture); var defaultTheme = new Windows.UI.ViewManagement.UISettings(); var uiTheme = defaultTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString(System.Globalization.CultureInfo.InvariantCulture); return(selectedTheme == "DARK" || (selectedTheme == "SYSTEM" && uiTheme == "#FF000000")); }
/// <summary> /// Check wat is the current system theme and set it to the opposite /// </summary> private void SystemTheme() { var DefaultTheme = new Windows.UI.ViewManagement.UISettings(); var uiTheme = DefaultTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString(); ElementTheme systemTheme = (uiTheme != "FF000000") ? ElementTheme.Light : ElementTheme.Dark; GlobalSettings.appTheme = systemTheme; themeDefaultRadio.IsChecked = true; SetTheme(GlobalSettings.appTheme); }
public App() { this.InitializeComponent(); exceptionDialog = new Dialogs.ExceptionDialog(); 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()); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { string Buffer; Windows.UI.ViewManagement.UISettings UserSettings = new Windows.UI.ViewManagement.UISettings(); Windows.UI.Color Color; Buffer = string.Format("Hand Preference {0}\n", UserSettings.HandPreference == Windows.UI.ViewManagement.HandPreference.LeftHanded ? "left" : "right"); Buffer += string.Format("Cursor Size {0} x {1}\n", UserSettings.CursorSize.Width, UserSettings.CursorSize.Height); Buffer += string.Format("Scrollbar Size {0} x {1}\n", UserSettings.ScrollBarSize.Width, UserSettings.ScrollBarSize.Height); Buffer += string.Format("Scrollbar Arrow Size {0} x {1}\n", UserSettings.ScrollBarArrowSize.Width, UserSettings.ScrollBarArrowSize.Height); Buffer += string.Format("Scrollbar Thumb Box Size {0} x {1}\n", UserSettings.ScrollBarThumbBoxSize.Width, UserSettings.ScrollBarThumbBoxSize.Height); Buffer += string.Format("Message Duration {0}\n", UserSettings.MessageDuration); Buffer += string.Format("Animations Enabled {0}\n", UserSettings.AnimationsEnabled ? "true" : "false"); Buffer += string.Format("Caret Browsing Enabled {0}\n", UserSettings.CaretBrowsingEnabled ? "true" : "false"); Buffer += string.Format("Caret Blink Rate {0}\n", UserSettings.CaretBlinkRate); Buffer += string.Format("Caret Width {0}\n", UserSettings.CaretWidth); Buffer += string.Format("Double Click Time {0}\n", UserSettings.DoubleClickTime); Buffer += string.Format("Mouse Hover Time {0}\n", UserSettings.MouseHoverTime); Buffer += "System Colors: \n"; Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.ActiveCaption); Buffer += string.Format("\tActive Caption: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.Background); Buffer += string.Format("\tBackground: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.ButtonFace); Buffer += string.Format("\tButton Face: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.ButtonText); Buffer += string.Format("\tButton Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.CaptionText); Buffer += string.Format("\tCaption Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.GrayText); Buffer += string.Format("\tGray/Disabled Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.Highlight); Buffer += string.Format("\tHighlight: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.HighlightText); Buffer += string.Format("\tHighlighted Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.Hotlight); Buffer += string.Format("\tHotlight: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.InactiveCaption); Buffer += string.Format("\tInactive Caption: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.InactiveCaptionText); Buffer += string.Format("\tInactive Caption Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.Window); Buffer += string.Format("\tWindow: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.WindowText); Buffer += string.Format("\tWindow Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); UIOutputTextBlock.Text = Buffer; }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { string Buffer; Windows.UI.ViewManagement.UISettings UserSettings = new Windows.UI.ViewManagement.UISettings(); Windows.UI.Color Color; Buffer = string.Format("Hand Preference {0}\n", UserSettings.HandPreference == Windows.UI.ViewManagement.HandPreference.LeftHanded ? "left" : "right"); Buffer += string.Format("Cursor Size {0} x {1}\n", UserSettings.CursorSize.Width, UserSettings.CursorSize.Height); Buffer += string.Format("Scrollbar Size {0} x {1}\n", UserSettings.ScrollBarSize.Width, UserSettings.ScrollBarSize.Height); Buffer += string.Format("Scrollbar Arrow Size {0} x {1}\n", UserSettings.ScrollBarArrowSize.Width, UserSettings.ScrollBarArrowSize.Height); Buffer += string.Format("Scrollbar Thumb Box Size {0} x {1}\n", UserSettings.ScrollBarThumbBoxSize.Width, UserSettings.ScrollBarThumbBoxSize.Height); Buffer += string.Format("Message Duration {0}\n", UserSettings.MessageDuration); Buffer += string.Format("Animations Enabled {0}\n", UserSettings.AnimationsEnabled ? "true" : "false"); Buffer += string.Format("Caret Browsing Enabled {0}\n", UserSettings.CaretBrowsingEnabled ? "true" : "false"); Buffer += string.Format("Caret Blink Rate {0}\n", UserSettings.CaretBlinkRate); Buffer += string.Format("Caret Width {0}\n", UserSettings.CaretWidth); Buffer += string.Format("Double Click Time {0}\n", UserSettings.DoubleClickTime); Buffer += string.Format("Mouse Hover Time {0}\n", UserSettings.MouseHoverTime); Buffer += "System Colors: \n"; Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.ActiveCaption); Buffer += string.Format("\tActive Caption: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.Background); Buffer += string.Format("\tBackground: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.ButtonFace); Buffer += string.Format("\tButton Face: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.ButtonText); Buffer += string.Format("\tButton Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.CaptionText); Buffer += string.Format("\tCaption Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.GrayText); Buffer += string.Format("\tGray/Disabled Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.Highlight); Buffer += string.Format("\tHighlight: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.HighlightText); Buffer += string.Format("\tHighlighted Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.Hotlight); Buffer += string.Format("\tHotlight: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.InactiveCaption); Buffer += string.Format("\tInactive Caption: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.InactiveCaptionText); Buffer += string.Format("\tInactive Caption Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.Window); Buffer += string.Format("\tWindow: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); Color = UserSettings.UIElementColor(Windows.UI.ViewManagement.UIElementType.WindowText); Buffer += string.Format("\tWindow Text: {0}, {1}, {2}\n", Color.R, Color.G, Color.B); UIOutputTextBlock.Text = Buffer; }
public DialColorControl() { this.InitializeComponent(); //handedness for on-screen UI Windows.UI.ViewManagement.UISettings settings = new Windows.UI.ViewManagement.UISettings(); rightHanded = (settings.HandPreference == Windows.UI.ViewManagement.HandPreference.RightHanded); //if left handed then rotate the entire control 180 if (!rightHanded) { RotateTransform trans = new RotateTransform(); trans.Angle = 180; colorControl.RenderTransform = trans; } }
private void AutoReload() { if (Environment.OSVersion.Version >= new Version(10, 0)) { var uiSettings = new Windows.UI.ViewManagement.UISettings(); uiSettings.ColorValuesChanged += (sender, args) => { Application.Current.Dispatcher.Invoke( () => { ChangeTheme(Settings.Theme); }); }; UISettings = uiSettings; } }
public object Convert(object value, Type targetType, object parameter, string language) { bool t = (bool)value; if (t) //return new SolidColorBrush(Windows.UI.ViewManagement.UIColorType.Accent); { Windows.UI.ViewManagement.UISettings uISettings = new Windows.UI.ViewManagement.UISettings(); return(new SolidColorBrush(uISettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent))); } else { return(new SolidColorBrush(Colors.White)); } }
private static string GetDefaulTheme() { string defaultWinTheme = string.Empty; var DefaultTheme = new Windows.UI.ViewManagement.UISettings(); var uiTheme = DefaultTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString(); if (uiTheme == "#FF000000") { defaultWinTheme = "Dark"; } else if (uiTheme == "#FFFFFFFF") { defaultWinTheme = "Light"; } return(defaultWinTheme); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { // this.DebugSettings.EnableFrameRateCounter = true; } #endif #if !HAS_UNO var userSettings = new Windows.UI.ViewManagement.UISettings(); m_isAnimationEnabled = userSettings.AnimationsEnabled; #endif Frame rootFrame = Windows.UI.Xaml.Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Windows.UI.Xaml.Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Windows.UI.Xaml.Window.Current.Activate(); } }
private void AutoReload() { var support = Environment.OSVersion.Version.Major >= new Version(10, 0).Major; Logger.WoxInfo($"Runtime Version {Environment.OSVersion.Version} {support}"); if (support) { var uiSettings = new Windows.UI.ViewManagement.UISettings(); uiSettings.ColorValuesChanged += (sender, args) => { Application.Current.Dispatcher.Invoke( () => { ChangeTheme(Settings.Theme); }); }; UISettings = uiSettings; } }
private void ViewModelOnOpenWebView(string html, int id) { _currentId = id; var uiSettings = new Windows.UI.ViewManagement.UISettings(); var color = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent); var color1 = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.AccentDark2); var color2 = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.AccentLight2); var css = Css.Replace("AccentColourBase", "#" + color.ToString().Substring(3)). Replace("AccentColourLight", "#" + color2.ToString().Substring(3)). Replace("AccentColourDark", "#" + color1.ToString().Substring(3)) .Replace("BodyBackgroundThemeColor", Settings.SelectedTheme == ApplicationTheme.Dark ? "#2d2d2d" : "#e6e6e6") .Replace("BodyForegroundThemeColor", Settings.SelectedTheme == ApplicationTheme.Dark ? "white" : "black").Replace( "HorizontalSeparatorColor", Settings.SelectedTheme == ApplicationTheme.Dark ? "#0d0d0d" : "#b3b3b3"); ArticleWebView.NavigateToString(css + Begin + html + "</div></body></html>"); }
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) { localSettings.Values["theme"] = "Default"; } 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 CreateEventPage() { this.InitializeComponent(); Loaded += CreateEventPage_Loaded; Windows.UI.ViewManagement.UISettings settings = new Windows.UI.ViewManagement.UISettings(); HorizontalAlignment alignment = (settings.HandPreference == Windows.UI.ViewManagement.HandPreference.RightHanded) ? HorizontalAlignment.Left : HorizontalAlignment.Right; EventInkToolbar.HorizontalAlignment = alignment; EventInkNote.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Touch | Windows.UI.Core.CoreInputDeviceTypes.Pen; }
private Windows.UI.Xaml.ElementTheme GetAppTheme() { var appTheme = Windows.UI.Xaml.ElementTheme.Default; var savedTheme = Windows.Storage.ApplicationData.Current.LocalSettings.Values["theme"]?.ToString(); if (!string.IsNullOrEmpty(savedTheme)) { Enum.TryParse(savedTheme, out appTheme); } if (appTheme == Windows.UI.Xaml.ElementTheme.Default) { var settings = new Windows.UI.ViewManagement.UISettings(); appTheme = settings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString() switch { "#FFFFFFFF" => Windows.UI.Xaml.ElementTheme.Light, "#FF000000" => Windows.UI.Xaml.ElementTheme.Dark, _ => Windows.UI.Xaml.ElementTheme.Default // Unknown theme }; } return(appTheme); }
/// <summary> /// Инициализирует одноэлементный объект приложения. Это первая выполняемая строка разрабатываемого /// кода; поэтому она является логическим эквивалентом main() или WinMain(). /// </summary> public App() { var uiSettings = new Windows.UI.ViewManagement.UISettings(); Color color = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background); //System.Diagnostics.Debug.WriteLine("color:" + color.ToString()); if (color.ToString() == "#FF000000") { this.RequestedTheme = ApplicationTheme.Dark; } else { this.RequestedTheme = ApplicationTheme.Light; } //ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; //localSettings.Values.Clear(); this.InitializeComponent(); this.Suspending += OnSuspending; }
private async void UiSettings_AdvancedEffectsEnabledChangedAsync(Windows.UI.ViewManagement.UISettings sender, object args) { if (sender.AdvancedEffectsEnabled) { await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { //TODO: Apply Acrylic Accent applyAcrylicAccent(transparentArea); makeButtonsTranslucent(); }); } else { await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { //TODO: Reset Background disableAcrylicAccent(transparentArea); makeButtonsOpaque(); }); } }
private void SetPropertiesFromLocalSettings() { 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; } else if (localSettings.Values["theme"].ToString() == "Dark") { SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.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; } else { SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Dark; } } } this.RequestedTheme = SettingsPages.Personalization.TV.ThemeValue; }
public object Convert(object value, Type targetType, object parameter, string language) { bool isEnabled = (bool)value; var defaultTheme = new Windows.UI.ViewManagement.UISettings(); // Using InvariantCulture as this is an internal string and expected to be in hexadecimal var uiTheme = defaultTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString(CultureInfo.InvariantCulture); // Normalize strings to uppercase according to Fxcop selectedTheme = SettingsRepository <GeneralSettings> .GetInstance(settingsUtils).SettingsConfig.Theme.ToUpperInvariant(); if (selectedTheme == "DARK" || (selectedTheme == "SYSTEM" && uiTheme == "#FF000000")) { // DARK if (isEnabled) { return((SolidColorBrush)Application.Current.Resources["DarkForegroundBrush"]); } else { return((SolidColorBrush)Application.Current.Resources["DarkForegroundDisabledBrush"]); } } else { // LIGHT if (isEnabled) { return((SolidColorBrush)Application.Current.Resources["LightForegroundBrush"]); } else { return((SolidColorBrush)Application.Current.Resources["LightForegroundDisabledBrush"]); } } }
private void ViewModelOnOpenWebView(string html, MalNewsUnitModel item) { //BackNav ViewModelLocator.NavMgr.RegisterBackNav(PageIndex.PageArticles, item.Type == MalNewsType.Article ? MalArticlesPageNavigationArgs.Articles : MalArticlesPageNavigationArgs.News); // _currentId = ViewModel.Articles.IndexOf(item); var uiSettings = new Windows.UI.ViewManagement.UISettings(); var color = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent); var color1 = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.AccentDark2); var color2 = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.AccentLight2); var css = Css.Replace("AccentColourBase", "#" + color.ToString().Substring(3)). Replace("AccentColourLight", "#" + color2.ToString().Substring(3)). Replace("AccentColourDark", "#" + color1.ToString().Substring(3)) .Replace("BodyBackgroundThemeColor", Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#2d2d2d" : "#e6e6e6") .Replace("BodyForegroundThemeColor", Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "white" : "black").Replace( "HorizontalSeparatorColor", Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#0d0d0d" : "#b3b3b3"); ArticleWebView.NavigateToString(css + Begin + html + "</div></body></html>"); }
private void ViewModelOnOpenWebView(string html,int id) { //BackNav ViewModelLocator.NavMgr.RegisterBackNav(PageIndex.PageArticles, ViewModel.Articles[id].Type == MalNewsType.Article ? MalArticlesPageNavigationArgs.Articles : MalArticlesPageNavigationArgs.News); // _currentId = id; var uiSettings = new Windows.UI.ViewManagement.UISettings(); var color = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent); var color1 = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.AccentDark2); var color2 = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.AccentLight2); var css = Css.Replace("AccentColourBase", "#" + color.ToString().Substring(3)). Replace("AccentColourLight", "#" + color2.ToString().Substring(3)). Replace("AccentColourDark", "#" + color1.ToString().Substring(3)) .Replace("BodyBackgroundThemeColor", Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#2d2d2d" : "#e6e6e6") .Replace("BodyForegroundThemeColor", Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "white" : "black").Replace( "HorizontalSeparatorColor", Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#0d0d0d" : "#b3b3b3"); ArticleWebView.NavigateToString(css + Begin + html + "</div></body></html>"); }
private void GetTheme() { _systemTheme = new Windows.UI.ViewManagement.UISettings(); _uiTheme = _systemTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString(); _appTheme = ThemeSelectorService.Theme; }
public App() { this.InitializeComponent(); exceptionDialog = new Dialogs.ExceptionDialog(); 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; } else if (localSettings.Values["theme"].ToString() == "Dark") { SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.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; } else { SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Dark; } } } this.RequestedTheme = SettingsPages.Personalization.TV.ThemeValue; if (localSettings.Values["FavoritesDisplayed_Start"] == null) { localSettings.Values["FavoritesDisplayed_Start"] = true; } if (localSettings.Values["RecentsDisplayed_Start"] == null) { localSettings.Values["RecentsDisplayed_Start"] = true; } if (localSettings.Values["DrivesDisplayed_Start"] == null) { localSettings.Values["DrivesDisplayed_Start"] = false; } if (localSettings.Values["FavoritesDisplayed_NewTab"] == null) { localSettings.Values["FavoritesDisplayed_NewTab"] = true; } if (localSettings.Values["RecentsDisplayed_NewTab"] == null) { localSettings.Values["RecentsDisplayed_NewTab"] = true; } if (localSettings.Values["DrivesDisplayed_NewTab"] == null) { localSettings.Values["DrivesDisplayed_NewTab"] = false; } PopulatePinnedSidebarItems(); }
private void LoadUI() { //主题 cbTheme.SelectedIndex = SettingHelper.GetValue <int>(SettingHelper.UI.THEME, 0); cbTheme.Loaded += new RoutedEventHandler((sender, e) => { cbTheme.SelectionChanged += new SelectionChangedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.THEME, cbTheme.SelectedIndex); Frame rootFrame = Window.Current.Content as Frame; switch (cbTheme.SelectedIndex) { case 1: rootFrame.RequestedTheme = ElementTheme.Light; break; case 2: rootFrame.RequestedTheme = ElementTheme.Dark; break; default: rootFrame.RequestedTheme = ElementTheme.Default; break; } App.ExtendAcrylicIntoTitleBar(); }); }); cbColor.SelectedIndex = SettingHelper.GetValue <int>(SettingHelper.UI.THEME_COLOR, 0); cbColor.Loaded += new RoutedEventHandler((sender, e) => { cbColor.SelectionChanged += new SelectionChangedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.THEME_COLOR, cbColor.SelectedIndex); Color color = new Color(); if (cbColor.SelectedIndex == 0) { var uiSettings = new Windows.UI.ViewManagement.UISettings(); color = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent); } else { color = Utils.ToColor((cbColor.SelectedItem as AppThemeColor).color); } (Application.Current.Resources["SystemControlHighlightAltAccentBrush"] as SolidColorBrush).Color = color; (Application.Current.Resources["SystemControlHighlightAccentBrush"] as SolidColorBrush).Color = color; //(App.Current.Resources.ThemeDictionaries["Light"] as ResourceDictionary)["SystemAccentColor"] = Utils.ToColor(item.color); }); }); //显示模式 cbDisplayMode.SelectedIndex = SettingHelper.GetValue <int>(SettingHelper.UI.DISPLAY_MODE, 0); cbDisplayMode.Loaded += new RoutedEventHandler((sender, e) => { cbDisplayMode.SelectionChanged += new SelectionChangedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.DISPLAY_MODE, cbDisplayMode.SelectedIndex); if (cbDisplayMode.SelectedIndex == 2) { Utils.ShowMessageToast("多窗口模式正在开发测试阶段,可能会有一堆问题"); } else { Utils.ShowMessageToast("重启生效"); } }); }); //加载原图 swPictureQuality.IsOn = SettingHelper.GetValue <bool>(SettingHelper.UI.ORTGINAL_IMAGE, false); swPictureQuality.Loaded += new RoutedEventHandler((sender, e) => { swPictureQuality.Toggled += new RoutedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.ORTGINAL_IMAGE, swPictureQuality.IsOn); SettingHelper.UI._loadOriginalImage = null; }); }); //缓存页面 swHomeCache.IsOn = SettingHelper.GetValue <bool>(SettingHelper.UI.CACHE_HOME, true); swHomeCache.Loaded += new RoutedEventHandler((sender, e) => { swHomeCache.Toggled += new RoutedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.CACHE_HOME, swHomeCache.IsOn); }); }); //右侧详情宽度 numRightWidth.Value = SettingHelper.GetValue <double>(SettingHelper.UI.RIGHT_DETAIL_WIDTH, 320); numRightWidth.Loaded += new RoutedEventHandler((sender, e) => { numRightWidth.ValueChanged += new TypedEventHandler <NumberBox, NumberBoxValueChangedEventArgs>((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.RIGHT_DETAIL_WIDTH, args.NewValue); }); }); //图片圆角半径 numImageCornerRadius.Value = SettingHelper.GetValue <double>(SettingHelper.UI.IMAGE_CORNER_RADIUS, 0); ImageCornerRadiusExample.CornerRadius = new CornerRadius(numImageCornerRadius.Value); numImageCornerRadius.Loaded += new RoutedEventHandler((sender, e) => { numImageCornerRadius.ValueChanged += new TypedEventHandler <NumberBox, NumberBoxValueChangedEventArgs>((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.IMAGE_CORNER_RADIUS, args.NewValue); ImageCornerRadiusExample.CornerRadius = new CornerRadius(args.NewValue); App.Current.Resources["ImageCornerRadius"] = new CornerRadius(args.NewValue); }); }); //显示视频封面 swVideoDetailShowCover.IsOn = SettingHelper.GetValue <bool>(SettingHelper.UI.SHOW_DETAIL_COVER, true); swVideoDetailShowCover.Loaded += new RoutedEventHandler((sender, e) => { swVideoDetailShowCover.Toggled += new RoutedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.SHOW_DETAIL_COVER, swVideoDetailShowCover.IsOn); }); }); //新窗口浏览图片 swPreviewImageOpenNewWindow.IsOn = SettingHelper.GetValue <bool>(SettingHelper.UI.NEW_WINDOW_PREVIEW_IMAGE, false); swPreviewImageOpenNewWindow.Loaded += new RoutedEventHandler((sender, e) => { swPreviewImageOpenNewWindow.Toggled += new RoutedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.NEW_WINDOW_PREVIEW_IMAGE, swPreviewImageOpenNewWindow.IsOn); }); }); //鼠标侧键返回 swMouseClosePage.IsOn = SettingHelper.GetValue <bool>(SettingHelper.UI.MOUSE_BACK, true); swMouseClosePage.Loaded += new RoutedEventHandler((sender, e) => { swMouseClosePage.Toggled += new RoutedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.MOUSE_BACK, swMouseClosePage.IsOn); }); }); //隐藏赞助图标 swHideSponsor.IsOn = SettingHelper.GetValue <bool>(SettingHelper.UI.HIDE_SPONSOR, false); swHideSponsor.Loaded += new RoutedEventHandler((sender, e) => { swHideSponsor.Toggled += new RoutedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.HIDE_SPONSOR, swHideSponsor.IsOn); }); }); //动态显示 cbDetailDisplay.SelectedIndex = SettingHelper.GetValue <int>(SettingHelper.UI.DETAIL_DISPLAY, 0); cbDetailDisplay.Loaded += new RoutedEventHandler((sender, e) => { cbDetailDisplay.SelectionChanged += new SelectionChangedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.DETAIL_DISPLAY, cbDetailDisplay.SelectedIndex); }); }); //动态显示 cbDynamicDisplayMode.SelectedIndex = SettingHelper.GetValue <int>(SettingHelper.UI.DYNAMIC_DISPLAY_MODE, 0); cbDynamicDisplayMode.Loaded += new RoutedEventHandler((sender, e) => { cbDynamicDisplayMode.SelectionChanged += new SelectionChangedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.DYNAMIC_DISPLAY_MODE, cbDynamicDisplayMode.SelectedIndex); }); }); //推荐显示 cbRecommendDisplayMode.SelectedIndex = SettingHelper.GetValue <int>(SettingHelper.UI.RECMEND_DISPLAY_MODE, 0); cbRecommendDisplayMode.Loaded += new RoutedEventHandler((sender, e) => { cbRecommendDisplayMode.SelectionChanged += new SelectionChangedEventHandler((obj, args) => { SettingHelper.SetValue(SettingHelper.UI.RECMEND_DISPLAY_MODE, cbRecommendDisplayMode.SelectedIndex); }); }); gridHomeCustom.ItemsSource = SettingHelper.GetValue <ObservableCollection <HomeNavItem> >(SettingHelper.UI.HOEM_ORDER, HomeVM.GetAllNavItems()); ExceptHomeNavItems(); }