public static void UpdateTheme(ThemeAccents accent, ThemeBaseColors baseColor) { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(accent.ToString()), ThemeManager.GetAppTheme(baseColor.ToString())); }
private void ChangeAppAccentButtonClick(object sender, RoutedEventArgs e) { var theme = ThemeManager.DetectAppStyle(Application.Current); ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(((Button)sender).Content.ToString()), theme.Item1); }
private void CustomAccent2AppButtonClick(object sender, RoutedEventArgs e) { var theme = ThemeManager.DetectAppStyle(Application.Current); ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("CustomAccent2"), theme.Item1); }
private void ChangeThemeAndAccent(string theme, string accent) { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(accent), ThemeManager.GetAppTheme(theme)); }
private void comboBoxTheme_SelectionChanged(object sender, SelectionChangedEventArgs e) { ThemeManager.ChangeAppStyle(this, ThemeManager.GetAccent((string)comboBoxTheme.SelectedItem), ThemeManager.GetAppTheme("BaseLight")); Launcher_Namespace.Properties.Settings.Default.Color = (string)comboBoxTheme.SelectedItem; Launcher_Namespace.Properties.Settings.Default.Save(); }
public void ChangeAccentColor() { ThemeManager.ChangeAppStyle(Application.Current, _accent, ThemeManager.DetectAppStyle().Item1); }
private void ChangeTheme(string themeName) { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(currentAccent), ThemeManager.GetAppTheme(themeName)); currentTheme = themeName; }
private void Application_Startup(object sender, StartupEventArgs e) { #region 检查环境 if ((System.Environment.Version.Major == 4) && (System.Environment.Version.Minor == 0)) { if ((!SystemTools.IsSetupFrameworkUpdate("KB2468871v2")) && (!SystemTools.IsSetupFrameworkUpdate("KB2468871"))) { var result = MessageBox.Show(GetResourceString("String.Message.NoFrameworkUpdate2"), GetResourceString("String.Message.NoFrameworkUpdate"), MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { System.Diagnostics.Process.Start("https://github.com/Nsiso/NsisoLauncher/wiki/%E5%90%AF%E5%8A%A8%E5%99%A8%E6%8A%A5%E9%94%99%EF%BC%9A%E5%BD%93%E5%89%8D%E7%94%B5%E8%84%91%E7%8E%AF%E5%A2%83%E7%BC%BA%E5%B0%91KB2468871v2%E8%A1%A5%E4%B8%81"); System.Environment.Exit(0); } } } #endregion #region DEBUG初始化 //debug logHandler = new LogHandler(true); AggregateExceptionCatched += (a, b) => logHandler.AppendFatal(b.AggregateException); if (e.Args.Contains("-debug")) { Windows.DebugWindow debugWindow = new Windows.DebugWindow(); debugWindow.Show(); logHandler.OnLog += (s, log) => debugWindow?.AppendLog(s, log); } #endregion config = new ConfigHandler(); #region DEBUG初始化(基于配置文件) if (config.MainConfig.Launcher.Debug && !e.Args.Contains("-debug")) { Windows.DebugWindow debugWindow = new Windows.DebugWindow(); debugWindow.Show(); logHandler.OnLog += (s, log) => debugWindow?.AppendLog(s, log); } #endregion #region 数据初始化 Config.Environment env = config.MainConfig.Environment; javaList = Java.GetJavaList(); //设置版本路径 string gameroot = null; switch (env.GamePathType) { case GameDirEnum.ROOT: gameroot = Path.GetFullPath(".minecraft"); break; case GameDirEnum.APPDATA: gameroot = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\.minecraft"; break; case GameDirEnum.PROGRAMFILES: gameroot = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles) + "\\.minecraft"; break; case GameDirEnum.CUSTOM: gameroot = env.GamePath + "\\.minecraft"; break; default: throw new ArgumentException("判断游戏目录类型时出现异常,请检查配置文件中GamePathType节点"); } logHandler.AppendInfo("核心初始化->游戏根目录(默认则为空):" + gameroot); //设置JAVA Java java = null; if (env.AutoJava) { java = Java.GetSuitableJava(javaList); } else { java = javaList.Find(x => x.Path == env.JavaPath); if (java == null) { java = Java.GetJavaInfo(env.JavaPath); } } if (java != null) { env.JavaPath = java.Path; logHandler.AppendInfo("核心初始化->Java路径:" + java.Path); logHandler.AppendInfo("核心初始化->Java版本:" + java.Version); logHandler.AppendInfo("核心初始化->Java位数:" + java.Arch); } else { logHandler.AppendWarn("核心初始化失败,当前电脑未匹配到JAVA"); } //设置版本独立 bool verIso = config.MainConfig.Environment.VersionIsolation; #endregion #region 启动核心初始化 handler = new LaunchHandler(gameroot, java, verIso); handler.GameLog += (s, log) => logHandler.AppendLog(s, new Log() { LogLevel = LogLevel.GAME, Message = log }); #endregion #region 载核心初始化 ServicePointManager.DefaultConnectionLimit = 10; Download downloadCfg = config.MainConfig.Download; downloader = new MultiThreadDownloader(); if (!string.IsNullOrWhiteSpace(downloadCfg.DownloadProxyAddress)) { WebProxy proxy = new WebProxy(downloadCfg.DownloadProxyAddress, downloadCfg.DownloadProxyPort); if (!string.IsNullOrWhiteSpace(downloadCfg.ProxyUserName)) { NetworkCredential credential = new NetworkCredential(downloadCfg.ProxyUserName, downloadCfg.ProxyUserPassword); proxy.Credentials = credential; } downloader.Proxy = proxy; } downloader.ProcessorSize = App.config.MainConfig.Download.DownloadThreadsSize; downloader.DownloadLog += (s, log) => logHandler?.AppendLog(s, log); #endregion #region NIDE8核心初始化 if (!string.IsNullOrWhiteSpace(config.MainConfig.User.Nide8ServerID)) { nide8Handler = new NsisoLauncherCore.Net.Nide8API.APIHandler(config.MainConfig.User.Nide8ServerID); nide8Handler.UpdateBaseURL(); } #endregion #region 自定义主题初始化 var custom = config.MainConfig.Customize; if (!string.IsNullOrWhiteSpace(custom.AccentColor) && !string.IsNullOrWhiteSpace(custom.AppThme)) { logHandler.AppendInfo("自定义->更改主题颜色:" + custom.AccentColor); logHandler.AppendInfo("自定义->更改主题:" + custom.AppThme); ThemeManager.ChangeAppStyle(Current, ThemeManager.GetAccent(custom.AccentColor), ThemeManager.GetAppTheme(custom.AppThme)); } #endregion //debug //throw new Exception(); }
private void comboBox_accent_SelectionChanged(object sender, SelectionChangedEventArgs e) { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(Settings.Accents[comboBox_accent.SelectedIndex]), ThemeManager.GetAppTheme("BaseLight")); Settings.Accent = comboBox_accent.SelectedIndex; }
private void GreenButtonClick(object sender, RoutedEventArgs e) { currentAccent = ThemeManager.DefaultAccents.First(x => x.Name == "Green"); ThemeManager.ChangeAppStyle(Application.Current, currentAccent, currentTheme); }
private void LoadConfig() { if (Config.Instance.TrackerWindowTop.HasValue) { Top = Config.Instance.TrackerWindowTop.Value; } if (Config.Instance.TrackerWindowLeft.HasValue) { Left = Config.Instance.TrackerWindowLeft.Value; } if (Config.Instance.WindowHeight < 0) { Config.Instance.Reset("WindowHeight"); } Height = Config.Instance.WindowHeight; if (Config.Instance.WindowWidth < 0) { Config.Instance.Reset("WindowWidth"); } Width = Config.Instance.WindowWidth; var titleBarCorners = new[] { new Point((int)Left + 5, (int)Top + 5), new Point((int)(Left + Width) - 5, (int)Top + 5), new Point((int)Left + 5, (int)(Top + TitlebarHeight) - 5), new Point((int)(Left + Width) - 5, (int)(Top + TitlebarHeight) - 5) }; if (!Screen.AllScreens.Any(s => titleBarCorners.Any(c => s.WorkingArea.Contains(c)))) { Top = 100; Left = 100; } if (Config.Instance.StartMinimized) { WindowState = WindowState.Minimized; if (Config.Instance.MinimizeToTray) { MinimizeToTray(); } } var theme = string.IsNullOrEmpty(Config.Instance.ThemeName) ? ThemeManager.DetectAppStyle().Item1 : ThemeManager.AppThemes.First(t => t.Name == Config.Instance.ThemeName); var accent = string.IsNullOrEmpty(Config.Instance.AccentName) ? ThemeManager.DetectAppStyle().Item2 : ThemeManager.Accents.First(a => a.Name == Config.Instance.AccentName); ThemeManager.ChangeAppStyle(Application.Current, accent, theme); Options.Load(); Game.HighlightCardsInHand = Config.Instance.HighlightCardsInHand; Game.HighlightDiscarded = Config.Instance.HighlightDiscarded; CheckboxDeckDetection.IsChecked = Config.Instance.AutoDeckDetection; SetContextMenuProperty("autoSelectDeck", "Checked", (bool)CheckboxDeckDetection.IsChecked); // Don't select the 'archived' class on load var selectedClasses = Config.Instance.SelectedDeckPickerClasses.Where(c => c.ToString() != "Archived").ToList(); if (selectedClasses.Count == 0) { selectedClasses.Add(HeroClassAll.All); } DeckPickerList.SelectClasses(selectedClasses); DeckPickerList.SelectDeckType(Config.Instance.SelectedDeckType, true); SortFilterDecksFlyout.LoadTags(DeckList.Instance.AllTags); UpdateQuickFilterItemSource(); SortFilterDecksFlyout.SetSelectedTags(Config.Instance.SelectedTags); TagControlEdit.LoadTags(DeckList.Instance.AllTags.Where(tag => tag != "All" && tag != "None").ToList()); SortFilterDecksFlyout.OperationSwitch.IsChecked = Config.Instance.TagOperation == TagFilerOperation.And; SortFilterDecksFlyout.ComboboxDeckSorting.SelectedItem = Config.Instance.SelectedDeckSorting; if (!EventKeys.Contains(Config.Instance.KeyPressOnGameStart)) { Config.Instance.KeyPressOnGameStart = "None"; } if (!EventKeys.Contains(Config.Instance.KeyPressOnGameEnd)) { Config.Instance.KeyPressOnGameEnd = "None"; } ManaCurveMyDecks.Visibility = Config.Instance.ManaCurveMyDecks ? Visibility.Visible : Visibility.Collapsed; ManaCurveMyDecks.ListViewStatType.SelectedIndex = (int)Config.Instance.ManaCurveFilter; CheckboxClassCardsFirst.IsChecked = Config.Instance.CardSortingClassFirst; SetContextMenuProperty("classCardsFirst", "Checked", (bool)CheckboxClassCardsFirst.IsChecked); SetContextMenuProperty("useNoDeck", "Checked", DeckList.Instance.ActiveDeck == null); DeckStatsFlyout.LoadConfig(); GameDetailsFlyout.LoadConfig(); StatsWindow.StatsControl.LoadConfig(); StatsWindow.GameDetailsFlyout.LoadConfig(); MenuItemCheckBoxSyncOnStart.IsChecked = Config.Instance.HearthStatsSyncOnStart; MenuItemCheckBoxAutoUploadDecks.IsChecked = Config.Instance.HearthStatsAutoUploadNewDecks; MenuItemCheckBoxAutoUploadGames.IsChecked = Config.Instance.HearthStatsAutoUploadNewGames; MenuItemCheckBoxAutoSyncBackground.IsChecked = Config.Instance.HearthStatsAutoSyncInBackground; MenuItemCheckBoxAutoDeleteDecks.IsChecked = Config.Instance.HearthStatsAutoDeleteDecks; MenuItemCheckBoxAutoDeleteGames.IsChecked = Config.Instance.HearthStatsAutoDeleteMatches; }
private void LightButtonClick(object sender, RoutedEventArgs e) { currentTheme = ThemeManager.DefaultAppThemes.First(x => x.Name == "BaseLight"); ThemeManager.ChangeAppStyle(Application.Current, currentAccent, currentTheme); }
public MainWindow() { InitializeComponent(); ThemeManager.ChangeAppStyle(Application.Current, currentAccent, currentTheme); }
private void ChangeTheme() { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(SelectedAccent), ThemeManager.GetAppTheme(SelectedTheme)); }
/// <summary> /// Will change app style /// </summary> public void ChangeAppStyle(string accent, string appTheme) { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(accent), ThemeManager.GetAppTheme(appTheme)); }
public static void CreateWindowsAccentStyle(bool changeImmediately = false) { var resourceDictionary = new ResourceDictionary(); var color = SystemParameters.WindowGlassColor; resourceDictionary.Add("HighlightColor", color); resourceDictionary.Add("AccentColor", Color.FromArgb(204, color.R, color.G, color.B)); resourceDictionary.Add("AccentColor2", Color.FromArgb(153, color.R, color.G, color.B)); resourceDictionary.Add("AccentColor3", Color.FromArgb(102, color.R, color.G, color.B)); resourceDictionary.Add("AccentColor4", Color.FromArgb(51, color.R, color.G, color.B)); resourceDictionary.Add("HighlightBrush", new SolidColorBrush((Color)resourceDictionary["HighlightColor"])); resourceDictionary.Add("AccentColorBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("AccentColorBrush2", new SolidColorBrush((Color)resourceDictionary["AccentColor2"])); resourceDictionary.Add("AccentColorBrush3", new SolidColorBrush((Color)resourceDictionary["AccentColor3"])); resourceDictionary.Add("AccentColorBrush4", new SolidColorBrush((Color)resourceDictionary["AccentColor4"])); resourceDictionary.Add("WindowTitleColorBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("ProgressBrush", new LinearGradientBrush(new GradientStopCollection(new[] { new GradientStop((Color)resourceDictionary["HighlightColor"], 0), new GradientStop((Color)resourceDictionary["AccentColor3"], 1) }), new Point(0.001, 0.5), new Point(1.002, 0.5))); resourceDictionary.Add("CheckmarkFill", new SolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("RightArrowFill", new SolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("IdealForegroundColor", Colors.White); resourceDictionary.Add("IdealForegroundColorBrush", new SolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("AccentSelectedColorBrush", new SolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("MetroDataGrid.HighlightBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("MetroDataGrid.HighlightTextBrush", new SolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("MetroDataGrid.MouseOverHighlightBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor3"])); resourceDictionary.Add("MetroDataGrid.FocusBorderBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("MetroDataGrid.InactiveSelectionHighlightBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor2"])); resourceDictionary.Add("MetroDataGrid.InactiveSelectionHighlightTextBrush", new SolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); var fileName = Path.Combine(Config.Instance.ConfigDir, "WindowsAccent.xaml"); try { using (var stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite)) using (var writer = XmlWriter.Create(stream, new XmlWriterSettings { Indent = true })) XamlWriter.Save(resourceDictionary, writer); } catch (Exception e) { Log.Error("Error creating WindowsAccent: " + e); return; } resourceDictionary = new ResourceDictionary { Source = new Uri(fileName, UriKind.Absolute) }; ThemeManager.AddAccent(WindowAccentName, resourceDictionary.Source); var oldWindowsAccent = ThemeManager.GetAccent(WindowAccentName); oldWindowsAccent.Resources.Source = resourceDictionary.Source; if (changeImmediately) { ThemeManager.ChangeAppStyle(Application.Current, CurrentAccent, CurrentTheme); } }
private void LoadConfig() { if (Config.Instance.TrackerWindowTop.HasValue) { Top = Config.Instance.TrackerWindowTop.Value; } if (Config.Instance.TrackerWindowLeft.HasValue) { Left = Config.Instance.TrackerWindowLeft.Value; } if (Config.Instance.WindowHeight < 0) { Config.Instance.Reset("WindowHeight"); } Height = Config.Instance.WindowHeight; if (Config.Instance.WindowWidth < 0) { Config.Instance.Reset("WindowWidth"); } Width = Config.Instance.WindowWidth; var titleBarCorners = new[] { new Point((int)Left + 5, (int)Top + 5), new Point((int)(Left + Width) - 5, (int)Top + 5), new Point((int)Left + 5, (int)(Top + TitlebarHeight) - 5), new Point((int)(Left + Width) - 5, (int)(Top + TitlebarHeight) - 5) }; if (!Screen.AllScreens.Any(s => titleBarCorners.Any(c => s.WorkingArea.Contains(c)))) { Top = 100; Left = 100; } if (Config.Instance.StartMinimized) { WindowState = WindowState.Minimized; if (Config.Instance.MinimizeToTray) { MinimizeToTray(); } } var theme = string.IsNullOrEmpty(Config.Instance.ThemeName) ? ThemeManager.DetectAppStyle().Item1 : ThemeManager.AppThemes.First(t => t.Name == Config.Instance.ThemeName); var accent = string.IsNullOrEmpty(Config.Instance.AccentName) ? ThemeManager.DetectAppStyle().Item2 : ThemeManager.Accents.First(a => a.Name == Config.Instance.AccentName); ThemeManager.ChangeAppStyle(Application.Current, accent, theme); Options.Load(); Game.HighlightCardsInHand = Config.Instance.HighlightCardsInHand; Game.HighlightDiscarded = Config.Instance.HighlightDiscarded; //Options.CheckboxHideOverlayInBackground.IsChecked = Config.Instance.HideInBackground; //Options.CheckboxHideOpponentCardAge.IsChecked = Config.Instance.HideOpponentCardAge; //Options.CheckboxHideOpponentCardMarks.IsChecked = Config.Instance.HideOpponentCardMarks; //Options.CheckboxHideOverlayInMenu.IsChecked = Config.Instance.HideInMenu; //Options.CheckboxHighlightCardsInHand.IsChecked = Config.Instance.HighlightCardsInHand; //Options.CheckboxHideOverlay.IsChecked = Config.Instance.HideOverlay; //Options.CheckboxHideDecksInOverlay.IsChecked = Config.Instance.HideDecksInOverlay; //Options.CheckboxKeepDecksVisible.IsChecked = Config.Instance.KeepDecksVisible; //Options.CheckboxMinimizeTray.IsChecked = Config.Instance.MinimizeToTray; //Options.CheckboxWindowsTopmost.IsChecked = Config.Instance.WindowsTopmost; //Options.CheckboxPlayerWindowOpenAutomatically.IsChecked = Config.Instance.PlayerWindowOnStart; //Options.CheckboxOpponentWindowOpenAutomatically.IsChecked = Config.Instance.OpponentWindowOnStart; //Options.CheckboxTimerTopmost.IsChecked = Config.Instance.TimerWindowTopmost; //Options.CheckboxTimerWindow.IsChecked = Config.Instance.TimerWindowOnStartup; //Options.CheckboxTimerTopmostHsForeground.IsChecked = Config.Instance.TimerWindowTopmostIfHsForeground; //Options.CheckboxTimerTopmostHsForeground.IsEnabled = Config.Instance.TimerWindowTopmost; //Options.CheckboxSameScaling.IsChecked = Config.Instance.UseSameScaling; CheckboxDeckDetection.IsChecked = Config.Instance.AutoDeckDetection; //Options.CheckboxWinTopmostHsForeground.IsChecked = Config.Instance.WindowsTopmostIfHsForeground; //Options.CheckboxWinTopmostHsForeground.IsEnabled = Config.Instance.WindowsTopmost; //Options.CheckboxAutoSelectDeck.IsEnabled = Config.Instance.AutoDeckDetection; //Options.CheckboxAutoSelectDeck.IsChecked = Config.Instance.AutoSelectDetectedDeck; //Options.CheckboxExportName.IsChecked = Config.Instance.ExportSetDeckName; //Options.CheckboxPrioGolden.IsChecked = Config.Instance.PrioritizeGolden; //Options.CheckboxBringHsToForegorund.IsChecked = Config.Instance.BringHsToForeground; //Options.CheckboxFlashHs.IsChecked = Config.Instance.FlashHsOnTurnStart; //Options.CheckboxHideSecrets.IsChecked = Config.Instance.HideSecrets; //Options.CheckboxHighlightDiscarded.IsChecked = Config.Instance.HighlightDiscarded; //Options.CheckboxRemoveCards.IsChecked = Config.Instance.RemoveCardsFromDeck; //Options.CheckboxHighlightLastDrawn.IsChecked = Config.Instance.HighlightLastDrawn; //Options.CheckboxStartMinimized.IsChecked = Config.Instance.StartMinimized; //Options.CheckboxShowPlayerGet.IsChecked = Config.Instance.ShowPlayerGet; //Options.ToggleSwitchExtraFeatures.IsChecked = Config.Instance.ExtraFeatures; //Options.CheckboxCheckForUpdates.IsChecked = Config.Instance.CheckForUpdates; //Options.CheckboxRecordArena.IsChecked = Config.Instance.RecordArena; //Options.CheckboxRecordCasual.IsChecked = Config.Instance.RecordCasual; //Options.CheckboxRecordFriendly.IsChecked = Config.Instance.RecordFriendly; //Options.CheckboxRecordOther.IsChecked = Config.Instance.RecordOther; //Options.CheckboxRecordPractice.IsChecked = Config.Instance.RecordPractice; //Options.CheckboxRecordRanked.IsChecked = Config.Instance.RecordRanked; //Options.CheckboxFullTextSearch.IsChecked = Config.Instance.UseFullTextSearch; //Options.CheckboxDiscardGame.IsChecked = Config.Instance.DiscardGameIfIncorrectDeck; //Options.CheckboxExportPasteClipboard.IsChecked = Config.Instance.ExportPasteClipboard; //Options.CheckboxGoldenFeugen.IsChecked = Config.Instance.OwnsGoldenFeugen; //Options.CheckboxGoldenStalagg.IsChecked = Config.Instance.OwnsGoldenStalagg; //Options.CheckboxCloseWithHearthstone.IsChecked = Config.Instance.CloseWithHearthstone; //Options.CheckboxStatsInWindow.IsChecked = Config.Instance.StatsInWindow; //Options.CheckboxOverlaySecretToolTipsOnly.IsChecked = Config.Instance.OverlaySecretToolTipsOnly; //Options.CheckboxTagOnImport.IsChecked = Config.Instance.TagDecksOnImport; //Options.CheckboxConfigSaveAppData.IsChecked = Config.Instance.SaveConfigInAppData; //Options.CheckboxDataSaveAppData.IsChecked = Config.Instance.SaveDataInAppData; //Options.CheckboxAdvancedWindowSearch.IsChecked = Config.Instance.AdvancedWindowSearch; //Options.CheckboxDeleteDeckKeepStats.IsChecked = Config.Instance.KeepStatsWhenDeletingDeck; //Options.CheckboxNoteDialog.IsChecked = Config.Instance.ShowNoteDialogAfterGame; //Options.CheckboxAutoClear.IsChecked = Config.Instance.AutoClearDeck; //Options.CheckboxLogTab.IsChecked = Config.Instance.ShowLogTab; //Options.CheckboxTimerAlert.IsChecked = Config.Instance.TimerAlert; //Options.CheckboxRecordSpectator.IsChecked = Config.Instance.RecordSpectator; //Options.CheckboxHideOverlayInSpectator.IsChecked = Config.Instance.HideOverlayInSpectator; //Options.TextboxExportDelay.Text = Config.Instance.ExportStartDelay.ToString(); //Options.CheckboxDiscardZeroTurnGame.IsChecked = Config.Instance.DiscardZeroTurnGame; //Options.CheckboxSaveHSLogIntoReplayFile.IsChecked = Config.Instance.SaveHSLogIntoReplay; //Options.CheckboxNoteDialogDelayed.IsChecked = Config.Instance.NoteDialogDelayed; //Options.CheckboxNoteDialogDelayed.IsEnabled = Config.Instance.ShowNoteDialogAfterGame; //Options.CheckboxStartWithWindows.IsChecked = Config.Instance.StartWithWindows; //Options.CheckboxOverlayCardMarkToolTips.IsChecked = Config.Instance.OverlayCardMarkToolTips; //Options.ComboBoxLogLevel.SelectedValue = Config.Instance.LogLevel.ToString(); //Options.CheckBoxForceExtraFeatures.IsChecked = Config.Instance.ForceMouseHook; //Options.CheckBoxForceExtraFeatures.IsEnabled = Config.Instance.ExtraFeatures; //Options.CheckboxAutoGrayoutSecrets.IsChecked = Config.Instance.AutoGrayoutSecrets; //Options.CheckboxImportNetDeck.IsChecked = Config.Instance.NetDeckClipboardCheck ?? false; //Options.CheckboxAutoSaveOnImport.IsChecked = Config.Instance.AutoSaveOnImport; //Options.SliderOverlayOpacity.Value = Config.Instance.OverlayOpacity; //Options.SliderOpponentOpacity.Value = Config.Instance.OpponentOpacity; //Options.SliderPlayerOpacity.Value = Config.Instance.PlayerOpacity; //Options.SliderOverlayPlayerScaling.Value = Config.Instance.OverlayPlayerScaling; //Options.SliderOverlayOpponentScaling.Value = Config.Instance.OverlayOpponentScaling; //DeckPickerList.ShowAll = Config.Instance.ShowAllDecks; //DeckPickerList.SetSelectedTags(Config.Instance.SelectedTags); // Don't select the 'archived' class on load var selectedClasses = Config.Instance.SelectedDeckPickerClasses.Where(c => c.ToString() != "Archived").ToList(); if (selectedClasses.Count == 0) { selectedClasses.Add(HeroClassAll.All); } DeckPickerList.SelectClasses(selectedClasses); DeckPickerList.SelectDeckType(Config.Instance.SelectedDeckType, true); //Options.CheckboxHideTimers.IsChecked = Config.Instance.HideTimers; //var delay = Config.Instance.DeckExportDelay; //Options.ComboboxExportSpeed.SelectedIndex = delay < 40 ? 0 : delay < 60 ? 1 : delay < 100 ? 2 : delay < 150 ? 3 : 4; SortFilterDecksFlyout.LoadTags(DeckList.Instance.AllTags); UpdateQuickFilterItemSource(); SortFilterDecksFlyout.SetSelectedTags(Config.Instance.SelectedTags); //DeckPickerList.SetSelectedTags(Config.Instance.SelectedTags); TagControlEdit.LoadTags(DeckList.Instance.AllTags.Where(tag => tag != "All" && tag != "None").ToList()); //DeckPickerList.SetTagOperation(Config.Instance.TagOperation); SortFilterDecksFlyout.OperationSwitch.IsChecked = Config.Instance.TagOperation == TagFilerOperation.And; SortFilterDecksFlyout.ComboboxDeckSorting.SelectedItem = Config.Instance.SelectedDeckSorting; //Options.ComboboxWindowBackground.SelectedItem = Config.Instance.SelectedWindowBackground; //Options.TextboxCustomBackground.IsEnabled = Config.Instance.SelectedWindowBackground == "Custom"; //Options.TextboxCustomBackground.Text = string.IsNullOrEmpty(Config.Instance.WindowsBackgroundHex) // ? "#696969" : Config.Instance.WindowsBackgroundHex; //Options.UpdateAdditionalWindowsBackground(); //if(Helper.LanguageDict.Values.Contains(Config.Instance.SelectedLanguage)) // Options.ComboboxLanguages.SelectedItem = Helper.LanguageDict.First(x => x.Value == Config.Instance.SelectedLanguage).Key; if (!EventKeys.Contains(Config.Instance.KeyPressOnGameStart)) { Config.Instance.KeyPressOnGameStart = "None"; } //Options.ComboboxKeyPressGameStart.SelectedValue = Config.Instance.KeyPressOnGameStart; if (!EventKeys.Contains(Config.Instance.KeyPressOnGameEnd)) { Config.Instance.KeyPressOnGameEnd = "None"; } //Options.ComboboxKeyPressGameEnd.SelectedValue = Config.Instance.KeyPressOnGameEnd; //Options.CheckboxHideManaCurveMyDecks.IsChecked = Config.Instance.ManaCurveMyDecks; ManaCurveMyDecks.Visibility = Config.Instance.ManaCurveMyDecks ? Visibility.Visible : Visibility.Collapsed; //Options.CheckboxTrackerCardToolTips.IsChecked = Config.Instance.TrackerCardToolTips; //Options.CheckboxWindowCardToolTips.IsChecked = Config.Instance.WindowCardToolTips; //Options.CheckboxOverlayCardToolTips.IsChecked = Config.Instance.OverlayCardToolTips; //Options.CheckboxOverlayAdditionalCardToolTips.IsEnabled = Config.Instance.OverlayCardToolTips; //Options.CheckboxOverlayAdditionalCardToolTips.IsChecked = Config.Instance.AdditionalOverlayTooltips; CheckboxClassCardsFirst.IsChecked = Config.Instance.CardSortingClassFirst; DeckStatsFlyout.LoadConfig(); GameDetailsFlyout.LoadConfig(); StatsWindow.StatsControl.LoadConfig(); StatsWindow.GameDetailsFlyout.LoadConfig(); MenuItemImportArena.IsEnabled = Config.Instance.ShowArenaImportMessage; MenuItemImportConstructed.IsEnabled = Config.Instance.ShowConstructedImportMessage; MenuItemCheckBoxSyncOnStart.IsChecked = Config.Instance.HearthStatsSyncOnStart; MenuItemCheckBoxAutoUploadDecks.IsChecked = Config.Instance.HearthStatsAutoUploadNewDecks; MenuItemCheckBoxAutoUploadGames.IsChecked = Config.Instance.HearthStatsAutoUploadNewGames; MenuItemCheckBoxAutoSyncBackground.IsChecked = Config.Instance.HearthStatsAutoSyncInBackground; MenuItemCheckBoxAutoDeleteDecks.IsChecked = Config.Instance.HearthStatsAutoDeleteDecks; MenuItemCheckBoxAutoDeleteGames.IsChecked = Config.Instance.HearthStatsAutoDeleteMatches; }
/// <summary> /// Sets the theme color of the application. This method dynamically creates an in-memory resource /// dictionary containing the accent colors used by Fluent.Ribbon. /// </summary> public static void ApplyTheme() { //<Color x:Key="HighlightColor"> // #800080 //</Color> //<Color x:Key="AccentColor"> // #CC800080 //</Color> //<Color x:Key="AccentColor2"> // #99800080 //</Color> //<Color x:Key="AccentColor3"> // #66800080 //</Color> //<Color x:Key="AccentColor4"> // #33800080 //</Color> //<SolidColorBrush x:Key="HighlightBrush" Color="{StaticResource HighlightColor}" /> //<SolidColorBrush x:Key="AccentColorBrush" Color="{StaticResource AccentColor}" /> //<SolidColorBrush x:Key="AccentColorBrush2" Color="{StaticResource AccentColor2}" /> //<SolidColorBrush x:Key="AccentColorBrush3" Color="{StaticResource AccentColor3}" /> //<SolidColorBrush x:Key="AccentColorBrush4" Color="{StaticResource AccentColor4}" /> //<SolidColorBrush x:Key="WindowTitleColorBrush" Color="{StaticResource AccentColor}" /> //<SolidColorBrush x:Key="AccentSelectedColorBrush" Color="White" /> //<LinearGradientBrush x:Key="ProgressBrush" EndPoint="0.001,0.5" StartPoint="1.002,0.5"> // <GradientStop Color="{StaticResource HighlightColor}" Offset="0" /> // <GradientStop Color="{StaticResource AccentColor3}" Offset="1" /> //</LinearGradientBrush> //<SolidColorBrush x:Key="CheckmarkFill" Color="{StaticResource AccentColor}" /> //<SolidColorBrush x:Key="RightArrowFill" Color="{StaticResource AccentColor}" /> //<Color x:Key="IdealForegroundColor"> // Black //</Color> //<SolidColorBrush x:Key="IdealForegroundColorBrush" Color="{StaticResource IdealForegroundColor}" /> // Theme is always the 0-index of the resources var application = Application.Current; var applicationResources = application.Resources; var resourceDictionary = ThemeHelper.GetAccentColorResourceDictionary(); var applicationTheme = ThemeManager.AppThemes.First(x => string.Equals(x.Name, "BaseLight")); // Create theme var resDictName = $"ApplicationAccentColors.xaml"; var fileName = Path.Combine(Catel.IO.Path.GetApplicationDataDirectory(), resDictName); Log.Debug($"Writing dynamic theme file to '{fileName}'"); using (var writer = XmlWriter.Create(fileName, new XmlWriterSettings { Indent = true, IndentChars = " " })) { XamlWriter.Save(resourceDictionary, writer); writer.Close(); } resourceDictionary = new ResourceDictionary { Source = new Uri(fileName, UriKind.Absolute) }; Log.Debug("Applying theme to Fluent.Ribbon"); var newAccent = new Accent { Name = "Runtime accent (Orchestra)", Resources = resourceDictionary }; ThemeManager.AddAccent(newAccent.Name, newAccent.Resources.Source); ThemeManager.ChangeAppStyle(application, newAccent, applicationTheme); // Note: important to add the resources dictionary *after* changing the app style, but then insert at the top // so theme detection performance is best applicationResources.MergedDictionaries.Insert(1, resourceDictionary); }
private void ChangeThemeTo(string Theme) { if (Theme == "Red") { Settings.Default.Theme = "Red"; } if (Theme == "Green") { Settings.Default.Theme = "Green"; } if (Theme == "Blue") { Settings.Default.Theme = "Blue"; } if (Theme == "Purple") { Settings.Default.Theme = "Purple"; } if (Theme == "Orange") { Settings.Default.Theme = "Orange"; } if (Theme == "Lime") { Settings.Default.Theme = "Lime"; } if (Theme == "Emerald") { Settings.Default.Theme = "Emerald"; } if (Theme == "Teal") { Settings.Default.Theme = "Teal"; } if (Theme == "Cyan") { Settings.Default.Theme = "Cyan"; } if (Theme == "Cobalt") { Settings.Default.Theme = "Cobalt"; } if (Theme == "Indigo") { Settings.Default.Theme = "Indigo"; } if (Theme == "Violet") { Settings.Default.Theme = "Violet"; } if (Theme == "Pink") { Settings.Default.Theme = "Pink"; } if (Theme == "Magenta") { Settings.Default.Theme = "Magenta"; } if (Theme == "Crimson") { Settings.Default.Theme = "Crimson"; } if (Theme == "Amber") { Settings.Default.Theme = "Amber"; } if (Theme == "Yellow") { Settings.Default.Theme = "Yellow"; } if (Theme == "Brown") { Settings.Default.Theme = "Brown"; } if (Theme == "Olive") { Settings.Default.Theme = "Olive"; } if (Theme == "Steel") { Settings.Default.Theme = "Steel"; } if (Theme == "Mauve") { Settings.Default.Theme = "Mauve"; } if (Theme == "Taupe") { Settings.Default.Theme = "Taupe"; } if (Theme == "Sienna") { Settings.Default.Theme = "Sienna"; } Settings.Default.Save(); var AccountsBitmap = new BitmapImage(new Uri($"pack://application:,,,/Resources/Accounts/AccountsIMG_{Settings.Default.Theme}.png")); var ConsoleBitmap = new BitmapImage(new Uri($"pack://application:,,,/Resources/Console/ConsoleIMG_{Settings.Default.Theme}.png")); var EggsBitmap = new BitmapImage(new Uri($"pack://application:,,,/Resources/Eggs/EggsIMG_{Settings.Default.Theme}.png")); var HubBitmap = new BitmapImage(new Uri($"pack://application:,,,/Resources/Hub/HubIMG_{Settings.Default.Theme}.png")); var ItemsBitmap = new BitmapImage(new Uri($"pack://application:,,,/Resources/Items/ItemsIMG_{Settings.Default.Theme}.png")); var MapBitmap = new BitmapImage(new Uri($"pack://application:,,,/Resources/Map/MapIMG_{Settings.Default.Theme}.png")); var PokemonBitmap = new BitmapImage(new Uri($"pack://application:,,,/Resources/Pokemon/PokemonIMG_{Settings.Default.Theme}.png")); var SniperBitmap = new BitmapImage(new Uri($"pack://application:,,,/Resources/Sniper/SniperIMG_{Settings.Default.Theme}.png")); accountsIMG.Source = AccountsBitmap; consoleIMG.Source = ConsoleBitmap; eggsIMG.Source = EggsBitmap; browserIMG.Source = HubBitmap; itemsIMG.Source = ItemsBitmap; mapIMG.Source = MapBitmap; pokemonIMG.Source = PokemonBitmap; sniperIMG.Source = SniperBitmap; if (Settings.Default.ResetLayout == true) { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("Red"), ThemeManager.GetAppTheme("BaseDark")); Settings.Default.ResetLayout = false; } ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(Settings.Default.Theme), ThemeManager.GetAppTheme(Settings.Default.SchemeValue)); ResetSync(); }
/// <summary> /// Sets the theme color of the application. This method dynamically creates an in-memory resource /// dictionary containing the accent colors used by MahApps. /// </summary> public static void ApplyTheme() { //<Color x:Key="HighlightColor"> // #800080 //</Color> //<Color x:Key="AccentColor"> // #CC800080 //</Color> //<Color x:Key="AccentColor2"> // #99800080 //</Color> //<Color x:Key="AccentColor3"> // #66800080 //</Color> //<Color x:Key="AccentColor4"> // #33800080 //</Color> //<SolidColorBrush x:Key="HighlightBrush" Color="{StaticResource HighlightColor}" /> //<SolidColorBrush x:Key="AccentColorBrush" Color="{StaticResource AccentColor}" /> //<SolidColorBrush x:Key="AccentColorBrush2" Color="{StaticResource AccentColor2}" /> //<SolidColorBrush x:Key="AccentColorBrush3" Color="{StaticResource AccentColor3}" /> //<SolidColorBrush x:Key="AccentColorBrush4" Color="{StaticResource AccentColor4}" /> //<SolidColorBrush x:Key="WindowTitleColorBrush" Color="{StaticResource AccentColor}" /> //<SolidColorBrush x:Key="AccentSelectedColorBrush" Color="White" /> //<LinearGradientBrush x:Key="ProgressBrush" EndPoint="0.001,0.5" StartPoint="1.002,0.5"> // <GradientStop Color="{StaticResource HighlightColor}" Offset="0" /> // <GradientStop Color="{StaticResource AccentColor3}" Offset="1" /> //</LinearGradientBrush> //<SolidColorBrush x:Key="CheckmarkFill" Color="{StaticResource AccentColor}" /> //<SolidColorBrush x:Key="RightArrowFill" Color="{StaticResource AccentColor}" /> //<Color x:Key="IdealForegroundColor"> // Black //</Color> //<SolidColorBrush x:Key="IdealForegroundColorBrush" Color="{StaticResource IdealForegroundColor}" /> // Theme is always the 0-index of the resources var application = Application.Current; var applicationResources = application.Resources; var resourceDictionary = ThemeHelper.GetAccentColorResourceDictionary(); var applicationTheme = ThemeManager.AppThemes.First(x => string.Equals(x.Name, "BaseLight")); // Insert to get the best MahApps performance (when looking up themes) applicationResources.MergedDictionaries.Remove(resourceDictionary); applicationResources.MergedDictionaries.Insert(2, applicationTheme.Resources); Log.Debug("Applying theme to MahApps"); var newAccent = new Accent { Name = "Runtime accent (Orchestra)", Resources = resourceDictionary }; ThemeManager.ChangeAppStyle(application, newAccent, applicationTheme); // Note: important to add the resources dictionary *after* changing the app style, but then insert at the top // so MahApps theme detection performance is best applicationResources.MergedDictionaries.Insert(1, resourceDictionary); //var theme = ThemeManager.GetAppTheme(applicationResources); //if (theme == null) //{ // // Note: check ThemeManager.IsAccentDictionary() in https://github.com/MahApps/MahApps.Metro/blob/develop/MahApps.Metro/ThemeManager.cs#L234 // // for a list of expected resources // Log.Warning("No app theme found after applying it, make sure to include all resources that MahApps expects inside ThemeHelper.GetAccentColorResourceDictionary()"); //} }
private void ChangeAccent(string accent) { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(accent), ThemeManager.GetAppTheme(currentTheme)); currentAccent = accent; }
public MainWindowViewModel() { Items = new ReactiveList <TodoItem> { ChangeTrackingEnabled = true }; Items.ItemsAdded.Subscribe(i => i.DeleteCommand.Subscribe(_ => Items.Remove(i))); var itemDoneChanged = Items.ItemChanged.Where(x => x.PropertyName == "Done").Select(_ => Unit.Default); var countChanged = Items.CountChanged.Select(_ => Unit.Default); itemDoneChanged.Merge(countChanged).Subscribe(x1 => ItemsLeftCount = Items.Count(i => !i.Done)); FilteredItems = Items.CreateDerivedCollection(x => x, (Func <TodoItem, bool>)FilterItem); var canCreate = this.ObservableForProperty(vm => vm.NewItemText).Select(s => !String.IsNullOrWhiteSpace(s.Value)); CreateCommand = ReactiveCommand.Create(canCreate); CreateCommand.SelectArgs <KeyEventArgs>() .Where(x => x.Key == Key.Enter) .Subscribe(CreateItemExecute); //Items.Add(new TodoItem("ASDASD")); ChangeThemeCommand = ReactiveCommand.Create(); ChangeThemeCommand.Subscribe(_ => { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.DetectAppStyle(Application.Current).Item2, ThemeManager.AppThemes.ElementAt(_ThemeIndex++ % ThemeManager.AppThemes.Count())); }); ChangeAccentCommand = ReactiveCommand.Create(); ChangeAccentCommand.Subscribe(_ => { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.Accents.ElementAt(_ThemeAccent++ % ThemeManager.Accents.Count()), ThemeManager.DetectAppStyle(Application.Current).Item1); }); LoadCommand = ReactiveCommand.CreateAsyncObservable(_ => Observable.Create <TodoItem>(obs => { if (!failedYet) { obs.OnError(new Exception("test")); failedYet = true; } else { failedYet = false; obs.OnNext(new TodoItem("a")); obs.OnNext(new TodoItem("b")); obs.OnNext(new TodoItem("c")); obs.OnCompleted(); } return(Disposable.Empty); })); var observable = LoadCommand.ThrownExceptions.Select(ex => new UserError(ex.Message, recoveryOptions: new[] { RecoveryCommand.Yes, RecoveryCommand.Cancel })); //_LastError = observable.ToProperty(this, x => x.LastError); observable.SelectMany(UserError.Throw).Subscribe(result => { //this.RaisePropertyChanged("HasError"); switch (result) { case RecoveryOptionResult.CancelOperation: return; case RecoveryOptionResult.RetryOperation: LoadCommand.Execute(null); break; } }); LoadCommand.Subscribe(Items.Add); }
public static void CreateAppStyleBy(Color color, bool changeImmediately = false) { // create a runtime accent resource dictionary var resourceDictionary = new ResourceDictionary(); resourceDictionary.Add("HighlightColor", color); resourceDictionary.Add("AccentColor", Color.FromArgb((byte)(204), color.R, color.G, color.B)); resourceDictionary.Add("AccentColor2", Color.FromArgb((byte)(153), color.R, color.G, color.B)); resourceDictionary.Add("AccentColor3", Color.FromArgb((byte)(102), color.R, color.G, color.B)); resourceDictionary.Add("AccentColor4", Color.FromArgb((byte)(51), color.R, color.G, color.B)); resourceDictionary.Add("HighlightBrush", new SolidColorBrush((Color)resourceDictionary["HighlightColor"])); resourceDictionary.Add("AccentColorBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("AccentColorBrush2", new SolidColorBrush((Color)resourceDictionary["AccentColor2"])); resourceDictionary.Add("AccentColorBrush3", new SolidColorBrush((Color)resourceDictionary["AccentColor3"])); resourceDictionary.Add("AccentColorBrush4", new SolidColorBrush((Color)resourceDictionary["AccentColor4"])); resourceDictionary.Add("WindowTitleColorBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("ProgressBrush", new LinearGradientBrush( new GradientStopCollection(new[] { new GradientStop((Color)resourceDictionary["HighlightColor"], 0), new GradientStop((Color)resourceDictionary["AccentColor3"], 1) }), new Point(0.001, 0.5), new Point(1.002, 0.5))); resourceDictionary.Add("CheckmarkFill", new SolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("RightArrowFill", new SolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("IdealForegroundColor", Colors.White); resourceDictionary.Add("IdealForegroundColorBrush", new SolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("AccentSelectedColorBrush", new SolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); // applying theme to MahApps var resDictName = string.Format("ApplicationAccent_{0}.xaml", color.ToString().Replace("#", string.Empty)); var fileName = Path.Combine(Path.GetTempPath(), resDictName); using (var writer = System.Xml.XmlWriter.Create(fileName, new System.Xml.XmlWriterSettings { Indent = true })) { System.Windows.Markup.XamlWriter.Save(resourceDictionary, writer); writer.Close(); } resourceDictionary = new ResourceDictionary() { Source = new Uri(fileName, UriKind.Absolute) }; var newAccent = new Accent { Name = resDictName, Resources = resourceDictionary }; ThemeManager.AddAccent(newAccent.Name, newAccent.Resources.Source); if (changeImmediately) { var application = Application.Current; var applicationTheme = ThemeManager.AppThemes.First(x => string.Equals(x.Name, "BaseLight")); ThemeManager.ChangeAppStyle(application, newAccent, applicationTheme); } }
private async Task RefreshData() { //ha valami folyamatban van, nem hívjuk újra a frissítést if (IsBusy) { return; } IsBusy = true; tcs = new CancellationTokenSource(); task = new Task(() => { //todo: ha megállíthatónak akarjuk a frissítést, akkor legegyszerűbb a tcs-t továbbítani var result = forecastRepository.GetData(SelectedCity.Coordinates, SelectedLanguage.Code); tcs.Token.ThrowIfCancellationRequested(); if (result.IsValid) { //A daily tab view nem enged csak az UI szálról adatot módosítani App.Current.Dispatcher.Invoke(() => mapper.Map(result, this)) ; } else { HasSuccess = false; throw new Exception("Hiba történt az adatfrissítés közben"); } }, tcs.Token); task.Start(); //await-tal megvárjuk a végrehajtást, hogy frissítsük parancs hívhatóságát try { await Task.WhenAll(new Task[] { task }); } catch (OperationCanceledException) //ezzel lekezeltük a Cancel-t { } catch (Exception ex) { //todo: a hibát jelezni a felületre HasSuccess = false; logger.Error(ex, "Hiba történt az adatfrissítés közben"); ErrorMessage = "Hiba történt az adatfrissítés közben"; } finally { Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current); if (HasSuccess) { if (!appStyle.Item2.Name.Equals(GlobalStrings.Blue, StringComparison.OrdinalIgnoreCase)) { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(GlobalStrings.Blue), appStyle.Item1); } } else { if (!appStyle.Item2.Name.Equals(GlobalStrings.Red, StringComparison.OrdinalIgnoreCase)) { ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(GlobalStrings.Red), appStyle.Item1); } } IsBusy = false; IsValid = true; CommandManager.InvalidateRequerySuggested(); } }
private void ChangeAppThemeButtonClick(object sender, RoutedEventArgs e) { var theme = ThemeManager.DetectAppStyle(Application.Current); ThemeManager.ChangeAppStyle(Application.Current, theme.Item2, ThemeManager.GetAppTheme("Base" + ((Button)sender).Content)); }
public static void CreateAppStyleBy(Color color, bool changeImmediately = false) { // create a runtime accent resource dictionary var resourceDictionary = new ResourceDictionary { { "HighlightColor", color }, { "AccentBaseColor", color }, { "AccentColor", Color.FromArgb((byte)(204), color.R, color.G, color.B) }, { "AccentColor2", Color.FromArgb((byte)(153), color.R, color.G, color.B) }, { "AccentColor3", Color.FromArgb((byte)(102), color.R, color.G, color.B) }, { "AccentColor4", Color.FromArgb((byte)(51), color.R, color.G, color.B) } }; resourceDictionary.Add("HighlightBrush", GetSolidColorBrush((Color)resourceDictionary["HighlightColor"])); resourceDictionary.Add("AccentBaseColorBrush", GetSolidColorBrush((Color)resourceDictionary["AccentBaseColor"])); resourceDictionary.Add("AccentColorBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("AccentColorBrush2", GetSolidColorBrush((Color)resourceDictionary["AccentColor2"])); resourceDictionary.Add("AccentColorBrush3", GetSolidColorBrush((Color)resourceDictionary["AccentColor3"])); resourceDictionary.Add("AccentColorBrush4", GetSolidColorBrush((Color)resourceDictionary["AccentColor4"])); resourceDictionary.Add("WindowTitleColorBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("ProgressBrush", new LinearGradientBrush( new GradientStopCollection(new[] { new GradientStop((Color)resourceDictionary["HighlightColor"], 0), new GradientStop((Color)resourceDictionary["AccentColor3"], 1) }), new Point(0.001, 0.5), new Point(1.002, (int)0.5))); resourceDictionary.Add("CheckmarkFill", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("RightArrowFill", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("IdealForegroundColor", IdealTextColor(color)); resourceDictionary.Add("IdealForegroundColorBrush", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("IdealForegroundDisabledBrush", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"], 0.4)); resourceDictionary.Add("AccentSelectedColorBrush", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("MetroDataGrid.HighlightBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("MetroDataGrid.HighlightTextBrush", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("MetroDataGrid.MouseOverHighlightBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor3"])); resourceDictionary.Add("MetroDataGrid.FocusBorderBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("MetroDataGrid.InactiveSelectionHighlightBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor2"])); resourceDictionary.Add("MetroDataGrid.InactiveSelectionHighlightTextBrush", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchBrush.Win10", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchMouseOverBrush.Win10", GetSolidColorBrush((Color)resourceDictionary["AccentColor2"])); resourceDictionary.Add("MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorCheckedBrush.Win10", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); // applying theme to MahApps var resDictName = $"ApplicationAccent_{color.ToString().Replace("#", string.Empty)}.xaml"; var fileName = Path.Combine(Path.GetTempPath(), resDictName); using (var writer = System.Xml.XmlWriter.Create(fileName, new System.Xml.XmlWriterSettings { Indent = true })) { System.Windows.Markup.XamlWriter.Save(resourceDictionary, writer); writer.Close(); } resourceDictionary = new ResourceDictionary() { Source = new Uri(fileName, UriKind.Absolute) }; var newAccent = new Accent { Name = resDictName, Resources = resourceDictionary }; ThemeManager.AddAccent(newAccent.Name, newAccent.Resources.Source); if (changeImmediately) { var application = Application.Current; //var applicationTheme = ThemeManager.AppThemes.First(x => string.Equals(x.Name, "BaseLight")); // detect current application theme var applicationTheme = ThemeManager.DetectAppStyle(application); ThemeManager.ChangeAppStyle(application, newAccent, applicationTheme.Item1); } }
private void CustomThemeAppButtonClick(object sender, RoutedEventArgs e) { var theme = ThemeManager.DetectAppStyle(Application.Current); ThemeManager.ChangeAppStyle(Application.Current, theme.Item2, ThemeManager.GetAppTheme("CustomTheme")); }
private void ChangeWindowAccentButtonClick(object sender, RoutedEventArgs e) { var theme = ThemeManager.DetectAppStyle(this); ThemeManager.ChangeAppStyle(this, ThemeManager.GetAccent(((Button)sender).Content.ToString()), theme.Item1); }
private void Application_Startup(object sender, StartupEventArgs e) { #region DEBUG初始化 //debug logHandler = new LogHandler(true); AggregateExceptionCatched += (a, b) => logHandler.AppendFatal(b.AggregateException); if (e.Args.Contains("-debug")) { Windows.DebugWindow debugWindow = new Windows.DebugWindow(); debugWindow.Show(); logHandler.OnLog += (s, log) => debugWindow?.AppendLog(s, log); } #endregion config = new ConfigHandler(); #region DEBUG初始化(基于配置文件) if (config.MainConfig.Launcher.Debug && !e.Args.Contains("-debug")) { Windows.DebugWindow debugWindow = new Windows.DebugWindow(); debugWindow.Show(); logHandler.OnLog += (s, log) => debugWindow?.AppendLog(s, log); } #endregion #region MineRealms反馈API初始化 #if DEBUG MineRealmsAPIHandler = new MineRealmsLauncherCore.Net.PhalAPI.APIHandler(true); #else MineRealmsAPIHandler = new MineRealmsLauncherCore.Net.PhalAPI.APIHandler(config.MainConfig.Launcher.NoTracking); #endif #endregion #region 数据初始化 Config.Environment env = config.MainConfig.Environment; javaList = Java.GetJavaList(); //设置版本路径 string gameroot = null; switch (env.GamePathType) { case GameDirEnum.ROOT: gameroot = Path.GetFullPath(".minecraft"); break; case GameDirEnum.APPDATA: gameroot = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\.minecraft"; break; case GameDirEnum.PROGRAMFILES: gameroot = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles) + "\\.minecraft"; break; case GameDirEnum.CUSTOM: gameroot = env.GamePath + "\\.minecraft"; break; default: throw new ArgumentException("判断游戏目录类型时出现异常,请检查配置文件中GamePathType节点"); } logHandler.AppendInfo("核心初始化->游戏根目录(默认则为空):" + gameroot); //设置JAVA Java java = null; if (env.AutoJava) { java = Java.GetSuitableJava(javaList); } else { java = javaList.Find(x => x.Path == env.JavaPath); if (java == null) { java = Java.GetJavaInfo(env.JavaPath); } } if (java != null) { env.JavaPath = java.Path; logHandler.AppendInfo("核心初始化->Java路径:" + java.Path); logHandler.AppendInfo("核心初始化->Java版本:" + java.Version); logHandler.AppendInfo("核心初始化->Java位数:" + java.Arch); } else { logHandler.AppendWarn("核心初始化失败,当前电脑未匹配到JAVA"); } //设置版本独立 bool verIso = config.MainConfig.Environment.VersionIsolation; #endregion #region 启动核心初始化 handler = new LaunchHandler(gameroot, java, verIso); handler.GameLog += (s, log) => logHandler.AppendLog(s, new Log() { LogLevel = LogLevel.GAME, Message = log }); handler.LaunchLog += (s, log) => logHandler.AppendLog(s, log); #endregion #region 载核心初始化 ServicePointManager.DefaultConnectionLimit = 10; Download downloadCfg = config.MainConfig.Download; downloader = new MultiThreadDownloader(); if (!string.IsNullOrWhiteSpace(downloadCfg.DownloadProxyAddress)) { WebProxy proxy = new WebProxy(downloadCfg.DownloadProxyAddress, downloadCfg.DownloadProxyPort); if (!string.IsNullOrWhiteSpace(downloadCfg.ProxyUserName)) { NetworkCredential credential = new NetworkCredential(downloadCfg.ProxyUserName, downloadCfg.ProxyUserPassword); proxy.Credentials = credential; } downloader.Proxy = proxy; } downloader.ProcessorSize = App.config.MainConfig.Download.DownloadThreadsSize; downloader.CheckFileHash = App.config.MainConfig.Download.CheckDownloadFileHash; downloader.DownloadLog += (s, log) => logHandler?.AppendLog(s, log); #endregion #region 自定义主题初始化 var custom = config.MainConfig.Customize; if (!string.IsNullOrWhiteSpace(custom.AccentColor) && !string.IsNullOrWhiteSpace(custom.AppThme)) { logHandler.AppendInfo("自定义->更改主题颜色:" + custom.AccentColor); logHandler.AppendInfo("自定义->更改主题:" + custom.AppThme); ThemeManager.ChangeAppStyle(Current, ThemeManager.GetAccent(custom.AccentColor), ThemeManager.GetAppTheme(custom.AppThme)); } #endregion }
public void ChangeAccent(string Accent) { //MetroWindow window = (MetroWindow)Application.Current.MainWindow; ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(Accent), ThemeManager.DetectAppStyle(Application.Current).Item1); }