Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/12 12:51:52 (13 years ago)
Author:
ascheibe
Message:

#1761 added a delay when switching to the tab page on which an item is dragged on

Location:
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/DragOverTabControl.Designer.cs

    r7259 r7342  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
     48      this.timer = new System.Windows.Forms.Timer(this.components);
    4749      this.SuspendLayout();
     50      //
     51      // timer
     52      //
     53      this.timer.Interval = 500;
     54      this.timer.Tick += new System.EventHandler(this.timer_Tick);
    4855      //
    4956      // DragOverTabControl
     
    5663
    5764    #endregion
     65
     66    private System.Windows.Forms.Timer timer;
    5867  }
    5968}
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/DragOverTabControl.cs

    r7259 r7342  
    2525namespace HeuristicLab.MainForm.WindowsForms {
    2626  public partial class DragOverTabControl : TabControl {
     27    private int destinationTabIndex;
     28
    2729    public DragOverTabControl() {
    2830      InitializeComponent();
    2931    }
    3032
    31     private void DragOverTabControl_DragOver(object sender, DragEventArgs e) {
     33    private int GetTabIndex() {
    3234      Point position = PointToClient(Control.MousePosition);
    3335      int tabIndex = -1;
     
    3638          tabIndex = i;
    3739      }
     40      return tabIndex;
     41    }
    3842
    39       if (tabIndex != SelectedIndex && tabIndex != -1)
     43    private void DragOverTabControl_DragOver(object sender, DragEventArgs e) {
     44      int tabIndex = GetTabIndex();
     45
     46      if (!timer.Enabled && tabIndex != SelectedIndex && tabIndex != -1) {
     47        destinationTabIndex = tabIndex;
     48        timer.Start();
     49      }
     50    }
     51
     52    private void timer_Tick(object sender, System.EventArgs e) {
     53      timer.Stop();
     54      int tabIndex = GetTabIndex();
     55
     56      if (tabIndex == destinationTabIndex && tabIndex != SelectedIndex && tabIndex != -1) {
    4057        SelectedIndex = tabIndex;
    41 
     58      }
    4259    }
    4360  }
Note: See TracChangeset for help on using the changeset viewer.