//
// (C) Copyright 2003-2019 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 polygon
///
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 argument
public virtual void OnRightMouseClick(Graphics graphic, MouseEventArgs e) { }
///
/// Mouse move event handler
///
/// Graphics object, used to draw geometry
/// Mouse event argument
public virtual void OnMouseMove(Graphics graphic, MouseEventArgs e) { }
///
/// Mouse down event handler
///
/// Graphics object, used to draw geometry
/// Mouse event argument
public virtual void OnMouseDown(Graphics graphic, MouseEventArgs e) { }
///
/// Mouse up event handler
///
/// Graphics object, used to draw geometry
/// Mouse event argument
public virtual void OnMouseUp(Graphics graphic, MouseEventArgs e) { }
///
/// Mouse middle key down event handler
///
/// Graphics object, used to draw geometry
/// Mouse event argument
public virtual void OnMidMouseDown(Graphics graphic, MouseEventArgs e)
{
this.m_points.Clear();
}
///
/// Draw geometries contained in the tool. which class derived from this class
/// must implement this abstract method
///
/// Graphics object, used to draw geometry
public abstract void Draw(Graphics graphic);
}
}