NanoXLSX.Core 3.0.0-rc.3
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;
9
10namespace NanoXLSX.Themes
11{
15 public class Theme
16 {
17
18 #region constants
26 public const string DefaultThemeVersion = "166925";
27
28 #endregion
29
30 #region enums
61 #endregion
62
66 public string Name { get; set; }
70 public ColorScheme Colors { get; set; }
71
76 public bool DefaultTheme { get; private set; }
77
82 public Theme(string name)
83 {
84 this.Name = name;
85 this.Colors = GetDefaultColorScheme();
86 }
87
88
93 internal static Theme GetDefaultTheme()
94 {
95 Theme theme = new Theme("default")
96 {
97 DefaultTheme = true
98 };
99 ColorScheme colors = GetDefaultColorScheme();
100 theme.Colors = colors;
101 return theme;
102 }
103
108 internal static ColorScheme GetDefaultColorScheme()
109 {
110 ColorScheme colors = new ColorScheme
111 {
112 Name = "default",
113 Dark1 = new SystemColor(SystemColor.Value.WindowText),
114 Light1 = new SystemColor(SystemColor.Value.Window, "FFFFFF"),
115 Dark2 = new SrgbColor("44546A"),
116 Light2 = new SrgbColor("E7E6E6"),
117 Accent1 = new SrgbColor("4472C4"),
118 Accent2 = new SrgbColor("ED7D31"),
119 Accent3 = new SrgbColor("A5A5A5"),
120 Accent4 = new SrgbColor("FFC000"),
121 Accent5 = new SrgbColor("5B9BD5"),
122 Accent6 = new SrgbColor("70AD47"),
123 Hyperlink = new SrgbColor("0563C1"),
124 FollowedHyperlink = new SrgbColor("954F72")
125 };
126 return colors;
127 }
128
134 public override bool Equals(object obj)
135 {
136 return obj is Theme theme &&
137 Name == theme.Name &&
138 EqualityComparer<ColorScheme>.Default.Equals(Colors, theme.Colors);
139 }
140
147 public override int GetHashCode()
148 {
149 unchecked
150 {
151 int hashCode = 1172093127;
152 hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
153 hashCode = hashCode * -1521134295 + EqualityComparer<ColorScheme>.Default.GetHashCode(Colors);
154 return hashCode;
155 }
156 }
157 }
158}
Class representing a color scheme, used in a theme.
Class representing an Office theme.
Definition Theme.cs:16
override int GetHashCode()
Returns a hash code for this instance.
Definition Theme.cs:147
ColorSchemeElement
Enum to define the sequence index of color scheme element, used in the implementations of Interfaces....
Definition Theme.cs:35
@ FollowedHyperlink
Followed Hyperlink.
Definition Theme.cs:59
ColorScheme Colors
Gets or sets the ColorScheme of the theme.
Definition Theme.cs:70
const string DefaultThemeVersion
Default theme ID, stated in the workbook document.
Definition Theme.cs:26
string Name
Gets or sets the name of the theme.
Definition Theme.cs:66
override bool Equals(object obj)
Returns whether two instances are the same.
Definition Theme.cs:134
bool DefaultTheme
Gets whether the theme is defined as copy or reference to the application default theme.
Definition Theme.cs:76
Theme(string name)
Constructor with parameters. Using this constructor initialized the Colors property with valid defaul...
Definition Theme.cs:82