public ColumnStyle(ColumnStyleType type) { _cellPen = new PenX(GdiColorHelper.ToNamedColor(SystemColors.InactiveBorder), 1) { ParentObject = this }; _textBrush = new BrushX(GdiColorHelper.ToNamedColor(SystemColors.WindowText)) { ParentObject = this }; _backgroundBrush = new BrushX(GdiColorHelper.ToNamedColor(SystemColors.Window)) { ParentObject = this }; _columnStyleType = type; SetDefaultCellBorder(); SetDefaultBackgroundBrush(); SetDefaultTextBrush(); SetDefaultTextFont(); }
/// <summary> /// Copies the properties of another instance to this instance. /// </summary> /// <param name="pen">the PenHolder object to copy</param> public void CopyFrom(PenX pen) { if (object.ReferenceEquals(this, pen)) return; _SetPenVariable(null); this._configuredProperties = pen._configuredProperties; this._penType = pen.PenType; this._alignment = pen.Alignment; if (0 != (this._configuredProperties & Configured.Brush)) this._brush = new BrushX(pen._brush); this._color = pen.Color; if (null != pen._compoundArray) this._compoundArray = (float[])pen.CompoundArray.Clone(); else this._compoundArray = null; this._dashPattern = pen._dashPattern; // immutable this._dashCap = pen._dashCap; this._cachedDashStyle = pen._cachedDashStyle; if (null != pen._cachedDashPattern) this._cachedDashPattern = (float[])pen._cachedDashPattern.Clone(); else this._cachedDashPattern = null; this._cachedDashOffset = pen._cachedDashOffset; this._endCap = pen.EndCap; this._lineJoin = pen.LineJoin; this._miterLimit = pen.MiterLimit; this._startCap = pen.StartCap; if (null != pen._transformation) this._transformation = pen.Transform.Clone(); else this._transformation = null; this._width = pen.Width; // note: there is an problem with Pen.Clone() : if the Color of the pen // was set to a known color, the color of the cloned pen is the same, but no longer a known color // therefore we avoid the cloning of the pen here // if(m_CachedMode && null!=pen.m_Pen) // _SetPenVariable( (Pen)pen.m_Pen.Clone() ); // else // _SetPenVariable(null); }
public ColumnStyle(ColumnStyle s) { _columnStyleType = s._columnStyleType; m_Size = s.m_Size; _isCellPenCustom = s._isCellPenCustom; m_CellPen = (PenX)s.m_CellPen.Clone(); m_TextFormat = (StringFormat)s.m_TextFormat.Clone(); m_TextFont = (Font)s.m_TextFont.Clone(); _isTextBrushCustom = s._isTextBrushCustom; m_TextBrush = (BrushX)s.m_TextBrush.Clone(); _isBackgroundBrushCustom = s._isBackgroundBrushCustom; m_BackgroundBrush = (BrushX)s.m_BackgroundBrush.Clone(); }
protected static Configured _GetConfiguredPropertiesVariable(PenX pen) { Configured c = Configured.IsNull; if (null == pen || pen._configuredProperties == 0) return c; // Pen is null, so nothing is configured c |= Configured.IsNotNull; // Pen is at least not null if (pen.PenType != PenType.SolidColor) c |= Configured.PenType; if (pen.PenType == PenType.SolidColor && pen.Color != NamedColors.Black) c |= Configured.Color; if (pen.PenType != PenType.SolidColor) c |= Configured.Brush; if (pen.Alignment != PenAlignment.Center) c |= Configured.Alignment; if (pen.CompoundArray != null && pen.CompoundArray.Length > 0) c |= Configured.CompoundArray; if (pen._cachedDashStyle != DashStyle.Solid) c |= Configured.DashStyle; if (pen._cachedDashStyle != DashStyle.Solid && pen.DashCap != DashCap.Flat) c |= Configured.DashCap; if (pen._cachedDashStyle != DashStyle.Solid && pen._cachedDashOffset != 0) c |= Configured.DashOffset; if (pen._cachedDashStyle == DashStyle.Custom && pen._cachedDashPattern != null) c |= Configured.DashPattern; if (!pen.EndCap.IsDefaultStyle) c |= Configured.EndCap; if (!pen.StartCap.IsDefaultStyle) c |= Configured.StartCap; if (pen.LineJoin != LineJoin.Miter) c |= Configured.LineJoin; if (pen.MiterLimit != 10) c |= Configured.MiterLimit; if (null != pen.Transform && !pen.Transform.IsIdentity) c |= Configured.Transform; if (pen.Width != 1) c |= Configured.Width; return c; }
/// <summary> /// Copy constructor of PenHolder /// </summary> /// <param name="pen">the PenHolder object to copy</param> public PenX(PenX pen) { CopyFrom(pen); }
public static bool AreEqual(PenX p1, PenX p2) { if (p1 == null && p2 == null) return true; if (p1 == null || p2 == null) return false; if (object.ReferenceEquals(p1, p2)) return true; if (p1._configuredProperties != p2._configuredProperties) return false; Configured diff = GetDifferences(p1, p2); return diff == 0; }
public static bool AreEqualUnlessWidth(PenX p1, PenX p2) { if (p1 == null && p2 == null) return true; if (p1 == null || p2 == null) return false; if (object.ReferenceEquals(p1, p2)) return true; Configured c1 = p1._configuredProperties; Configured c2 = p2._configuredProperties; c1 = SetProp(c1, Configured.Width, false); c2 = SetProp(c2, Configured.Width, false); if (c1 != c2) return false; Configured diff = GetDifferences(p1, p2); diff = SetProp(diff, Configured.Width, false); return diff == 0; }
/// <summary> /// Returns all differences between two pens as a flagged enum. /// </summary> /// <param name="p1">First pen to compare.</param> /// <param name="p2">Second pen to comare.</param> /// <returns>A enum where all those bits are set where the two pens are different.</returns> public static Configured GetDifferences(PenX p1, PenX p2) { Configured cp1 = p1._configuredProperties; Configured cp2 = p2._configuredProperties; Configured cp = cp1 & cp2; // for all properties that are configured both in p1 and p2, test if they are equal // now set the optional Pen properties if (0 != (cp & PenX.Configured.IsNotNull)) cp = SetProp(cp, Configured.IsNotNull, false); if (0 != (cp & PenX.Configured.Width)) cp = SetProp(cp, PenX.Configured.Width, p1._width != p2._width); if (0 != (cp & PenX.Configured.Alignment)) cp = SetProp(cp, PenX.Configured.Alignment, p1._alignment != p2._alignment); if (0 != (cp & PenX.Configured.Color)) cp = SetProp(cp, PenX.Configured.Color, p1._color != p2._color); if (0 != (cp & PenX.Configured.Brush)) cp = SetProp(cp, PenX.Configured.Brush, !BrushX.AreEqual(p1._brush, p2._brush)); if (0 != (cp & PenX.Configured.CompoundArray)) cp = SetProp(cp, PenX.Configured.CompoundArray, !AreEqual(p1._compoundArray, p2._compoundArray)); if (0 != (cp & PenX.Configured.DashStyle)) cp = SetProp(cp, PenX.Configured.DashStyle, p1._cachedDashStyle != p2._cachedDashStyle); if (0 != (cp & PenX.Configured.DashCap)) cp = SetProp(cp, PenX.Configured.DashCap, p1._dashCap != p2._dashCap); if (0 != (cp & PenX.Configured.DashOffset)) cp = SetProp(cp, PenX.Configured.DashOffset, p1._cachedDashOffset != p2._cachedDashOffset); if (0 != (cp & PenX.Configured.DashPattern)) cp = SetProp(cp, PenX.Configured.DashPattern, !AreEqual(p1._cachedDashPattern, p2._cachedDashPattern)); if (0 != (cp & PenX.Configured.EndCap)) cp = SetProp(cp, PenX.Configured.EndCap, p1._endCap != p2._endCap); if (0 != (cp & PenX.Configured.LineJoin)) cp = SetProp(cp, PenX.Configured.LineJoin, p1._lineJoin != p2._lineJoin); if (0 != (cp & PenX.Configured.MiterLimit)) cp = SetProp(cp, PenX.Configured.MiterLimit, p1._miterLimit != p2._miterLimit); if (0 != (cp & PenX.Configured.StartCap)) cp = SetProp(cp, PenX.Configured.StartCap, p1._startCap != p2._startCap); if (0 != (cp & PenX.Configured.Transform)) cp = SetProp(cp, PenX.Configured.Transform, p1._transformation != p2._transformation); return cp | (cp1 ^ cp2); }
public PenAllPropertiesController(PenX doc) { _doc = doc; Initialize(true); }
public bool Apply(bool disposeController) { _doc = _view.Pen; return true; }
/// <summary> /// Copies the properties of another instance to this instance. /// </summary> /// <param name="pen">the PenHolder object to copy</param> public void CopyFrom(PenX pen) { _SetPenVariable(null); this.m_ConfiguredProperties = pen.m_ConfiguredProperties; this.m_PenType = pen.PenType; this.m_Alignment = pen.Alignment; if (0 != (this.m_ConfiguredProperties & Configured.Brush)) this.m_Brush = new BrushX(pen.m_Brush); this.m_Color = pen.Color; if (null != pen.m_CompoundArray) this.m_CompoundArray = (float[])pen.CompoundArray.Clone(); else this.m_CompoundArray = null; this.m_DashCap = pen.DashCap; this.m_DashOffset = pen.DashOffset; if (null != pen.m_DashPattern) this.m_DashPattern = (float[])pen.DashPattern.Clone(); else this.m_DashPattern = null; this.m_DashStyle = pen.DashStyle; this.m_EndCap = pen.EndCap; this.m_LineJoin = pen.LineJoin; this.m_MiterLimit = pen.MiterLimit; this.m_StartCap = pen.StartCap; if (null != pen.m_Transform) this.m_Transform = pen.Transform.Clone(); else this.m_Transform = null; this.m_Width = pen.Width; // note: there is an problem with Pen.Clone() : if the Color of the pen // was set to a known color, the color of the cloned pen is the same, but no longer a known color // therefore we avoid the cloning of the pen here // if(m_CachedMode && null!=pen.m_Pen) // _SetPenVariable( (Pen)pen.m_Pen.Clone() ); // else // _SetPenVariable(null); }
public ColorTypeThicknessPenController(PenX doc) { if (doc == null) throw new ArgumentNullException("doc"); _doc = doc; _tempDoc = (PenX)doc.Clone(); }