8using System.Collections.Generic;
9using System.ComponentModel;
88 get => backgroundColor;
91 backgroundColor = value;
106 get => foregroundColor;
109 foregroundColor = value;
138 public Fill(
string foreground,
string background)
174 StringBuilder sb =
new StringBuilder();
175 sb.Append(
"\"Fill\": {\n");
179 AddPropertyAsJson(sb,
"HashCode", this.
GetHashCode(),
true);
181 return sb.ToString();
209 int hashCode = -1564173520;
210 hashCode = hashCode * -1521134295 + EqualityComparer<Color>.Default.GetHashCode(
BackgroundColor);
211 hashCode = hashCode * -1521134295 + EqualityComparer<Color>.Default.GetHashCode(
ForegroundColor);
212 hashCode = hashCode * -1521134295 +
PatternFill.GetHashCode();
224 return obj is
Fill fill &&
286 SetColor(GetColorByComponent(value), fillType);
290 #region staticMethods
295 public static implicit
operator Fill(
string value)
316 public static implicit
operator Fill(
int index)
330 internal static string GetPatternName(
PatternValue pattern)
342 output =
"mediumGray";
345 output =
"lightGray";
363 internal static PatternValue GetPatternEnum(
string name)
384 private static Color GetColorByComponent(IColor component)
386 if (component is SrgbColor)
388 return Color.CreateRgb((SrgbColor)component);
390 else if (component is IndexedColor)
392 return Color.CreateIndexed((IndexedColor)component);
394 else if (component is ThemeColor)
396 return Color.CreateTheme((ThemeColor)component);
398 else if (component is SystemColor)
400 return Color.CreateSystem((SystemColor)component);
404 return Color.CreateAuto();
Compound class representing a color in various representations (RGB, indexed, theme,...
static Color CreateIndexed(IndexedColor color)
Creates an Color from an indexed color.
static Color CreateRgb(SrgbColor color)
Creates an Color from an RGB/ARGB color.
Class representing an indexed color from the legacy OOXML / Excel indexed color palette.
Value
Legacy OOXML / Excel indexed color palette.
const Value DefaultIndexedColor
Default indexed color (system foreground color).
Class representing a generic sRGB color (with or without alpha channel).
const string DefaultSrgbColor
Default color value (opaque black: #000000).
Class represents an abstract style component.
FillType
Enum for the type of the color, used by the Fill class.
@ PatternColor
Color defines a pattern color.
@ FillColor
Color defines a solid fill color.
static readonly Color DefaultIndexedColor
Default index color.
Fill CopyFill()
Method to copy the current object to a new one with casting.
override bool Equals(object obj)
Returns whether two instances are the same.
Color BackgroundColor
Gets or sets the background color of the fill. The value is expressed as hex string with the format A...
Fill()
Default constructor.
static readonly PatternValue DefaultPatternFill
Default pattern.
static readonly Color DefaultColor
Default Color (foreground or background).
override int GetHashCode()
Returns a hash code for this instance.
void SetColor(string value, FillType fillType)
Sets the color depending on fill type, using a sRGB value (without alpha).
void SetColor(Color value, FillType fillType)
Sets the color depending on fill type, using a color object of the type Color.
override string ToString()
Override toString method.
void SetColor(IColor value, FillType fillType)
Sets the color depending on fill type, using a color object, deriving from IColor.
Fill(string value, FillType fillType)
Constructor with color value as sRGB and fill type.
override AbstractStyle Copy()
Method to copy the current object to a new one without casting.
PatternValue
Enum for the pattern values, used by the Fill class.
@ MediumGray
Medium gray fill.
@ Gray0625
6.25% gray fill
@ None
No pattern (default).
@ DarkGray
Dark gray fill.
@ Solid
Solid fill (for colors).
@ LightGray
Light gray fill.
Color ForegroundColor
Gets or sets the foreground color of the fill. The value is expressed as hex string with the format A...
PatternValue PatternFill
Gets or sets the pattern type of the fill (Default is none).
Fill(string foreground, string background)
Constructor with foreground and background color as sRGB values (without alpha).
Interface to represent non typed color, either defined by the system or the user.