123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- /*************************************************************************************************
- *****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
- {
- /// <summary>
- /// //FontData structure, set the Font Name, Size and Font style
- /// </summary>
- [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
- {
- ///// <summary>
- ///// construct a new pen
- ///// </summary>
- // static PenExt()
- // {
- // _penObj1 = new Pen(Color.Black,1);
- // }
- public PenExt()
- {
- this.color = Color.Black;//default color is black
- _penObj = new Pen(Color.Black, 1);
- }
- //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 _penObj1;
- private 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;
- }
- }
- }
- }
|