public abstract class Shape { //Fields private const int BORDER_WIDTH = 5; private bool _showBorder = true; private Color _color; private Point _location; public Control _BaseCanvas; private bool _isSelected; //Properties public bool IsSelected { get { return _isSelected; } set { _isSelected = value; } } public float BorderWidth { get { return BORDER_WIDTH; } } public bool ShowBorder { get { return _showBorder; } set { _showBorder = value; } } public Color Color { get { return _color; } set { _color = value; } } public int Xposition { get { return _location.X; } set { _location.X = value; } } public int Yposition { get { return _location.Y; } set { _location.Y = value; } } public Point Location { get { return _location; } set { _location = value; } } public static Shape self; /// <summary> /// Default Constructor /// </summary> public Shape(Control refCanvas) { _BaseCanvas = refCanvas; _color = Color.Black; self = this; } /// <summary> /// Constructor with Position /// </summary> /// <param name="x"></param> /// <param name="y"></param> public Shape(Control refCanvas, Point location) : this(refCanvas) { _location = location; } public abstract void Draw(); // public abstract void Paint(); } //Inherits form Base Class Shape class Square : Shape { // Protected field members protected int _size; //Public Properties public int Size { get { return _size; } set { _size = value; } } /// <summary> /// Constructor with base form initialization /// </summary> /// <param name="ContainerForm"></param> public Square(Control objControl) : base(objControl) { } public Square(Control objControl, Point location) : base(objControl, location) { } /// <summary> /// Function to draw Square /// </summary> public override void Draw() { Graphics g = _BaseCanvas.CreateGraphics(); Pen p = new Pen(Color); p.Width = BorderWidth; g.DrawRectangle(p, Xposition, Yposition, _size, _size); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)