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

    r2768 r4068  
    1 using System;
    2 using System.Diagnostics;
    31using System.Collections;
    4 using System.Drawing;
    52using System.Windows.Forms;
    63
    7 namespace Netron.Diagramming.Core
    8 {
    9     // ----------------------------------------------------------------------
    10     /// <summary>
    11     /// This tool allows entities to give feedback (e.g. via a change of
    12     /// cursor) when the mouse is hovering over them.
    13     /// </summary>
    14     // ----------------------------------------------------------------------
    15     class HoverTool : AbstractTool, IMouseListener
    16     {
     4namespace Netron.Diagramming.Core {
     5  // ----------------------------------------------------------------------
     6  /// <summary>
     7  /// This tool allows entities to give feedback (e.g. via a change of
     8  /// cursor) when the mouse is hovering over them.
     9  /// </summary>
     10  // ----------------------------------------------------------------------
     11  class HoverTool : AbstractTool, IMouseListener {
    1712
    18         #region Fields
     13    #region Fields
    1914
    20         private IHoverListener currentListener = null;
     15    private IHoverListener currentListener = null;
    2116
    22         private IDiagramEntity previousHovered = null;
     17    private IDiagramEntity previousHovered = null;
    2318
    2419
    25         #endregion
     20    #endregion
    2621
    27         #region Constructor
     22    #region Constructor
    2823
    29         // ------------------------------------------------------------------
    30         /// <summary>
    31         /// Initializes a new instance of the <see cref="T:HoverTool"/> class.
    32         /// </summary>
    33         /// <param name="name">The name of the tool.</param>
    34         // ------------------------------------------------------------------
    35         public HoverTool(string name)
    36             : base(name)
    37         {
    38         }
    39 
    40         #endregion
    41 
    42         #region Methods
    43 
    44         // ------------------------------------------------------------------
    45         /// <summary>
    46         /// Called when the tool is activated.
    47         /// </summary>
    48         // ------------------------------------------------------------------
    49         protected override void OnActivateTool()
    50         {
    51            
    52 
    53         }
    54 
    55         // ------------------------------------------------------------------
    56         /// <summary>
    57         /// Handles the mouse down event.
    58         /// </summary>
    59         /// <param name="e">The <see cref=
    60         /// "T:System.Windows.Forms.MouseEventArgs"/> instance containing
    61         /// the event data.</param>
    62         // ------------------------------------------------------------------
    63         public bool MouseDown(MouseEventArgs e)
    64         {
    65             return false;
    66         }
    67 
    68         // ------------------------------------------------------------------
    69         /// <summary>
    70         /// Handles the mouse move event
    71         /// </summary>
    72         /// <param name="e">The <see cref=
    73         /// "T:System.Windows.Forms.MouseEventArgs"/> instance containing
    74         /// the event data.</param>
    75         // ------------------------------------------------------------------
    76         public void MouseMove(MouseEventArgs e)
    77         {
    78 
    79             if (!IsSuspended && this.Enabled)
    80             {
    81                 IHoverListener listener = null;
    82 
    83                 CollectionBase<IDiagramEntity> paintables=
    84                     this.Controller.Model.Paintables;
    85                 IDiagramEntity entity;
    86                 if(paintables.Count==0) return;
    87                 //going from top to the bottom of the z-order
    88                 for (int k=paintables.Count-1; k>=0; k--)
    89                 {
    90                     entity = paintables[k];
    91                     if(entity.Hit(e.Location)) //we caught an entity
    92                     {
    93                         //unhover the previous, if any
    94                         if (previousHovered != null)
    95                         {
    96                             previousHovered.Hovered = false;
    97                         }
    98 
    99                         //tell the current one it's being hovered
    100                         entity.Hovered = true;
    101 
    102                         //fetch the hovering service, if defined
    103                         listener = entity.GetService(
    104                             typeof(IHoverListener)) as IHoverListener;
    105                         if(listener != null) //the caught entity does listen
    106                         {
    107                             if(currentListener == listener) //it's the same as the previous time
    108                                 listener.MouseHover(e);
    109                             else //we moved from one entity to another listening entity
    110                             {
    111                                 if(currentListener!=null) //tell the previous entity we are leaving
    112                                     currentListener.MouseLeave(e);
    113                                 listener.MouseEnter(e); //tell the current one we enter
    114                                 currentListener = listener;
    115                             }
    116                         }
    117                         else //the caught entity does not listen
    118                         {
    119                             if(currentListener != null)
    120                             {
    121                                 currentListener.MouseLeave(e);
    122                                 currentListener = null;
    123                             }
    124                         }
    125                         previousHovered = entity;//remember, for the next time
    126                         return; //if another entity is listening underneath this entity it will not receive the notification
    127                     }
    128                 }
    129                 if(currentListener != null)
    130                 {
    131                     currentListener.MouseLeave(e);
    132                     currentListener = null;
    133                 }
    134                 //unhover the previous, if any
    135                 if(previousHovered != null)
    136                     previousHovered.Hovered = false;
    137 
    138             }
    139         }
    140 
    141         // ------------------------------------------------------------------
    142         /// <summary>
    143         /// Handles the mouse up event.
    144         /// </summary>
    145         /// <param name="e">The <see cref=
    146         /// "T:System.Windows.Forms.MouseEventArgs"/> instance containing
    147         /// the event data.</param>
    148         // ------------------------------------------------------------------
    149         public void MouseUp(MouseEventArgs e)
    150         {
    151            
    152         }
    153         #endregion
     24    // ------------------------------------------------------------------
     25    /// <summary>
     26    /// Initializes a new instance of the <see cref="T:HoverTool"/> class.
     27    /// </summary>
     28    /// <param name="name">The name of the tool.</param>
     29    // ------------------------------------------------------------------
     30    public HoverTool(string name)
     31      : base(name) {
    15432    }
    15533
     34    #endregion
     35
     36    #region Methods
     37
     38    // ------------------------------------------------------------------
     39    /// <summary>
     40    /// Called when the tool is activated.
     41    /// </summary>
     42    // ------------------------------------------------------------------
     43    protected override void OnActivateTool() {
     44
     45
     46    }
     47
     48    // ------------------------------------------------------------------
     49    /// <summary>
     50    /// Handles the mouse down event.
     51    /// </summary>
     52    /// <param name="e">The <see cref=
     53    /// "T:System.Windows.Forms.MouseEventArgs"/> instance containing
     54    /// the event data.</param>
     55    // ------------------------------------------------------------------
     56    public bool MouseDown(MouseEventArgs e) {
     57      return false;
     58    }
     59
     60    // ------------------------------------------------------------------
     61    /// <summary>
     62    /// Handles the mouse move event
     63    /// </summary>
     64    /// <param name="e">The <see cref=
     65    /// "T:System.Windows.Forms.MouseEventArgs"/> instance containing
     66    /// the event data.</param>
     67    // ------------------------------------------------------------------
     68    public void MouseMove(MouseEventArgs e) {
     69
     70      if (!IsSuspended && this.Enabled) {
     71        IHoverListener listener = null;
     72
     73        CollectionBase<IDiagramEntity> paintables =
     74            this.Controller.Model.Paintables;
     75        IDiagramEntity entity;
     76        if (paintables.Count == 0) return;
     77        //going from top to the bottom of the z-order
     78        for (int k = paintables.Count - 1; k >= 0; k--) {
     79          entity = paintables[k];
     80          if (entity.Hit(e.Location)) //we caught an entity
     81                    {
     82            //unhover the previous, if any
     83            if (previousHovered != null) {
     84              previousHovered.Hovered = false;
     85            }
     86
     87            //tell the current one it's being hovered
     88            entity.Hovered = true;
     89
     90            //fetch the hovering service, if defined
     91            listener = entity.GetService(
     92                typeof(IHoverListener)) as IHoverListener;
     93            if (listener != null) //the caught entity does listen
     94                        {
     95              if (currentListener == listener) //it's the same as the previous time
     96                listener.MouseHover(e);
     97              else //we moved from one entity to another listening entity
     98                            {
     99                if (currentListener != null) //tell the previous entity we are leaving
     100                  currentListener.MouseLeave(e);
     101                listener.MouseEnter(e); //tell the current one we enter
     102                currentListener = listener;
     103              }
     104            } else //the caught entity does not listen
     105                        {
     106              if (currentListener != null) {
     107                currentListener.MouseLeave(e);
     108                currentListener = null;
     109              }
     110            }
     111            previousHovered = entity;//remember, for the next time
     112            return; //if another entity is listening underneath this entity it will not receive the notification
     113          }
     114        }
     115        if (currentListener != null) {
     116          currentListener.MouseLeave(e);
     117          currentListener = null;
     118        }
     119        //unhover the previous, if any
     120        if (previousHovered != null)
     121          previousHovered.Hovered = false;
     122
     123      }
     124    }
     125
     126    // ------------------------------------------------------------------
     127    /// <summary>
     128    /// Handles the mouse up event.
     129    /// </summary>
     130    /// <param name="e">The <see cref=
     131    /// "T:System.Windows.Forms.MouseEventArgs"/> instance containing
     132    /// the event data.</param>
     133    // ------------------------------------------------------------------
     134    public void MouseUp(MouseEventArgs e) {
     135
     136    }
     137    #endregion
     138  }
     139
    156140}
Note: See TracChangeset for help on using the changeset viewer.