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/PolygonTool.cs

    r2768 r4068  
    11using System;
    2 using System.Diagnostics;
    3 using System.Collections;
    4 using System.Collections.Generic;
    52using System.Drawing;
    63using System.Windows.Forms;
    74
    8 namespace Netron.Diagramming.Core
    9 {
    10    
    11     class PolygonTool : AbstractTool, IMouseListener, IKeyboardListener
    12     {
     5namespace Netron.Diagramming.Core {
    136
    14         #region Fields
    15         /// <summary>
    16         /// the location of the mouse when the motion starts
    17         /// </summary>
    18        
    19         private bool doDraw;
    20         private Point[] points;
    21         #endregion
     7  class PolygonTool : AbstractTool, IMouseListener, IKeyboardListener {
    228
    23         #region Constructor
    24         /// <summary>
    25         /// Initializes a new instance of the <see cref="T:PolygonTool"/> class.
    26         /// </summary>
    27         /// <param name="name">The name of the tool.</param>
    28         public PolygonTool(string name) : base(name)
    29         {
    30         }
    31         #endregion
     9    #region Fields
     10    /// <summary>
     11    /// the location of the mouse when the motion starts
     12    /// </summary>
    3213
    33         #region Methods
     14    private bool doDraw;
     15    private Point[] points;
     16    #endregion
    3417
    35         /// <summary>
    36         /// Called when the tool is activated.
    37         /// </summary>
    38         protected override void OnActivateTool()
    39         {
    40             Controller.View.CurrentCursor =CursorPalette.Cross;
    41             this.SuspendOtherTools();
    42             doDraw = false;
    43             points = new Point[1];
    44         }
     18    #region Constructor
     19    /// <summary>
     20    /// Initializes a new instance of the <see cref="T:PolygonTool"/> class.
     21    /// </summary>
     22    /// <param name="name">The name of the tool.</param>
     23    public PolygonTool(string name)
     24      : base(name) {
     25    }
     26    #endregion
    4527
    46         /// <summary>
    47         /// Handles the mouse down event
    48         /// </summary>
    49         /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
    50         /// <returns>Returns 'true' if the event was handled, otherwise 'false'.</returns>
    51         public bool MouseDown(MouseEventArgs e)
    52         {
    53             if (e == null)
    54                 throw new ArgumentNullException("The argument object is 'null'");
    55             if (e.Button == MouseButtons.Left && Enabled && !IsSuspended)
    56             {
    57                     Array.Resize<Point>(ref points, points.Length + 1);
    58                     points[points.Length-2]= e.Location;
    59                     doDraw = true;
    60                     return true;           
    61             }
    62             return false;
    63         }
     28    #region Methods
    6429
    65         /// <summary>
    66         /// Handles the mouse move event
    67         /// </summary>
    68         /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
    69         public void MouseMove(MouseEventArgs e)
    70         {
    71             if (e == null)
    72                 throw new ArgumentNullException("The argument object is 'null'");
    73             Point point = e.Location;
    74             if(IsActive && doDraw)
    75             {
    76                 points[points.Length - 1] = e.Location;               
    77                 Controller.View.PaintGhostLine( MultiPointType.Polygon, points);
    78                 //Controller.View.Invalidate(System.Drawing.Rectangle.Inflate(Controller.View.Ghost.Rectangle, 20, 20));
    79                 //TODO: find a more performant way to invalidate the area
    80                 Controller.View.Invalidate();
    81             }           
    82         }
    83         /// <summary>
    84         ///
    85         /// </summary>
    86         /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
    87         public void MouseUp(MouseEventArgs e)
    88         {
    89             if (IsActive)
    90             {
    91                
    92             }
    93         }
    94         private void Package()
    95         {
    96             if ((points == null) ||
    97                (points.Length < 1) ||
    98                (points[0] == Point.Empty))
    99             {
    100                 return;
    101             }
    102 
    103             MultiPointShape shape = new MultiPointShape(
    104                 this.Controller.Model,
    105                 points,
    106                 MultiPointType.Polygon);
    107 
    108             AddMultiPointShapeCommand cmd = new AddMultiPointShapeCommand(this.Controller, shape);
    109             this.Controller.UndoManager.AddUndoCommand(cmd);
    110             cmd.Redo();
    111         }
    112         #endregion
    113 
    114         #region IKeyboardListener Members
    115 
    116         public void KeyDown(KeyEventArgs e)
    117         {       
    118             if(e.KeyData == Keys.Escape && IsActive)
    119             {
    120                 DeactivateTool();
    121                 Package();       
    122                 e.Handled = true;
    123             }
    124         }
    125 
    126         public void KeyUp(KeyEventArgs e)
    127         {
    128         }
    129 
    130         public void KeyPress(KeyPressEventArgs e)
    131         {
    132         }
    133 
    134         #endregion
     30    /// <summary>
     31    /// Called when the tool is activated.
     32    /// </summary>
     33    protected override void OnActivateTool() {
     34      Controller.View.CurrentCursor = CursorPalette.Cross;
     35      this.SuspendOtherTools();
     36      doDraw = false;
     37      points = new Point[1];
    13538    }
    13639
     40    /// <summary>
     41    /// Handles the mouse down event
     42    /// </summary>
     43    /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
     44    /// <returns>Returns 'true' if the event was handled, otherwise 'false'.</returns>
     45    public bool MouseDown(MouseEventArgs e) {
     46      if (e == null)
     47        throw new ArgumentNullException("The argument object is 'null'");
     48      if (e.Button == MouseButtons.Left && Enabled && !IsSuspended) {
     49        Array.Resize<Point>(ref points, points.Length + 1);
     50        points[points.Length - 2] = e.Location;
     51        doDraw = true;
     52        return true;
     53      }
     54      return false;
     55    }
     56
     57    /// <summary>
     58    /// Handles the mouse move event
     59    /// </summary>
     60    /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
     61    public void MouseMove(MouseEventArgs e) {
     62      if (e == null)
     63        throw new ArgumentNullException("The argument object is 'null'");
     64      Point point = e.Location;
     65      if (IsActive && doDraw) {
     66        points[points.Length - 1] = e.Location;
     67        Controller.View.PaintGhostLine(MultiPointType.Polygon, points);
     68        //Controller.View.Invalidate(System.Drawing.Rectangle.Inflate(Controller.View.Ghost.Rectangle, 20, 20));
     69        //TODO: find a more performant way to invalidate the area
     70        Controller.View.Invalidate();
     71      }
     72    }
     73    /// <summary>
     74    ///
     75    /// </summary>
     76    /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
     77    public void MouseUp(MouseEventArgs e) {
     78      if (IsActive) {
     79
     80      }
     81    }
     82    private void Package() {
     83      if ((points == null) ||
     84         (points.Length < 1) ||
     85         (points[0] == Point.Empty)) {
     86        return;
     87      }
     88
     89      MultiPointShape shape = new MultiPointShape(
     90          this.Controller.Model,
     91          points,
     92          MultiPointType.Polygon);
     93
     94      AddMultiPointShapeCommand cmd = new AddMultiPointShapeCommand(this.Controller, shape);
     95      this.Controller.UndoManager.AddUndoCommand(cmd);
     96      cmd.Redo();
     97    }
     98    #endregion
     99
     100    #region IKeyboardListener Members
     101
     102    public void KeyDown(KeyEventArgs e) {
     103      if (e.KeyData == Keys.Escape && IsActive) {
     104        DeactivateTool();
     105        Package();
     106        e.Handled = true;
     107      }
     108    }
     109
     110    public void KeyUp(KeyEventArgs e) {
     111    }
     112
     113    public void KeyPress(KeyPressEventArgs e) {
     114    }
     115
     116    #endregion
     117  }
     118
    137119}
Note: See TracChangeset for help on using the changeset viewer.