Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/22/10 00:44:01 (14 years ago)
Author:
swagner
Message:

Sorted usings and removed unused usings in entire solution (#1094)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/AbstractDrawingTool.cs

    r2768 r4068  
    11using System.Drawing;
    22using System.Windows.Forms;
    3 using System.Diagnostics;
    43
    5 namespace Netron.Diagramming.Core
    6 {
     4namespace Netron.Diagramming.Core {
     5  /// <summary>
     6  /// The base class for a drawing tool.
     7  /// </summary>
     8  public abstract class AbstractDrawingTool :
     9      AbstractTool,
     10      IMouseListener,
     11      IKeyboardListener {
     12
     13    #region Fields
     14
     15    // ------------------------------------------------------------------
    716    /// <summary>
    8     /// The base class for a drawing tool.
     17    /// The starting point of the rectangle being drawn.
    918    /// </summary>
    10     public abstract class AbstractDrawingTool :
    11         AbstractTool,
    12         IMouseListener,
    13         IKeyboardListener
    14     {
     19    // ------------------------------------------------------------------
     20    protected Point startingPoint;
    1521
    16         #region Fields
     22    // ------------------------------------------------------------------
     23    /// <summary>
     24    /// Says whether the startingPoint was set, otherwise the ghost will
     25    /// appear even before an initial point was set!
     26    /// </summary>
     27    // ------------------------------------------------------------------
     28    protected bool started;
    1729
    18         // ------------------------------------------------------------------
    19         /// <summary>
    20         /// The starting point of the rectangle being drawn.
    21         /// </summary>
    22         // ------------------------------------------------------------------
    23         protected Point startingPoint;
    24 
    25         // ------------------------------------------------------------------
    26         /// <summary>
    27         /// Says whether the startingPoint was set, otherwise the ghost will
    28         /// appear even before an initial point was set!
    29         /// </summary>
    30         // ------------------------------------------------------------------
    31         protected bool started;
    32 
    33         // ------------------------------------------------------------------
    34         /// <summary>
    35         /// The actual rectangle which serves as a basis for the drawing of
    36         /// ellipses, rectangles, etc.
    37         /// </summary>
    38         // ------------------------------------------------------------------
    39         private RectangleF mRectangle;
     30    // ------------------------------------------------------------------
     31    /// <summary>
     32    /// The actual rectangle which serves as a basis for the drawing of
     33    /// ellipses, rectangles, etc.
     34    /// </summary>
     35    // ------------------------------------------------------------------
     36    private RectangleF mRectangle;
    4037
    4138
    42         #endregion
     39    #endregion
    4340
    44         #region Properties
    45         protected RectangleF Rectangle
    46         {
    47             get { return mRectangle; }
    48             set { mRectangle = value; }
    49         }
     41    #region Properties
     42    protected RectangleF Rectangle {
     43      get { return mRectangle; }
     44      set { mRectangle = value; }
     45    }
    5046
    5147
    5248
    53         #endregion
     49    #endregion
    5450
    55         #region Constructor
    56         /// <summary>
    57         /// Default constructor
    58         /// </summary>
    59         /// <param name="name"></param>
    60         protected AbstractDrawingTool(string name)
    61             : base(name)
    62         {
    63         }
    64         #endregion
     51    #region Constructor
     52    /// <summary>
     53    /// Default constructor
     54    /// </summary>
     55    /// <param name="name"></param>
     56    protected AbstractDrawingTool(string name)
     57      : base(name) {
     58    }
     59    #endregion
    6560
    66         #region Methods
     61    #region Methods
    6762
    68         protected override void OnActivateTool()
    69         {
     63    protected override void OnActivateTool() {
    7064
    71             Controller.View.CurrentCursor = CursorPalette.Add;
     65      Controller.View.CurrentCursor = CursorPalette.Add;
    7266
    73         }
     67    }
    7468
    75         protected override void OnDeactivateTool()
    76         {
     69    protected override void OnDeactivateTool() {
    7770
    78             base.OnDeactivateTool();
    79         }
     71      base.OnDeactivateTool();
     72    }
    8073
    81         #region Explicit implementation of IKeyboardListener
    82         void IKeyboardListener.KeyDown(KeyEventArgs e)
    83         {
    84             OnKeyDown(e);
    85         }
     74    #region Explicit implementation of IKeyboardListener
     75    void IKeyboardListener.KeyDown(KeyEventArgs e) {
     76      OnKeyDown(e);
     77    }
    8678
    87         void IKeyboardListener.KeyUp(KeyEventArgs e)
    88         {
    89             OnKeyUp(e);
    90         }
     79    void IKeyboardListener.KeyUp(KeyEventArgs e) {
     80      OnKeyUp(e);
     81    }
    9182
    92         void IKeyboardListener.KeyPress(KeyPressEventArgs e)
    93         {
    94             OnKeyPress(e);
    95         }
     83    void IKeyboardListener.KeyPress(KeyPressEventArgs e) {
     84      OnKeyPress(e);
     85    }
    9686
    97         protected virtual void OnKeyDown(KeyEventArgs e)
    98         {
    99             //if (e.Handled) return;
     87    protected virtual void OnKeyDown(KeyEventArgs e) {
     88      //if (e.Handled) return;
    10089
    101             if (e.KeyData == Keys.Escape)
    102             {
    103                 DeactivateTool();
    104                 Controller.View.ResetGhost();
    105                 e.Handled = true;
    106             }
    107         }
    108         protected virtual void OnKeyUp(KeyEventArgs e)
    109         {
    110             if (e.Handled) return;
    111         }
     90      if (e.KeyData == Keys.Escape) {
     91        DeactivateTool();
     92        Controller.View.ResetGhost();
     93        e.Handled = true;
     94      }
     95    }
     96    protected virtual void OnKeyUp(KeyEventArgs e) {
     97      if (e.Handled) return;
     98    }
    11299
    113         protected virtual void OnKeyPress(KeyPressEventArgs e)
    114         {
    115             if (e.Handled) return;
    116         }
    117         #endregion
     100    protected virtual void OnKeyPress(KeyPressEventArgs e) {
     101      if (e.Handled) return;
     102    }
     103    #endregion
    118104
    119         #region Explicit implementation of IMouseListener
    120         bool IMouseListener.MouseDown(MouseEventArgs e)
    121         {
    122             return OnMouseDown(e);
    123         }
     105    #region Explicit implementation of IMouseListener
     106    bool IMouseListener.MouseDown(MouseEventArgs e) {
     107      return OnMouseDown(e);
     108    }
    124109
    125         void IMouseListener.MouseMove(MouseEventArgs e)
    126         {
    127             OnMouseMove(e);
    128         }
     110    void IMouseListener.MouseMove(MouseEventArgs e) {
     111      OnMouseMove(e);
     112    }
    129113
    130         void IMouseListener.MouseUp(MouseEventArgs e)
    131         {
    132             OnMouseUp(e);
    133         }
     114    void IMouseListener.MouseUp(MouseEventArgs e) {
     115      OnMouseUp(e);
     116    }
    134117
    135118
    136         protected virtual bool OnMouseDown(MouseEventArgs e)
    137         {
    138             if (IsActive && e.Button == MouseButtons.Left)
    139             {
    140                 startingPoint = new Point(e.X, e.Y);
    141                 started = true;
    142                 return true;
    143             }
    144             return false;
    145         }
     119    protected virtual bool OnMouseDown(MouseEventArgs e) {
     120      if (IsActive && e.Button == MouseButtons.Left) {
     121        startingPoint = new Point(e.X, e.Y);
     122        started = true;
     123        return true;
     124      }
     125      return false;
     126    }
    146127
    147         protected virtual void OnMouseMove(MouseEventArgs e)
    148         {
     128    protected virtual void OnMouseMove(MouseEventArgs e) {
    149129
    150         }
     130    }
    151131
    152         protected virtual void OnMouseUp(MouseEventArgs e)
    153         {
    154             if ((IsActive) &&
    155                 (started) &&
    156                 (Controller.View.Ghost != null))
    157             {
     132    protected virtual void OnMouseUp(MouseEventArgs e) {
     133      if ((IsActive) &&
     134          (started) &&
     135          (Controller.View.Ghost != null)) {
    158136
    159                 //base.RestoreCursor();
    160                 Point point = new Point(e.X, e.Y);
    161                 //mRectangle = new Rectangle(startingPoint.X, startingPoint.Y, point.X - startingPoint.X, point.Y - startingPoint.Y);
    162                 //mRectangle = base.Controller.View.ViewToWorld(base.Controller.View.DeviceToView(rectangle));
    163                 mRectangle = Controller.View.Ghost.Rectangle;
    164                 GhostDrawingComplete();
    165                 Controller.View.ResetGhost();
    166                 started = false;
    167             }
    168         }
    169         #endregion
     137        //base.RestoreCursor();
     138        Point point = new Point(e.X, e.Y);
     139        //mRectangle = new Rectangle(startingPoint.X, startingPoint.Y, point.X - startingPoint.X, point.Y - startingPoint.Y);
     140        //mRectangle = base.Controller.View.ViewToWorld(base.Controller.View.DeviceToView(rectangle));
     141        mRectangle = Controller.View.Ghost.Rectangle;
     142        GhostDrawingComplete();
     143        Controller.View.ResetGhost();
     144        started = false;
     145      }
     146    }
     147    #endregion
    170148
    171         /// <summary>
    172         /// This method will be called when the user has finished drawing a
    173         /// ghost rectangle or bundle and initiates the actual creation of a
    174         /// bundle and the addition to the model via the appropriate command.
    175         /// </summary>
    176         protected abstract void GhostDrawingComplete();
     149    /// <summary>
     150    /// This method will be called when the user has finished drawing a
     151    /// ghost rectangle or bundle and initiates the actual creation of a
     152    /// bundle and the addition to the model via the appropriate command.
     153    /// </summary>
     154    protected abstract void GhostDrawingComplete();
    177155
    178         #endregion
     156    #endregion
    179157
    180158
    181159
    182160
    183     }
     161  }
    184162
    185163}
Note: See TracChangeset for help on using the changeset viewer.