protected Theme() { Colors = new ThemeColors(); Brushes = new ThemeBrushes(Colors); Fonts = new ThemeFonts(); FontSizes = new ThemeFontSizes(); }
private static ThemeConfig BuildTheme(ThemeColors colors, bool darkTheme) { var theme = new ThemeConfig(); theme.Colors = colors; theme.IsDarkTheme = darkTheme; theme.SlightShade = new Color(0, 0, 0, 40); theme.MinimalShade = new Color(0, 0, 0, 15); theme.Shade = new Color(0, 0, 0, 120); theme.DarkShade = new Color(0, 0, 0, 190); theme.ActiveTabColor = theme.ResolveColor( new Color(darkTheme ? "#3E3E3E" : "#BEBEBE"), new Color( Color.White, (darkTheme) ? 3 : 25)); theme.TabBarBackground = theme.ActiveTabColor.WithLightnessAdjustment(0.85).ToColor(); theme.ThumbnailBackground = Color.Transparent; theme.AccentMimimalOverlay = new Color(theme.Colors.PrimaryAccentColor, 50); theme.InteractionLayerOverlayColor = new Color(theme.ActiveTabColor, 240); theme.InactiveTabColor = theme.ResolveColor(theme.ActiveTabColor, new Color(Color.White, darkTheme ? 20 : 60)); theme.SplitterBackground = theme.ActiveTabColor.WithLightnessAdjustment(0.87).ToColor(); theme.BorderColor = new Color(darkTheme ? "#C8C8C8" : "#333"); theme.SplashAccentColor = theme.Colors.PrimaryAccentColor; theme.BedBackgroundColor = theme.ResolveColor(theme.ActiveTabColor, new Color(Color.Black, 20)); theme.PresetColors = new PresetColors(); return(theme); }
/// <summary> /// The add color to recent colors if missing. /// </summary> /// <param name="color"> /// The color. /// </param> /// <returns> /// True if the color was added. /// </returns> private bool AddColorToRecentColorsIfMissing(Color color) { // Check if the color exists if (ThemeColors.Contains(color)) { return(false); } if (StandardColors.Contains(color)) { return(false); } if (RecentColors.Contains(color)) { return(false); } if (RecentColors.Count >= this.MaxNumberOfRecentColors) { RecentColors.RemoveAt(RecentColors.Count - 1); } RecentColors.Insert(0, color); return(true); }
public void ChangeTheme(ThemeColors color) { var theme = ColorMap[color]; //テーマを反映 foreach (var name in AccentTarget) { App.Current.Resources[name] = theme.AccentBrush; } foreach (var name in AccentActiveTarget) { App.Current.Resources[name] = theme.AccentActiveBrush; } foreach (var name in AccentAlphaHighlightTarget) { App.Current.Resources[name] = theme.AccentAlphaHighlightBrush; } foreach (var name in AccentForegroundTarget) { App.Current.Resources[name] = theme.AccentForegroundBrush; } foreach (var name in AccentHighlightTarget) { App.Current.Resources[name] = theme.AccentHighlightBrush; } }
internal void UpdateColor(String name, ThemeColors colors) { if ((null == name) || (0 == name.Length)) { return; } if (true == name.StartsWith("#")) { Color color = new Color(name.Substring(1)); this.colorArray[0] = color.colorArray[0]; this.colorArray[1] = color.colorArray[1]; this.colorArray[2] = color.colorArray[2]; this.colorArray[3] = color.colorArray[3]; } else { foreach (Color color in colors.SystemColors) { if (true == name.Equals(color.Name)) { this.colorArray[0] = color.colorArray[0]; this.colorArray[1] = color.colorArray[1]; this.colorArray[2] = color.colorArray[2]; this.colorArray[3] = color.colorArray[3]; return; } } } }
public LVTheme(ThemeColors color) { switch (color) { case ThemeColors.Light: this.SelectionColor = Color.FromArgb(75, 2, 163, 255); this.SelectionFocusedColor = Color.FromArgb(75, 2, 163, 255); this.MouseOverColor = Color.FromArgb(75, 146, 212, 250); this.SelectionBorderColor = Color.FromArgb(75, 10, 127, 237); this.HeaderSelectionColor = Color.FromArgb(255, 235, 235, 235); this.TextColor = Colors.Black; this.HeaderBackgroundColor = Colors.White; this.SortColumnColor = Color.FromRgb(235, 244, 254); this.HeaderDividerColor = Color.FromRgb(235, 244, 254); this.HeaderArrowColor = Color.FromArgb(75, 10, 127, 237); break; case ThemeColors.Dark: this.MouseOverColor = Color.FromArgb(75, 107, 105, 105); this.SelectionColor = Color.FromArgb(75, 139, 139, 139); this.SelectionFocusedColor = Color.FromArgb(75, 220, 220, 220); this.SelectionBorderColor = (System.Windows.Media.Color)System.Windows.Application.Current.Resources["WhiteColor"]; this.HeaderSelectionColor = Color.FromArgb(255, 60, 60, 60); this.TextColor = (System.Windows.Media.Color)System.Windows.Application.Current.Resources["Gray6"]; this.HeaderBackgroundColor = Color.FromRgb(45, 45, 45); this.SortColumnColor = Color.FromRgb(35, 35, 35); this.HeaderDividerColor = Color.FromRgb(79, 79, 79); this.HeaderArrowColor = Color.FromArgb(75, 220, 220, 220); break; } this.BackgroundColor = (System.Windows.Media.Color)System.Windows.Application.Current.Resources["WhiteColor"]; }
private void PART_EditThemeMenuImport_Click(object sender, RoutedEventArgs e) { string targetPath = _PlayniteApi.Dialogs.SelectFile("json file|*.json"); if (!targetPath.IsNullOrEmpty()) { ThemeColors themeColors = new ThemeColors(); try { themeColors = JsonConvert.DeserializeObject <ThemeColors>(File.ReadAllText(targetPath)); } catch { _PlayniteApi.Dialogs.ShowErrorMessage(resources.GetString("LOCThemeModifierManageNoFile"), "ThemeModifier"); return; } if (themeColors.Name.IsNullOrEmpty()) { _PlayniteApi.Dialogs.ShowErrorMessage(resources.GetString("LOCThemeModifierManageNoFile"), "ThemeModifier"); return; } string PathThemeColors = Path.Combine(_PluginUserDataPath, "ThemeColors"); string PathThemeColorsFile = Path.Combine(PathThemeColors, themeColors.Name + "_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm") + ".json"); File.Copy(targetPath, PathThemeColorsFile, true); SetMenuItems(); } }
public LVTheme(ThemeColors color) { switch (color) { case ThemeColors.Light: this.SelectionColor = Color.FromArgb(75, 128, 128, 128); this.SelectionBorderColor = Color.FromArgb(109, 96, 96, 91); this.HeaderSelectionColor = Color.FromArgb(255, 235, 235, 235); this.TextColor = Colors.Black; this.HeaderBackgroundColor = Colors.White; this.SortColumnColor = Color.FromRgb(235, 244, 254); this.HeaderDividerColor = Color.FromRgb(235, 244, 254); break; case ThemeColors.Dark: this.SelectionColor = Color.FromArgb(75, 128, 128, 128); this.SelectionBorderColor = Color.FromArgb(75, 210, 210, 210); this.HeaderSelectionColor = Color.FromArgb(255, 60, 60, 60); this.TextColor = (System.Windows.Media.Color)System.Windows.Application.Current.Resources["Gray6"]; this.HeaderBackgroundColor = Color.FromRgb(45, 45, 45); this.SortColumnColor = Color.FromRgb(35, 35, 35); this.HeaderDividerColor = Color.FromRgb(79, 79, 79); break; } this.BackgroundColor = (System.Windows.Media.Color)System.Windows.Application.Current.Resources["WhiteColor"]; }
private ColorBlock BuildColorBlock(ThemeColors themeColors) { ColorBlock colorBlock = ColorBlock.defaultColorBlock; colorBlock.normalColor = themeColors.normalColor; colorBlock.highlightedColor = themeColors.highlightedColor; return(colorBlock); }
public ExpressionWindow() : base() { TitleIcon.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; TitleIcon.VerticalAlignment = System.Windows.VerticalAlignment.Center; TitleIcon.Width = 16; TitleIcon.Height = 16; TitleIcon.Margin = new Thickness(8, 0, 0, 0); this.Icon = Imaging.CreateBitmapSourceFromHIcon( System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location).Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions() ); TitleIcon.Source = this.Icon; TitleIcon.SetBinding(Image.SourceProperty, new Binding() { Path = new PropertyPath("Icon"), RelativeSource = new RelativeSource() { AncestorType = typeof(ExpressionWindow), Mode = RelativeSourceMode.FindAncestor }, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); this.MinWidth = 50; this.MinHeight = TITLE_BAR_HEIGHT; IsColorPickerEnabled = true; IsModal = false; Window_TitleLabel.SetBinding(Label.ContentProperty, new Binding() { Path = new PropertyPath("Title"), RelativeSource = new RelativeSource() { AncestorType = typeof(ExpressionWindow), Mode = RelativeSourceMode.FindAncestor }, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); if (FrameLoaded) { themeColor = ((ExpressionWindow)Application.Current.MainWindow).ThemeColor; } else { ThemeColor = DEFAULT_COLOR; FrameLoaded = true; } Chrome = new WindowChrome(); Chrome.CaptionHeight = TITLE_BAR_HEIGHT; Chrome.CornerRadius = new CornerRadius(0); Chrome.ResizeBorderThickness = new Thickness(RESIZE_HANDLE_SIZE); Chrome.GlassFrameThickness = new Thickness(0); WindowChrome.SetWindowChrome(this, Chrome); Initialize(); Application.Current.Deactivated += Current_Deactivated; Application.Current.Activated += Current_Activated; }
public ThemeSet GetTheme(string mode, Color accentColor) { bool darkTheme = mode == "Dark"; Console.WriteLine("Requesting theme for " + accentColor.Html); var colors = ThemeColors.Create(accentColor, darkTheme); Console.WriteLine("Generated: PrimaryAccent: " + colors.PrimaryAccentColor + " source: " + colors.SourceColor); return(ThemeFromColors(colors, darkTheme)); }
public FolderCard(GameObject obj, string text) : base(obj) { // Set colors cardObj.SetColor(ThemeColors.GetColor(instanceNum)); cardObj.transform.Find("StarAccent").gameObject.SetColor(ThemeColors.GetColor(instanceNum).LerpBlackAlpha(0.3f, 0.1f)); // Set text cardObj.transform.Find("Text").gameObject.SetText(text); instanceNum++; }
public void GenerateScheme(Color v) { ThemeColors tc = new ThemeColors(Color.FromArgb(50, 50, 50), Color.HotPink); this.BackColor = tc.Background; this.ForeColor = tc.Foreground; pnlHighlight.BackColor = tc.Highlight; pnlHighlight.ForeColor = tc.HighlightBW; pnlBorder.BackColor = tc.HighlightLight; pnlContent.BackColor = tc.BackgroundDark; pnlBgBorder.BackColor = tc.BackgroundLight; }
public void Loaded() { LoadAccountInfo();//加载本地账号信息 ThemeColors.Clear(); var colors = Service.SettingService.GetAllColor(); foreach (var item in colors) { ThemeColors.Add(item); } }
public void Update(IFormattedLineSource formattedLineSource) { var textBlock = Child as TextBlock; textBlock.Foreground = formattedLineSource.DefaultTextProperties.ForegroundBrush; textBlock.FontSize = formattedLineSource.DefaultTextProperties.FontRenderingEmSize - 2; textBlock.FontFamily = formattedLineSource.DefaultTextProperties.Typeface.FontFamily; var themeColors = ThemeColors.BasedOnText(textBlock.Foreground); Background = themeColors.BackgroundBrush; BorderBrush = themeColors.BorderBrush; }
public NamedColor this[Color color] { get { var namedColor = ThemeColors.FirstOrDefault(c => c.Color == color) ?? StandardColors.FirstOrDefault(c => c.Color == color); if (namedColor == null && AutomaticColor.Color == color) { namedColor = AutomaticColor; } return(namedColor); } }
protected override void InitColors() { Colors = new ThemeColors { Base03 = Color.FromArgb(0, 43, 54), Base02 = Color.FromArgb(7, 54, 66), Base01 = Color.FromArgb(88, 110, 117), // 2 content colors Base00 = Color.FromArgb(101, 123, 131), Base0 = Color.FromArgb(131, 148, 150), // 3 light back- or foreground colors Base1 = Color.FromArgb(147, 161, 161), Base2 = Color.FromArgb(238, 232, 213), Base3 = Color.FromArgb(253, 246, 227), // pure colors Yellow = Color.FromArgb(181, 137, 0), Orange = Color.FromArgb(203, 75, 22), Red = Color.FromArgb(220, 50, 47), Magenta = Color.FromArgb(211, 54, 130), Violet = Color.FromArgb(108, 113, 196), Blue = Color.FromArgb(38, 139, 210), Cyan = Color.FromArgb(42, 161, 152), Green = Color.FromArgb(133, 153, 0), // some more colors used through the application White = Color.FromArgb(255, 255, 255), Black = Color.FromArgb(0, 0, 0), Silver = Color.FromArgb(206, 212, 223), GrayButton = Color.FromArgb(206, 212, 223), LightGrayButton = Color.FromArgb(237, 239, 243), HighLightButton = Color.FromArgb(255, 236, 181), LightHighLightButton = Color.FromArgb(255, 250, 237), HighLightButtonBorder = Color.FromArgb(229, 195, 101), HighLightYellow = Color.FromArgb(241, 243, 248), //HighLightBlue = Color.FromArgb (50, 150, 250), //HighLightBlueTransparent = Color.FromArgb (100, 50, 150, 250), //HighLightBlue = Color.FromArgb (235, 38, 139, 210), //HighLightBlue = Color.FromArgb (245, 38, 139, 210), HighLightBlue = Color.FromArgb(38, 139, 210), HighLightBlueTransparent = Color.FromArgb(100, 38, 139, 210), }; }
public static MaterialColor ToMaterialColor(this ThemeColors color) { switch (color) { case ThemeColors.Red: return(Colors.red); case ThemeColors.Teal: return(Colors.teal); case ThemeColors.Blue: return(Colors.blue); case ThemeColors.Grey: return(Colors.grey); } return(Colors.teal); }
private void ActivateButton(object btnSender) { if (btnSender != null) { if (currentButton != (Button)btnSender) { DisableButton(); Color color = SelectThemeColor(); currentButton = (Button)btnSender; currentButton.BackColor = color; currentButton.ForeColor = Color.White; currentButton.Font = new System.Drawing.Font("Century Gothic", 13.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); homePanel.BackColor = color; logoPanel.BackColor = ThemeColors.ChangeColorBrightness(color, -0.3); ThemeColors.PrimaryColor = color; ThemeColors.SecondaryColor = ThemeColors.ChangeColorBrightness(color, -0.3); } } }
public static ThemeSet ThemeFromColors(ThemeColors colors, bool darkTheme) { var json = JsonConvert.SerializeObject(colors); var clonedColors = JsonConvert.DeserializeObject <ThemeColors>(json); clonedColors.PrimaryTextColor = new Color("#222"); var menuTheme = BuildTheme(clonedColors, darkTheme); menuTheme.ActiveTabColor = new Color("#f1f1f1"); menuTheme.IsDarkTheme = false; return(new ThemeSet() { Theme = BuildTheme(colors, darkTheme), MenuTheme = menuTheme }); }
private void ChangeTheme(ThemeColors themeColor) { if (!Application.Current.Dispatcher.CheckAccess()) { Application.Current.RunInDispatcherAsync(() => this.ChangeTheme(themeColor)); } else { var newTheme = ThemeManager.Current.GetTheme("Light." + themeColor.ToString()); if (newTheme != null) { ThemeManager.Current.ChangeTheme(Application.Current, newTheme); this.Info($"Change theme: NewTheme: {newTheme.Name} Theme changed."); } else { this.Info($"Change theme: Theme not found: {themeColor}."); } } }
private void activeButton(object btnSender, int colorIndex) { if (btnSender != null) { if (currentButton != (Button)btnSender) { disableOtherButtons(); Color color = ThemeColors.tempColorSelecet(colorIndex); currentButton = (Button)btnSender; currentButton.BackColor = color; currentButton.ForeColor = Color.White; currentButton.Font = new Font("", 12.5F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); currentButton.Image = (Image) new Bitmap(currentButton.Image, new Size(52, 52)); panelLogo.BackColor = ThemeColors.ChangeColorBrightness(color, -0.2); panelTitleBar.BackColor = ThemeColors.ChangeColorBrightness(color, -0.05); ThemeColors.PrimaryColor = color; ThemeColors.SecondaryColor = ThemeColors.ChangeColorBrightness(color, -0.2); CloseButton.Visible = true; } } }
private void ActivateButton(object btnSender) { //Revisar si se ha presionado un boton if (btnSender != null) { //Establecer el boton presionado if (currentButton != (Button)btnSender) { //Tomar el color y cambiar fuentes para resaltar dicho boton DisableButton(); Color color = SelectThemeColor(); currentButton = (Button)btnSender; currentButton.BackColor = color; currentButton.ForeColor = Color.White; currentButton.Font = new System.Drawing.Font("Century Gothic", 13.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); homePanel.BackColor = color; logoPanel.BackColor = ThemeColors.ChangeColorBrightness(color, -0.3); ThemeColors.PrimaryColor = color; ThemeColors.SecondaryColor = ThemeColors.ChangeColorBrightness(color, -0.3); } } }
public void SetColor(ThemeColors themeColors) { currentProfile.profileData.ButtonNormalColor = GenerateColorString(themeColors.normalColor); currentProfile.profileData.ButtonHighlightedColor = GenerateColorString(themeColors.highlightedColor); ChangeCurrentColor(themeColors); }
public static Color GetColor(Theme th, ThemeColors tr) { return colors[Tuple.Create(th, tr)]; }
private static ThemeColors GetColors(IDictionary <string, ReportResourceEntry> dictionary) { if (dictionary == null) { return(null); } var result = new ThemeColors(); if (dictionary.TryGetValue(COLORS_DARK1_KEY, out var entry) && entry.Value != null) { result.Dark1 = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_DARK2_KEY, out entry) && entry.Value != null) { result.Dark2 = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_LIGHT1_KEY, out entry) && entry.Value != null) { result.Light1 = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_LIGHT2_KEY, out entry) && entry.Value != null) { result.Light2 = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_ACCENT1_KEY, out entry) && entry.Value != null) { result.Accent1 = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_ACCENT2_KEY, out entry) && entry.Value != null) { result.Accent2 = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_ACCENT3_KEY, out entry) && entry.Value != null) { result.Accent3 = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_ACCENT4_KEY, out entry) && entry.Value != null) { result.Accent4 = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_ACCENT5_KEY, out entry) && entry.Value != null) { result.Accent5 = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_ACCENT6_KEY, out entry) && entry.Value != null) { result.Accent6 = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_HYPERLINK_KEY, out entry) && entry.Value != null) { result.Hyperlink = entry.Value.ToString(); } if (dictionary.TryGetValue(COLORS_HYPERLINKFOLLOWED_KEY, out entry) && entry.Value != null) { result.HyperlinkFollowed = entry.Value.ToString(); } return(result); }
public ExpressionWindow() : base() { TitleIcon.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; TitleIcon.VerticalAlignment = System.Windows.VerticalAlignment.Center; TitleIcon.Width = 16; TitleIcon.Height = 16; TitleIcon.Margin = new Thickness(8, 0, 0, 0); this.Icon = Imaging.CreateBitmapSourceFromHIcon( System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location).Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions() ); TitleIcon.Source = this.Icon; TitleIcon.SetBinding(Image.SourceProperty, new Binding() { Path = new PropertyPath("Icon"), RelativeSource = new RelativeSource() { AncestorType = typeof(ExpressionWindow), Mode = RelativeSourceMode.FindAncestor }, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); this.MinWidth = 50; this.MinHeight = TITLE_BAR_HEIGHT; IsColorPickerEnabled = true; IsModal = false; Window_TitleLabel.SetBinding(Label.ContentProperty, new Binding() { Path = new PropertyPath("Title"), RelativeSource = new RelativeSource() { AncestorType = typeof(ExpressionWindow), Mode = RelativeSourceMode.FindAncestor }, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); if (FrameLoaded) themeColor = ((ExpressionWindow)Application.Current.MainWindow).ThemeColor; else { ThemeColor = DEFAULT_COLOR; FrameLoaded = true; } Chrome = new WindowChrome(); Chrome.CaptionHeight = TITLE_BAR_HEIGHT; Chrome.CornerRadius = new CornerRadius(0); Chrome.ResizeBorderThickness = new Thickness(RESIZE_HANDLE_SIZE); Chrome.GlassFrameThickness = new Thickness(0); WindowChrome.SetWindowChrome(this, Chrome); Initialize(); Application.Current.Deactivated += Current_Deactivated; Application.Current.Activated += Current_Activated; }
public async System.Threading.Tasks.Task <ThemeColors> GetColorAsync(ImageSource imageSource) { IImageSourceHandler handler; ThemeColors themeColors = new ThemeColors(); if (imageSource is FileImageSource) { handler = new FileImageSourceHandler(); } else if (imageSource is StreamImageSource) { handler = new StreamImagesourceHandler(); // sic } else if (imageSource is UriImageSource) { handler = new ImageLoaderSourceHandler(); // sic } else { return(themeColors); } var bitmap = await handler.LoadImageAsync(imageSource, Android.App.Application.Context); if (bitmap == null) { return(themeColors); } Palette.Builder builder = Palette.From(bitmap); Palette palette = builder.Generate(); Swatch swatch = null; if (palette.VibrantSwatch != null) { swatch = palette.VibrantSwatch; } else if (palette.LightVibrantSwatch != null) { swatch = palette.LightVibrantSwatch; } else if (palette.LightMutedSwatch != null) { swatch = palette.LightMutedSwatch; } else if (palette.DarkVibrantSwatch != null) { swatch = palette.DarkVibrantSwatch; } else if (palette.DarkMutedSwatch != null) { swatch = palette.DarkMutedSwatch; } int bgcolor = 0, textcolor = 0, titltcolor = 0; if (swatch != null) { bgcolor = swatch.Rgb; textcolor = swatch.BodyTextColor; titltcolor = swatch.TitleTextColor; } themeColors.SetColor(bgcolor, textcolor, titltcolor); return(themeColors); }
public void ChangeColor(ThemeColors colors) { SetColor(colors); }
private void ChangeCurrentColor(ThemeColors themeColors) { currentColors = BuildColorBlock(themeColors); UpdateAllColors(); }
public static Color GetColor(Theme th, ThemeColors tr) { return(colors[Tuple.Create(th, tr)]); }
public void CustomColorsAndFonts() { //ExStart //ExFor:Document.Theme //ExFor:Theme //ExFor:Theme.Colors //ExFor:Theme.MajorFonts //ExFor:Theme.MinorFonts //ExFor:Themes.ThemeColors //ExFor:Themes.ThemeColors.Accent1 //ExFor:Themes.ThemeColors.Accent2 //ExFor:Themes.ThemeColors.Accent3 //ExFor:Themes.ThemeColors.Accent4 //ExFor:Themes.ThemeColors.Accent5 //ExFor:Themes.ThemeColors.Accent6 //ExFor:Themes.ThemeColors.Dark1 //ExFor:Themes.ThemeColors.Dark2 //ExFor:Themes.ThemeColors.FollowedHyperlink //ExFor:Themes.ThemeColors.Hyperlink //ExFor:Themes.ThemeColors.Light1 //ExFor:Themes.ThemeColors.Light2 //ExFor:Themes.ThemeFonts //ExFor:Themes.ThemeFonts.ComplexScript //ExFor:Themes.ThemeFonts.EastAsian //ExFor:Themes.ThemeFonts.Latin //ExSummary:Shows how to set custom theme colors and fonts. Document doc = new Document(MyDir + "Theme colors.docx"); // This object gives us access to the document theme, which is a source of default fonts and colors Theme theme = doc.Theme; // These fonts will be inherited by some styles like "Heading 1" and "Subtitle" theme.MajorFonts.Latin = "Courier New"; theme.MinorFonts.Latin = "Agency FB"; Assert.AreEqual(string.Empty, theme.MajorFonts.ComplexScript); Assert.AreEqual(string.Empty, theme.MajorFonts.EastAsian); Assert.AreEqual(string.Empty, theme.MinorFonts.ComplexScript); Assert.AreEqual(string.Empty, theme.MinorFonts.EastAsian); // This collection of colors corresponds to the color palette from Microsoft Word which appears when changing shading or font color ThemeColors colors = theme.Colors; // We will set the color of each color palette column going from left to right like this colors.Dark1 = Color.MidnightBlue; colors.Light1 = Color.PaleGreen; colors.Dark2 = Color.Indigo; colors.Light2 = Color.Khaki; colors.Accent1 = Color.OrangeRed; colors.Accent2 = Color.LightSalmon; colors.Accent3 = Color.Yellow; colors.Accent4 = Color.Gold; colors.Accent5 = Color.BlueViolet; colors.Accent6 = Color.DarkViolet; // We can also set colors for hyperlinks like this colors.Hyperlink = Color.Black; colors.FollowedHyperlink = Color.Gray; doc.Save(ArtifactsDir + "Themes.CustomColorsAndFonts.docx"); //ExEnd doc = new Document(ArtifactsDir + "Themes.CustomColorsAndFonts.docx"); Assert.AreEqual(Color.OrangeRed.ToArgb(), doc.Theme.Colors.Accent1.ToArgb()); Assert.AreEqual(Color.MidnightBlue.ToArgb(), doc.Theme.Colors.Dark1.ToArgb()); Assert.AreEqual(Color.Gray.ToArgb(), doc.Theme.Colors.FollowedHyperlink.ToArgb()); Assert.AreEqual(Color.Black.ToArgb(), doc.Theme.Colors.Hyperlink.ToArgb()); Assert.AreEqual(Color.PaleGreen.ToArgb(), doc.Theme.Colors.Light1.ToArgb()); Assert.AreEqual(string.Empty, doc.Theme.MajorFonts.ComplexScript); Assert.AreEqual(string.Empty, doc.Theme.MajorFonts.EastAsian); Assert.AreEqual("Courier New", doc.Theme.MajorFonts.Latin); Assert.AreEqual(string.Empty, doc.Theme.MinorFonts.ComplexScript); Assert.AreEqual(string.Empty, doc.Theme.MinorFonts.EastAsian); Assert.AreEqual("Agency FB", doc.Theme.MinorFonts.Latin); }