NanoXLSX.Core 3.0.0-rc.4
Loading...
Searching...
No Matches
Theme.cs
1/*
2 * NanoXLSX is a small .NET library to generate and read XLSX (Microsoft Excel 2007 or newer) files in an easy and native way
3 * Copyright Raphael Stoeckli © 2025
4 * This library is licensed under the MIT License.
5 * You find a copy of the license in project folder or on: http://opensource.org/licenses/MIT
6 */
7
8using System.Collections.Generic;
10
11namespace NanoXLSX.Themes
12{
16 public class Theme
17 {
18
19 #region constants
27 public const string DefaultThemeVersion = "166925";
28
29 #endregion
30
31 #region enums
62 #endregion
63
67 public string Name { get; set; }
71 public ColorScheme Colors { get; set; }
72
77 public bool DefaultTheme { get; private set; }
78
83 public Theme(string name)
84 {
85 this.Name = name;
86 this.Colors = GetDefaultColorScheme();
87 }
88
89
94 internal static Theme GetDefaultTheme()
95 {
96 Theme theme = new Theme("default")
97 {
98 DefaultTheme = true
99 };
100 ColorScheme colors = GetDefaultColorScheme();
101 theme.Colors = colors;
102 return theme;
103 }
104
109 internal static ColorScheme GetDefaultColorScheme()
110 {
111 ColorScheme colors = new ColorScheme
112 {
113 Name = "default",
114 Dark1 = new SystemColor(SystemColor.Value.WindowText),
115 Light1 = new SystemColor(SystemColor.Value.Window, "FFFFFF"),
116 Dark2 = new SrgbColor("44546A"),
117 Light2 = new SrgbColor("E7E6E6"),
118 Accent1 = new SrgbColor("4472C4"),
119 Accent2 = new SrgbColor("ED7D31"),
120 Accent3 = new SrgbColor("A5A5A5"),
121 Accent4 = new SrgbColor("FFC000"),
122 Accent5 = new SrgbColor("5B9BD5"),
123 Accent6 = new SrgbColor("70AD47"),
124 Hyperlink = new SrgbColor("0563C1"),
125 FollowedHyperlink = new SrgbColor("954F72")
126 };
127 return colors;
128 }
129
135 public override bool Equals(object obj)
136 {
137 return obj is Theme theme &&
138 Name == theme.Name &&
139 EqualityComparer<ColorScheme>.Default.Equals(Colors, theme.Colors);
140 }
141
148 public override int GetHashCode()
149 {
150 unchecked
151 {
152 int hashCode = 1172093127;
153 hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
154 hashCode = hashCode * -1521134295 + EqualityComparer<ColorScheme>.Default.GetHashCode(Colors);
155 return hashCode;
156 }
157 }
158 }
159}
Class representing a generic sRGB color (with or without alpha channel).
Definition SrgbColor.cs:20
Class representing a color scheme, used in a theme.
Class representing an Office theme.
Definition Theme.cs:17
override int GetHashCode()
Returns a hash code for this instance.
Definition Theme.cs:148
ColorSchemeElement
Enum to define the sequence index of color scheme element, used in the implementations of Interfaces....
Definition Theme.cs:36
@ FollowedHyperlink
Followed Hyperlink.
Definition Theme.cs:60
ColorScheme Colors
Gets or sets the ColorScheme of the theme.
Definition Theme.cs:71
const string DefaultThemeVersion
Default theme ID, stated in the workbook document.
Definition Theme.cs:27
string Name
Gets or sets the name of the theme.
Definition Theme.cs:67
override bool Equals(object obj)
Returns whether two instances are the same.
Definition Theme.cs:135
bool DefaultTheme
Gets whether the theme is defined as copy or reference to the application default theme.
Definition Theme.cs:77
Theme(string name)
Constructor with parameters. Using this constructor initialized the Colors property with valid defaul...
Definition Theme.cs:83