public override void SetTheme(IThemeBase t) { base.SetTheme(t); _hComboBox1.Theme = t; _hComboBox2.Theme = t; _hComBoBox3.Theme = t; setMenuRender(); }
/// <summary> /// 设置主题 /// </summary> /// <param name="t"></param> public virtual void SetTheme(IThemeBase t) { BackColor = t.BackColor; BorderColor = t.BorderColor; ForeColor = t.ForeColor; if (t is ITheme) { Opacity = (t as ITheme).Opacity; Blendable = (t as ITheme).Blendable; } }
/// <summary> /// Get a text editor highlighting theme associated with the given WPF Theme Name. /// </summary> /// <param name="themeName"></param> /// <returns></returns> public IHighlightingThemes GetTextEditorHighlighting(string themeName) { // Is this WPF theme configured with a highlighting theme??? IThemeBase cfg = null; _TextEditorThemes.TryGetValue(themeName, out cfg); if (cfg != null) { return(cfg.HighlightingStyles); } return(null); }
/// <summary> /// 设置主题 /// </summary> /// <param name="t"></param> public void SetTheme(IThemeBase t) { BackColor = t.BackColor; ForeColor = t.ForeColor; BorderColor = t.BorderColor; }
/// <summary> /// 将指定的ThemeBase应用到对话框 /// </summary> /// <param name="themeBase"></param> public virtual void SetTheme(IThemeBase themeBase) { _DialogWindow.SetTheme(themeBase); }
/// <summary> /// Change WPF theme. /// /// This method can be called when the theme is to be reseted by all means /// (eg.: when powering application up). /// /// !!! Use the CurrentTheme property to change !!! /// !!! the theme when App is running !!! /// </summary> public void ResetTheme() { // Reset customized resources (if there are any from last change) and // enforce reload of original values from resource dictionary if (HighlightingManager.Instance.BackupDynResources != null) { try { foreach (string t in HighlightingManager.Instance.BackupDynResources) { Application.Current.Resources[t] = null; } } catch { // ignored } finally { HighlightingManager.Instance.BackupDynResources = null; } } // Get WPF Theme definition from Themes Assembly IThemeBase nextThemeToSwitchTo = ApplicationThemes.SelectedTheme; SwitchToSelectedTheme(nextThemeToSwitchTo); // Backup highlighting names (if any) and restore highlighting associations after reloading highlighting definitions var hlNames = new List <string>(); foreach (EdiViewModel f in Documents) { if (f != null) { hlNames.Add(f.HighlightingDefinition?.Name); } } // Is the current theme configured with a highlighting theme??? ////this.Config.FindHighlightingTheme( IHighlightingThemes hlThemes = nextThemeToSwitchTo.HighlightingStyles; // Re-load all highlighting patterns and re-apply highlightings HighlightingExtension.RegisterCustomHighlightingPatterns(hlThemes); //Re-apply highlightings after resetting highlighting manager List <EdiViewModel> l = Documents; for (int i = 0; i < l.Count; i++) { if (l[i] != null) { if (hlNames[i] == null) // The highlighting is null if highlighting is switched off for this file(!) { continue; } IHighlightingDefinition hdef = HighlightingManager.Instance.GetDefinition(hlNames[i]); if (hdef != null) { l[i].HighlightingDefinition = hdef; } } } var backupDynResources = new List <string>(); // Apply global styles to theming elements (dynamic resources in resource dictionary) of editor control if (HighlightingManager.Instance.HlThemes != null) { foreach (WidgetStyle w in HighlightingManager.Instance.HlThemes.GlobalStyles) { ApplyWidgetStyle(w, backupDynResources); } } if (backupDynResources.Count > 0) { HighlightingManager.Instance.BackupDynResources = backupDynResources; } }
/// <summary> /// Attempt to switch to the theme stated in <paramref name="nextThemeToSwitchTo"/>. /// The given name must map into the <seealso cref="Edi.Themes.ThemesVM.EnTheme"/> enumeration. /// </summary> /// <param name="nextThemeToSwitchTo"></param> private void SwitchToSelectedTheme(IThemeBase nextThemeToSwitchTo) { const string themesModul = "Edi.Themes.dll"; try { // set the style of the message box display in back-end system. _MsgBox.Style = MsgBoxStyle.System; // Get WPF Theme definition from Themes Assembly IThemeBase theme = ApplicationThemes.SelectedTheme; if (theme != null) { Application.Current.Resources.MergedDictionaries.Clear(); string themesPathFileName = Assembly.GetEntryAssembly().Location; themesPathFileName = System.IO.Path.GetDirectoryName(themesPathFileName); themesPathFileName = System.IO.Path.Combine(themesPathFileName, themesModul); Assembly.LoadFrom(themesPathFileName); if (System.IO.File.Exists(themesPathFileName) == false) { _MsgBox.Show(string.Format(CultureInfo.CurrentCulture, Util.Local.Strings.STR_THEMING_MSG_CANNOT_FIND_PATH, themesModul), Util.Local.Strings.STR_THEMING_CAPTION, MsgBoxButtons.OK, MsgBoxImage.Error); return; } foreach (var item in theme.Resources) { try { var res = new Uri(item, UriKind.Relative); if (Application.LoadComponent(res) is ResourceDictionary) { ResourceDictionary dictionary = Application.LoadComponent(res) as ResourceDictionary; Application.Current.Resources.MergedDictionaries.Add(dictionary); } } catch (Exception exp) { _MsgBox.Show(exp, string.Format(CultureInfo.CurrentCulture, "'{0}'", item), MsgBoxButtons.OK, MsgBoxImage.Error); } } } } catch (Exception exp) { _MsgBox.Show(exp, Util.Local.Strings.STR_THEMING_CAPTION, MsgBoxButtons.OK, MsgBoxImage.Error); } finally { // set the style of the message box display in back-end system. if (nextThemeToSwitchTo.WPFThemeName != "Generic") { _MsgBox.Style = MsgBoxStyle.WPFThemed; } } }
public override void SetTheme(IThemeBase t) { base.SetTheme(t); _hComboBox1.Theme = t; }