/************************************************************************************************* *****File Name : PENEXT.CS, Version : 1.0, 8 November 2004**************************************** *******************Author : Siva Kovvuri********************************************************* **This class represents the functionality of a pen object. This class extends the pen class ** **from the System.Drawing. It encapsulates functionality for defining the color, width for ** **the pen object. It includes methods for defining the default pen object with color black ** **and pen object with any color. ** **The FontData structure sets the name, type and size of the fonts. ** ** ** *************************************************************************************************/ using System; using System.Drawing; using System.Drawing.Drawing2D; using System.ComponentModel; using System.Drawing.Design; using System.Windows.Forms; using System.Windows.Forms.Design; //Namespace BaseDef, include BrushExt, PenExt, FontData namespace GraEditor.BaseDef { /// /// //FontData structure, set the Font Name, Size and Font style /// [Serializable] public struct FontData { public FontData(Font font) { this.Name = font.Name; //Name this.Size = font.SizeInPoints;//Size; this.Style = font.Style;//Syle } public string Name; public float Size; public FontStyle Style; public bool IsEmpty() //No font { return Name.Length == 0 || Size <= 0; } } //Define our own Pen class, use it to store the color, width, dash style. public class PenExt { /// /// construct a new pen /// static PenExt() { _penObj = new Pen(Color.Black,1); } public PenExt() { this.color = Color.Black;//default color is black } //set color public PenExt(Color c) { this.color = c; } //set color, width and dash style public PenExt(Color c,int w,DashStyle s) :this(c) { this.width = w; this.dashStyle = s; } private static Pen _penObj; //static Pen variable public Pen Pen //send the color, width, dash style of PenExt to pen variable { get { _penObj.Color = this.Color; //send color to pen variable _penObj.Width = this.Width;//send width to pen variable _penObj.DashStyle = this.dashStyle;//send dash style to pen variable return _penObj; } set { if(value == null) return; color = value.Color; // set the color of PenExt with Pen's color width = value.Width;// set the width of PenExt with Pen's width dashStyle = value.DashStyle;//// set the dash style of PenExt with Pen's style } } protected Color color; //Color property of PenExt public Color Color { get { return color; } set { if( value == color) return; color = value; } } protected float width; // width property of PenExt public float Width { get { return width; } set { if( value == width) return; width = value; } } protected DashStyle dashStyle; //dash styple property of PenExt public DashStyle DashStyle { get { return dashStyle; } set { if(value == dashStyle) return; if(dashStyle == DashStyle.Custom) return; dashStyle = value; } } } }