// Get the toolkit version of this brush for a specific toolkit. internal IToolkitBrush GetBrush(IToolkit toolkit) { lock (this) { if (this.toolkitBrush == null) { // We don't yet have a toolkit brush yet. this.toolkitBrush = CreateBrush(toolkit); this.toolkit = toolkit; return(this.toolkitBrush); } else if (this.toolkit == toolkit) { // Same toolkit - return the cached brush information. return(this.toolkitBrush); } else { // We have a brush for another toolkit, // so dispose it and create for this toolkit. // We null out "toolkitBrush" before calling // "CreateBrush()" just in case an exception // is thrown while creating the toolkit brush. this.toolkitBrush.Dispose(); this.toolkitBrush = null; this.toolkitBrush = CreateBrush(toolkit); this.toolkit = toolkit; return(this.toolkitBrush); } } }
public DrawingXorBrush(IToolkit toolkit, IToolkitBrush innerBrush) : base(toolkit, System.Drawing.Color.Black) { // TODO: create the XOR brush. this.innerBrush = innerBrush; hBrush = IntPtr.Zero; }
// Select a brush-based pen into a graphics object. public override void Select(IToolkitGraphics graphics, IToolkitBrush brush) { // Set the basic line information first. Select(graphics); // Select the brush details into the graphics context. brush.Select(graphics); }
protected virtual void Dispose(bool disposing) { lock(this) { if(toolkitBrush != null) { toolkitBrush.Dispose(); toolkitBrush = null; } } }
protected virtual void Dispose(bool disposing) { lock (this) { if (toolkitBrush != null) { toolkitBrush.Dispose(); toolkitBrush = null; } } }
// Mark this brush as modified, and flush all previous brush information. // Used when a subclass modifies a brush's properties. internal void Modified() { lock(this) { if(toolkitBrush != null) { toolkitBrush.Dispose(); toolkitBrush = null; } toolkit = null; } }
// Mark this brush as modified, and flush all previous brush information. // Used when a subclass modifies a brush's properties. internal void Modified() { lock (this) { if (toolkitBrush != null) { toolkitBrush.Dispose(); toolkitBrush = null; } toolkit = null; } }
// Select a brush-based pen into a graphics object. public override void Select(IToolkitGraphics graphics, IToolkitBrush brush) { Select(graphics); }
// Constructor. internal Brush() { toolkit = null; toolkitBrush = null; }
// Constructor. public DrawingXorBrush(IToolkitBrush innerBrush) : base(System.Drawing.Color.Black) { this.innerBrush = innerBrush; }
public abstract void Select(IToolkitGraphics graphics, IToolkitBrush brush);
// Create this brush for a specific toolkit. Inner part of "GetBrush()". internal override IToolkitBrush CreateBrush(IToolkit toolkit) { IToolkitBrush innerBrush = brush.GetBrush(toolkit); return(toolkit.CreateXorBrush(innerBrush)); }
// Select a brush-based pen into a graphics object. public void Select(IToolkitGraphics graphics, IToolkitBrush brush) { Select(graphics); // TODO: select the brush information }
public IToolkitBrush CreateXorBrush(IToolkitBrush innerBrush) { throw new NotImplementedException(); }
// Create an XOR brush. public virtual IToolkitBrush CreateXorBrush(IToolkitBrush innerBrush) { return null; }
// Get the toolkit version of this brush for a specific toolkit. internal IToolkitBrush GetBrush(IToolkit toolkit) { lock(this) { if(this.toolkitBrush == null) { // We don't yet have a toolkit brush yet. this.toolkitBrush = CreateBrush(toolkit); this.toolkit = toolkit; return this.toolkitBrush; } else if(this.toolkit == toolkit) { // Same toolkit - return the cached brush information. return this.toolkitBrush; } else { // We have a brush for another toolkit, // so dispose it and create for this toolkit. // We null out "toolkitBrush" before calling // "CreateBrush()" just in case an exception // is thrown while creating the toolkit brush. this.toolkitBrush.Dispose(); this.toolkitBrush = null; this.toolkitBrush = CreateBrush(toolkit); this.toolkit = toolkit; return this.toolkitBrush; } } }
// Create an XOR brush. public virtual IToolkitBrush CreateXorBrush(IToolkitBrush innerBrush) { return(null); }
// Create an XOR brush. public IToolkitBrush CreateXorBrush(IToolkitBrush innerBrush) { return new DrawingXorBrush(innerBrush); }
public void Select(IToolkitGraphics graphics, IToolkitBrush brush) { graphics.Pen = this; }
// Create an XOR brush. public IToolkitBrush CreateXorBrush(IToolkitBrush innerBrush) { return(new DrawingXorBrush(innerBrush)); }