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.WinFormsUI/2.3.1/WinFormsUI-2.3.1/Docking/DockPanel.DragHandler.cs

    r2645 r4068  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Text;
     1using System.Drawing;
    42using System.Windows.Forms;
    5 using System.Drawing;
    6 using System.Drawing.Drawing2D;
    7 using System.ComponentModel;
    83
    9 namespace WeifenLuo.WinFormsUI.Docking
    10 {
    11     partial class DockPanel
    12     {
    13         /// <summary>
    14         /// DragHandlerBase is the base class for drag handlers. The derived class should:
    15         ///   1. Define its public method BeginDrag. From within this public BeginDrag method,
    16         ///      DragHandlerBase.BeginDrag should be called to initialize the mouse capture
    17         ///      and message filtering.
    18         ///   2. Override the OnDragging and OnEndDrag methods.
    19         /// </summary>
    20         private abstract class DragHandlerBase : NativeWindow, IMessageFilter
    21         {
    22             protected DragHandlerBase()
    23             {
    24             }
     4namespace WeifenLuo.WinFormsUI.Docking {
     5  partial class DockPanel {
     6    /// <summary>
     7    /// DragHandlerBase is the base class for drag handlers. The derived class should:
     8    ///   1. Define its public method BeginDrag. From within this public BeginDrag method,
     9    ///      DragHandlerBase.BeginDrag should be called to initialize the mouse capture
     10    ///      and message filtering.
     11    ///   2. Override the OnDragging and OnEndDrag methods.
     12    /// </summary>
     13    private abstract class DragHandlerBase : NativeWindow, IMessageFilter {
     14      protected DragHandlerBase() {
     15      }
    2516
    26             protected abstract Control DragControl
    27             {
    28                 get;
    29             }
     17      protected abstract Control DragControl {
     18        get;
     19      }
    3020
    31             private Point m_startMousePosition = Point.Empty;
    32             protected Point StartMousePosition
    33             {
    34                 get { return m_startMousePosition; }
    35                 private set { m_startMousePosition = value; }
    36             }
     21      private Point m_startMousePosition = Point.Empty;
     22      protected Point StartMousePosition {
     23        get { return m_startMousePosition; }
     24        private set { m_startMousePosition = value; }
     25      }
    3726
    38             protected bool BeginDrag()
    39             {
    40                 // Avoid re-entrance;
    41                 lock (this)
    42                 {
    43                     if (DragControl == null)
    44                         return false;
     27      protected bool BeginDrag() {
     28        // Avoid re-entrance;
     29        lock (this) {
     30          if (DragControl == null)
     31            return false;
    4532
    46                     StartMousePosition = Control.MousePosition;
     33          StartMousePosition = Control.MousePosition;
    4734
    48                     if (!NativeMethods.DragDetect(DragControl.Handle, StartMousePosition))
    49                         return false;
     35          if (!NativeMethods.DragDetect(DragControl.Handle, StartMousePosition))
     36            return false;
    5037
    51                     DragControl.FindForm().Capture = true;
    52                     AssignHandle(DragControl.FindForm().Handle);
    53                     Application.AddMessageFilter(this);
    54                     return true;
    55                 }
    56             }
     38          DragControl.FindForm().Capture = true;
     39          AssignHandle(DragControl.FindForm().Handle);
     40          Application.AddMessageFilter(this);
     41          return true;
     42        }
     43      }
    5744
    58             protected abstract void OnDragging();
     45      protected abstract void OnDragging();
    5946
    60             protected abstract void OnEndDrag(bool abort);
     47      protected abstract void OnEndDrag(bool abort);
    6148
    62             private void EndDrag(bool abort)
    63             {
    64                 ReleaseHandle();
    65                 Application.RemoveMessageFilter(this);
    66                 DragControl.FindForm().Capture = false;
     49      private void EndDrag(bool abort) {
     50        ReleaseHandle();
     51        Application.RemoveMessageFilter(this);
     52        DragControl.FindForm().Capture = false;
    6753
    68                 OnEndDrag(abort);
    69             }
     54        OnEndDrag(abort);
     55      }
    7056
    71             bool IMessageFilter.PreFilterMessage(ref Message m)
    72             {
    73                 if (m.Msg == (int)Win32.Msgs.WM_MOUSEMOVE)
    74                     OnDragging();
    75                 else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONUP)
    76                     EndDrag(false);
    77                 else if (m.Msg == (int)Win32.Msgs.WM_CAPTURECHANGED)
    78                     EndDrag(true);
    79                 else if (m.Msg == (int)Win32.Msgs.WM_KEYDOWN && (int)m.WParam == (int)Keys.Escape)
    80                     EndDrag(true);
     57      bool IMessageFilter.PreFilterMessage(ref Message m) {
     58        if (m.Msg == (int)Win32.Msgs.WM_MOUSEMOVE)
     59          OnDragging();
     60        else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONUP)
     61          EndDrag(false);
     62        else if (m.Msg == (int)Win32.Msgs.WM_CAPTURECHANGED)
     63          EndDrag(true);
     64        else if (m.Msg == (int)Win32.Msgs.WM_KEYDOWN && (int)m.WParam == (int)Keys.Escape)
     65          EndDrag(true);
    8166
    82                 return OnPreFilterMessage(ref m);
    83             }
     67        return OnPreFilterMessage(ref m);
     68      }
    8469
    85             protected virtual bool OnPreFilterMessage(ref Message m)
    86             {
    87                 return false;
    88             }
     70      protected virtual bool OnPreFilterMessage(ref Message m) {
     71        return false;
     72      }
    8973
    90             protected sealed override void WndProc(ref Message m)
    91             {
    92                 if (m.Msg == (int)Win32.Msgs.WM_CANCELMODE || m.Msg == (int)Win32.Msgs.WM_CAPTURECHANGED)
    93                     EndDrag(true);
     74      protected sealed override void WndProc(ref Message m) {
     75        if (m.Msg == (int)Win32.Msgs.WM_CANCELMODE || m.Msg == (int)Win32.Msgs.WM_CAPTURECHANGED)
     76          EndDrag(true);
    9477
    95                 base.WndProc(ref m);
    96             }
    97         }
     78        base.WndProc(ref m);
     79      }
     80    }
    9881
    99         private abstract class DragHandler : DragHandlerBase
    100         {
    101             private DockPanel m_dockPanel;
     82    private abstract class DragHandler : DragHandlerBase {
     83      private DockPanel m_dockPanel;
    10284
    103             protected DragHandler(DockPanel dockPanel)
    104             {
    105                 m_dockPanel = dockPanel;
    106             }
     85      protected DragHandler(DockPanel dockPanel) {
     86        m_dockPanel = dockPanel;
     87      }
    10788
    108             public DockPanel DockPanel
    109             {
    110                 get { return m_dockPanel; }
    111             }
     89      public DockPanel DockPanel {
     90        get { return m_dockPanel; }
     91      }
    11292
    113             private IDragSource m_dragSource;
    114             protected IDragSource DragSource
    115             {
    116                 get { return m_dragSource; }
    117                 set { m_dragSource = value; }
    118             }
     93      private IDragSource m_dragSource;
     94      protected IDragSource DragSource {
     95        get { return m_dragSource; }
     96        set { m_dragSource = value; }
     97      }
    11998
    120             protected sealed override Control DragControl
    121             {
    122                 get { return DragSource == null ? null : DragSource.DragControl; }
    123             }
     99      protected sealed override Control DragControl {
     100        get { return DragSource == null ? null : DragSource.DragControl; }
     101      }
    124102
    125             protected sealed override bool OnPreFilterMessage(ref Message m)
    126             {
    127                 if ((m.Msg == (int)Win32.Msgs.WM_KEYDOWN || m.Msg == (int)Win32.Msgs.WM_KEYUP) &&
    128                     ((int)m.WParam == (int)Keys.ControlKey || (int)m.WParam == (int)Keys.ShiftKey))
    129                     OnDragging();
     103      protected sealed override bool OnPreFilterMessage(ref Message m) {
     104        if ((m.Msg == (int)Win32.Msgs.WM_KEYDOWN || m.Msg == (int)Win32.Msgs.WM_KEYUP) &&
     105            ((int)m.WParam == (int)Keys.ControlKey || (int)m.WParam == (int)Keys.ShiftKey))
     106          OnDragging();
    130107
    131                 return base.OnPreFilterMessage(ref m);
    132             }
    133         }
     108        return base.OnPreFilterMessage(ref m);
     109      }
    134110    }
     111  }
    135112}
Note: See TracChangeset for help on using the changeset viewer.