// // (C) Copyright 2003-2009 by Autodesk, Inc. // // Permission to use, copy, modify, and distribute this software in // object code form for any purpose and without fee is hereby granted, // provided that the above copyright notice appears in all copies and // that both that copyright notice and the limited warranty and // restricted rights notice below appear in all supporting // documentation. // // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. // using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Drawing; namespace Revit.SDK.Samples.NewOpenings.CS { /// /// stand for the draw tool type /// public enum ToolType { /// /// draw nothing /// None, /// /// draw polydon /// Line, /// /// draw rectangle /// Rectangle, /// /// draw circle /// Circle, /// /// draw arc /// Arc } /// /// abstract class use as base class of all draw tool class /// public abstract class ITool { # region members /// /// ToolType is enum type indicate draw tools. /// protected ToolType m_type; /// /// Field used to store points of a line /// protected List m_points = new List(); /// /// Field used to store lines /// protected List> m_lines = new List>(); /// /// background pen used to Erase the preview line /// protected Pen m_backGroundPen; /// /// // foreground pen used to draw lines /// protected Pen m_foreGroundPen; /// ///store the mouse position when mouse move in pictureBox /// protected Point m_preMovePoint; #endregion /// /// default constructor /// public ITool() { m_backGroundPen = Pens.White; m_foreGroundPen = Pens.Red; } /// /// get all lines drawn in pictureBox /// public List> GetLines() { return m_lines; } /// /// get the tool type /// public virtual ToolType ToolType { get { return m_type; } } /// /// right mouse click event handler /// /// Graphics object,used to draw geometry /// mouse event args public virtual void OnRightMouseClick(Graphics graphic, MouseEventArgs e) { } /// /// mouse move event handler /// /// Graphics object,used to draw geometry /// mouse event args public virtual void OnMouseMove(Graphics graphic, MouseEventArgs e) { } /// /// mouse down event handler /// /// Graphics object,used to draw geometry /// mouse event args public virtual void OnMouseDown(Graphics graphic, MouseEventArgs e) { } /// /// mouse up event handler /// /// Graphics object,used to graw geometry /// mouse event args public virtual void OnMouseUp(Graphics graphic, MouseEventArgs e) { } /// /// mouse middle key down event handler /// /// Graphics object,used to draw geometry /// mouse event args public virtual void OnMidMouseDown(Graphics graphic, MouseEventArgs e) { this.m_points.Clear(); } /// /// draw geometrys contained in the tool. which class derived from this class /// must implement this abstract method /// /// Graphics object,used to graw geometry public abstract void Draw(Graphics graphic); } }