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/MultiLineTool.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 {
     5namespace Netron.Diagramming.Core {
    106
    11     class MultiLineTool : AbstractTool, IMouseListener, IKeyboardListener
    12     {
     7  class MultiLineTool : AbstractTool, IMouseListener, IKeyboardListener {
    138
    14         #region Fields
    15         /// <summary>
    16         /// the location of the mouse when the motion starts
    17         /// </summary>
     9    #region Fields
     10    /// <summary>
     11    /// the location of the mouse when the motion starts
     12    /// </summary>
    1813
    19         private bool doDraw;
    20         private Point[] points;
    21         #endregion
     14    private bool doDraw;
     15    private Point[] points;
     16    #endregion
    2217
    23         #region Constructor
    24         /// <summary>
    25         /// Initializes a new instance of the <see cref="T:MultiLineTool"/> class.
    26         /// </summary>
    27         /// <param name="name">The name of the tool.</param>
    28         public MultiLineTool(string name)
    29             : base(name)
    30         {
    31         }
    32         #endregion
     18    #region Constructor
     19    /// <summary>
     20    /// Initializes a new instance of the <see cref="T:MultiLineTool"/> class.
     21    /// </summary>
     22    /// <param name="name">The name of the tool.</param>
     23    public MultiLineTool(string name)
     24      : base(name) {
     25    }
     26    #endregion
    3327
    34         #region Methods
     28    #region Methods
    3529
    36         /// <summary>
    37         /// Called when the tool is activated.
    38         /// </summary>
    39         protected override void OnActivateTool()
    40         {
    41             Controller.View.CurrentCursor = CursorPalette.Cross;
    42             this.SuspendOtherTools();
    43             doDraw = false;
    44             points = new Point[1];
    45         }
    46 
    47         /// <summary>
    48         /// Handles the mouse down event
    49         /// </summary>
    50         /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
    51         /// <returns>Returns 'true' if the event was handled, otherwise 'false'.</returns>
    52         public bool MouseDown(MouseEventArgs e)
    53         {
    54             if (e == null)
    55                 throw new ArgumentNullException("The argument object is 'null'");
    56             if (e.Button == MouseButtons.Left && Enabled && !IsSuspended)
    57             {
    58                 Point p = e.Location;
    59                 if (Closure(p))
    60                 {
    61                     points[points.Length - 1] = points[0];
    62                     doDraw = false;
    63                     DeactivateTool();
    64                     Package();
    65 
    66                     return true;
    67                 }
    68                 Array.Resize<Point>(ref points, points.Length + 1);
    69                 points[points.Length - 2] = p;
    70                 doDraw = true;
    71                 return true;
    72             }
    73             return false;
    74         }
    75         private bool Closure(Point p)
    76         {
    77             for (int k = 0; k < points.Length - 1; k++)
    78             {
    79                 if (new Rectangle(points[k].X - 6, points[k].Y - 6, 12, 12).Contains(p))
    80                 {
    81                     DialogResult res = MessageBox.Show("Do you wish to close the curve?", "Closure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    82                     if (res == DialogResult.Yes)
    83                         return true;
    84 
    85                 }
    86             }
    87             return false;
    88         }
    89         /// <summary>
    90         /// Handles the mouse move event
    91         /// </summary>
    92         /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
    93         public void MouseMove(MouseEventArgs e)
    94         {
    95             if (e == null)
    96                 throw new ArgumentNullException("The argument object is 'null'");
    97             Point point = e.Location;
    98             if (IsActive && doDraw)
    99             {
    100                 points[points.Length - 1] = e.Location;
    101                 Controller.View.PaintGhostLine(MultiPointType.Straight, points);
    102                 //Controller.View.Invalidate(System.Drawing.Rectangle.Inflate(Controller.View.Ghost.Rectangle, 20, 20));
    103                 //TODO: find a more performant way to invalidate the area
    104                 Controller.View.Invalidate();
    105             }
    106         }
    107         /// <summary>
    108         ///
    109         /// </summary>
    110         /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
    111         public void MouseUp(MouseEventArgs e)
    112         {
    113             if (IsActive)
    114             {
    115 
    116             }
    117         }
    118         private void Package()
    119         {
    120             if ((points == null) ||
    121                (points.Length < 1) ||
    122                (points[0] == Point.Empty))
    123             {
    124                 return;
    125             }
    126 
    127             MultiPointShape shape = new MultiPointShape(
    128                 this.Controller.Model,
    129                 points,
    130                 MultiPointType.Straight);
    131 
    132             AddMultiPointShapeCommand cmd = new AddMultiPointShapeCommand(this.Controller, shape);
    133             this.Controller.UndoManager.AddUndoCommand(cmd);
    134             this.Controller.View.ResetGhost();
    135             cmd.Redo();
    136         }
    137         #endregion
    138 
    139         #region IKeyboardListener Members
    140 
    141         public void KeyDown(KeyEventArgs e)
    142         {
    143             if (e.KeyData == Keys.Escape && IsActive)
    144             {
    145                 DeactivateTool();
    146                 Package();
    147                 e.Handled = true;
    148             }
    149         }
    150 
    151         public void KeyUp(KeyEventArgs e)
    152         {
    153         }
    154 
    155         public void KeyPress(KeyPressEventArgs e)
    156         {
    157         }
    158 
    159         #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];
    16038    }
    16139
     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        Point p = e.Location;
     50        if (Closure(p)) {
     51          points[points.Length - 1] = points[0];
     52          doDraw = false;
     53          DeactivateTool();
     54          Package();
     55
     56          return true;
     57        }
     58        Array.Resize<Point>(ref points, points.Length + 1);
     59        points[points.Length - 2] = p;
     60        doDraw = true;
     61        return true;
     62      }
     63      return false;
     64    }
     65    private bool Closure(Point p) {
     66      for (int k = 0; k < points.Length - 1; k++) {
     67        if (new Rectangle(points[k].X - 6, points[k].Y - 6, 12, 12).Contains(p)) {
     68          DialogResult res = MessageBox.Show("Do you wish to close the curve?", "Closure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     69          if (res == DialogResult.Yes)
     70            return true;
     71
     72        }
     73      }
     74      return false;
     75    }
     76    /// <summary>
     77    /// Handles the mouse move event
     78    /// </summary>
     79    /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
     80    public void MouseMove(MouseEventArgs e) {
     81      if (e == null)
     82        throw new ArgumentNullException("The argument object is 'null'");
     83      Point point = e.Location;
     84      if (IsActive && doDraw) {
     85        points[points.Length - 1] = e.Location;
     86        Controller.View.PaintGhostLine(MultiPointType.Straight, points);
     87        //Controller.View.Invalidate(System.Drawing.Rectangle.Inflate(Controller.View.Ghost.Rectangle, 20, 20));
     88        //TODO: find a more performant way to invalidate the area
     89        Controller.View.Invalidate();
     90      }
     91    }
     92    /// <summary>
     93    ///
     94    /// </summary>
     95    /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
     96    public void MouseUp(MouseEventArgs e) {
     97      if (IsActive) {
     98
     99      }
     100    }
     101    private void Package() {
     102      if ((points == null) ||
     103         (points.Length < 1) ||
     104         (points[0] == Point.Empty)) {
     105        return;
     106      }
     107
     108      MultiPointShape shape = new MultiPointShape(
     109          this.Controller.Model,
     110          points,
     111          MultiPointType.Straight);
     112
     113      AddMultiPointShapeCommand cmd = new AddMultiPointShapeCommand(this.Controller, shape);
     114      this.Controller.UndoManager.AddUndoCommand(cmd);
     115      this.Controller.View.ResetGhost();
     116      cmd.Redo();
     117    }
     118    #endregion
     119
     120    #region IKeyboardListener Members
     121
     122    public void KeyDown(KeyEventArgs e) {
     123      if (e.KeyData == Keys.Escape && IsActive) {
     124        DeactivateTool();
     125        Package();
     126        e.Handled = true;
     127      }
     128    }
     129
     130    public void KeyUp(KeyEventArgs e) {
     131    }
     132
     133    public void KeyPress(KeyPressEventArgs e) {
     134    }
     135
     136    #endregion
     137  }
     138
    162139}
Note: See TracChangeset for help on using the changeset viewer.