namespace com.azkoss.excellite { using System; using System.Drawing; /// ///Contains fill pattern settings. /// public sealed class ExcelFillPattern { // Methods internal ExcelFillPattern(CellStyle parent) { this.parent = parent; } internal void CopyTo(CellStyle destination) { destination.Element.PatternStyle = this.parent.Element.PatternStyle; destination.Element.PatternForegroundColor = this.parent.Element.PatternForegroundColor; destination.Element.PatternBackgroundColor = this.parent.Element.PatternBackgroundColor; destination.UseFlags &= ((CellStyleData.Properties) (-29)); destination.UseFlags |= (this.parent.UseFlags & CellStyleData.Properties.PatternRelated); } /// ///Sets complex (non-empty and non-solid) pattern. /// ///Pattern style. ///Foreground color. ///Background color. /// ///

For solid pattern, just use SetSolid method.

///

To clear fill pattern, just set PatternStyle ///to FillPatternStyle.None

///
public void SetPattern(FillPatternStyle patternStyle, Color foregroundColor, Color backgroundColor) { this.PatternStyle = patternStyle; this.PatternForegroundColor = foregroundColor; this.PatternBackgroundColor = backgroundColor; } /// ///Sets solid pattern using specified fill color. /// ///Fill color. /// ///This will set PatternStyle to ///FillPatternStyle.Solid and ///PatternForegroundColor ///to fillColor. /// public void SetSolid(Color fillColor) { this.PatternStyle = FillPatternStyle.Solid; this.PatternForegroundColor = fillColor; } // Properties /// ///Get or sets fill pattern background color. /// /// public Color PatternBackgroundColor { get { return this.parent.Element.PatternBackgroundColor; } set { this.parent.BeforeChange(); this.parent.Element.PatternBackgroundColor = value; this.parent.UseFlags |= CellStyleData.Properties.PatternBackgroundColor; } } /// ///Get or sets fill pattern foreground color. /// /// public Color PatternForegroundColor { get { return this.parent.Element.PatternForegroundColor; } set { this.parent.BeforeChange(); this.parent.Element.PatternForegroundColor = value; this.parent.UseFlags |= CellStyleData.Properties.PatternForegroundColor; } } /// ///Gets or sets fill pattern style. /// /// ///If you set this property to anything else than ///FillPatternStyle.None, ///PatternForegroundColor and/or ///PatternBackgroundColor should also be set (if color is ///different from default Color.Black. /// public FillPatternStyle PatternStyle { get { return this.parent.Element.PatternStyle; } set { this.parent.BeforeChange(); this.parent.Element.PatternStyle = value; this.parent.UseFlags |= CellStyleData.Properties.PatternStyle; } } // Fields private CellStyle parent; } }