Completed
Last Updated: 06 Nov 2014 11:06 by ADMIN
ADMIN
George
Created on: 23 May 2014 10:39
Category: Dock
Type: Bug Report
0
FIX. RadDock - Cancelling the drag of a document window's tab causes RadDock to start dragging windows when the mouse is not down
To reproduce:

Add a few document windows to a RadDock. Start the application and start dragging a document window's tab, do not move the mouse much, you want to keep the red cursor. While at it press escape. The drag operation will be canceled. Now move your mouse over the tabs and you will notice that they will be dragged.

Workaround:

When the Drag service stops we need to reset some fields.

public Form1()
{
    InitializeComponent();


    foreach (Control child in ControlHelper.EnumChildControls(this.radDock1, true))
    {
        DocumentTabStrip docStrip = child as DocumentTabStrip;
        if (docStrip != null)
        {
            RadPageViewElement pageViewElement = docStrip.TabStripElement;
            pageViewElement.ItemDragService.Stopping += ItemDragService_Stopping;
            pageViewElement.ItemDragService.Started += ItemDragService_Started;
            break;
        }
    }
}


void ItemDragService_Started(object sender, EventArgs e)
{
    foreach (DockTabStrip strip in DockHelper.GetDockTabStrips<DockTabStrip>(this, true, this.radDock1))
    {
        strip.MouseDown += strip_MouseDown;
        strip.MouseUp += strip_MouseUp;
        strip.MouseCaptureChanged += strip_MouseCaptureChanged;
        strip.MouseMove += strip_MouseMove;
    }
}


void ItemDragService_Stopping(object sender, RadServiceStoppingEventArgs e)
{
    foreach (DockTabStrip strip in DockHelper.GetDockTabStrips<DockTabStrip>(this, true, this.radDock1))
    {
        strip.MouseDown -= strip_MouseDown;
        strip.MouseUp -= strip_MouseUp;
        strip.MouseCaptureChanged -= strip_MouseCaptureChanged;
        strip.MouseMove -= strip_MouseMove;


        strip.GetType().GetMethod("OnMouseCaptureChanged", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(strip, new object[] { EventArgs.Empty });
        typeof(TabStripPanel).GetField("dragStart", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(strip, Point.Empty);
    }
}


void strip_MouseMove(object sender, MouseEventArgs e)
{
    if (this.isMouseDown.ContainsKey(sender) && !this.isMouseDown[sender])
    {
        sender.GetType().BaseType.BaseType.GetField("dragging", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(sender, true);
    }
}


Dictionary<object, bool> isMouseDown = new Dictionary<object, bool>();
void strip_MouseCaptureChanged(object sender, EventArgs e)
{
    this.isMouseDown[sender] = false;
}


void strip_MouseUp(object sender, MouseEventArgs e)
{
    this.isMouseDown[sender] = false;
}


void strip_MouseDown(object sender, MouseEventArgs e)
{
    this.isMouseDown[sender] = true;
}

0 comments