public void DropWithoutMovement() { DNDForm form = new DNDForm(); form.Text = MethodBase.GetCurrentMethod().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it, WITHOUT MOVING IT." + Environment.NewLine + "2. Release the button." + Environment.NewLine + "3. Close the form."; form.DragControl.DragData = "no movement"; form.DragControl.AllowDrop = true; form.DragControl.AllowedEffects = DragDropEffects.Move; form.DragControl.DropEffect = DragDropEffects.Move; // Force to automatically do a dnd operation when mouse is pressed, // instead of waiting for movement form.DragControl.MouseDown += new MouseEventHandler(DragControl_MouseDown); Application.Run(form); Assert.AreEqual(1, form.DragControl.EnterFiredCount, "A1"); Assert.AreEqual(0, form.DragControl.LeaveFiredCount, "A2"); Assert.AreEqual(1, form.DragControl.DropFiredCount, "A3"); Assert.AreEqual(0, form.DragControl.DragOverFiredCount, "A4"); Assert.AreEqual(true, form.DragControl.Data != null, "A5"); // The assertion below is weird: We had a successfully drop, but the returned value is None Assert.AreEqual(DragDropEffects.None, form.DragControl.PerformedEffect, "A6"); }
public void SequentialOperations() { DNDForm form = new DNDForm(); form.Text = MethodBase.GetCurrentMethod().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Drag on the control on the right. " + Environment.NewLine + Environment.NewLine + "3. Click with left button on the control on the left again, holding it." + Environment.NewLine + "4. Move the mouse pointer to the control in the right." + Environment.NewLine + "5. Move the mouse pointer outside the drop control." + Environment.NewLine + "6. Release mouse button." + Environment.NewLine + Environment.NewLine + "7. Click with left button on the control on the left again, holding it." + Environment.NewLine + "8. Drag on the control on the right. " + Environment.NewLine + Environment.NewLine + "9. Close the form."; form.DragControl.DragData = "SimpleDragDropMessage"; form.DragControl.AllowedEffects = DragDropEffects.Move; form.DropControl.DropEffect = DragDropEffects.Move; Application.Run(form); Assert.AreEqual(2, form.DropControl.DropFiredCount, "A1"); Assert.AreEqual(1, form.DropControl.LeaveFiredCount, "A2"); Assert.AreEqual(DragDropEffects.Move, form.DragControl.PerformedEffect, "A3"); }
public void DragDropInSameControl() { DNDForm form = new DNDForm(); form.Text = MethodBase.GetCurrentMethod().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move the mouse inside left control. " + Environment.NewLine + "3. Drop on left control (same)." + Environment.NewLine + Environment.NewLine + "4. Click with left button on the control on the left again, holding it." + Environment.NewLine + "5. Move the mouse inside the left control. " + Environment.NewLine + "6. Press ESC, release mouse button and move mouse pointer outside control." + Environment.NewLine + "7. Close the form."; form.DragControl.DragData = "SameControl"; form.DragControl.AllowDrop = true; form.DragControl.AllowedEffects = DragDropEffects.Copy; data = null; drag_enter_count = drag_leave_count = 0; form.DragControl.DragEnter += new DragEventHandler(DragDropInSameControl_DragEnter); form.DragControl.DragLeave += new EventHandler(DragDropInSameControl_DragLeave); form.DragControl.DragDrop += new DragEventHandler(DragDropInSameControl_DragDrop); Application.Run(form); Assert.AreEqual(2, drag_enter_count, "A1"); Assert.AreEqual(1, drag_leave_count, "A2"); Assert.AreEqual(1, drag_drop_count, "A3"); Assert.AreEqual("SameControl", data, "A4"); }
public void DropCancelledByQuery() { DNDForm form = new DNDForm(); form.Text = MethodBase.GetCurrentMethod().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move mouse pointer to the control in the right. " + Environment.NewLine + "3. The drop should be cancelled after some seconds." + Environment.NewLine + "4. Close the form."; form.DragControl.DragData = "hello"; form.DragControl.AllowedEffects = DragDropEffects.All; form.DropControl.DropEffect = DragDropEffects.Copy; query_counter = 0; form.DragControl.QueryContinueDrag += new QueryContinueDragEventHandler(DragControl_QueryContinueDrag); Application.Run(form); Assert.AreEqual(DragDropEffects.None, form.DragControl.PerformedEffect, "A1"); Assert.AreEqual(1, form.DropControl.EnterFiredCount, "A2"); Assert.AreEqual(1, form.DropControl.LeaveFiredCount, "A3"); Assert.AreEqual(0, form.DropControl.DropFiredCount, "A4"); }
public void EventsAfterDrop() { DNDForm form = new DNDForm(); form.Text = MethodBase.GetCurrentMethod().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move mouse pointer to the control in the right. " + Environment.NewLine + "3. Move the pointer around and then release the mouse button." + Environment.NewLine + "4. Close the form."; form.DragControl.DragData = "hello"; form.DragControl.AllowedEffects = DragDropEffects.All; form.DropControl.DropEffect = DragDropEffects.Copy; // These should clear the event counters AND // thus the event counters should remain at 0 after drop occurred // AND we should get any MouseUp event. mouse_up_counter = 0; form.DropControl.DragDrop += new DragEventHandler(DropControl_DragDrop); form.DropControl.MouseUp += new MouseEventHandler(DropControl_MouseUp); Application.Run(form); Assert.AreEqual(DragDropEffects.Copy, form.DragControl.PerformedEffect, "A1"); Assert.AreEqual(0, form.DropControl.EnterFiredCount, "A2"); Assert.AreEqual(0, form.DropControl.LeaveFiredCount, "A3"); Assert.AreEqual(0, form.DropControl.DropFiredCount, "A4"); Assert.AreEqual(0, form.DropControl.DragOverFiredCount, "A5"); Assert.AreEqual(0, mouse_up_counter, "A6"); }
void DragControl_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) { DragDropControl c = (DragDropControl)sender; DNDForm f = (DNDForm)c.Parent; if (f.DropControl.EnterFiredCount == 0) { return; } // Cancel dnd operation AFTER we have reached the drop control if (query_counter++ >= 32) { e.Action = DragAction.Cancel; } }
public void DropCancelledByEsc () { DNDForm form = new DNDForm (); form.Text = MethodBase.GetCurrentMethod ().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move mouse pointer to the control in the right. " + Environment.NewLine + "3. While still pressing the mouse button, press ESC." + Environment.NewLine + "4. Close the form."; form.DragControl.DragData = "hello"; form.DragControl.AllowedEffects = DragDropEffects.All; form.DropControl.DropEffect = DragDropEffects.Copy; Application.Run (form); Assert.AreEqual (DragDropEffects.None, form.DragControl.PerformedEffect, "A1"); Assert.AreEqual (1, form.DropControl.EnterFiredCount, "A2"); Assert.AreEqual (1, form.DropControl.LeaveFiredCount, "A3"); Assert.AreEqual (0, form.DropControl.DropFiredCount, "A4"); }
public void SimpleDragDrop() { DNDForm form = new DNDForm(); form.Text = MethodBase.GetCurrentMethod().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move mouse pointer to the control in the right. " + Environment.NewLine + "3. Drop on the right control." + Environment.NewLine + "4. Close the form."; form.DragControl.DragData = "SimpleDragDropMessage"; form.DragControl.AllowedEffects = DragDropEffects.Copy; form.DropControl.DropEffect = DragDropEffects.Copy; Application.Run(form); Assert.AreEqual(DragDropEffects.Copy, form.DragControl.PerformedEffect, "A1"); Assert.IsTrue(form.DropControl.Data != null, "A2"); Assert.AreEqual(true, form.DropControl.Data.GetDataPresent(typeof(string)), "A3"); Assert.AreEqual("SimpleDragDropMessage", form.DropControl.Data.GetData(typeof(string)), "A4"); }
public void NotAllowedDropEffect() { DNDForm form = new DNDForm(); form.Text = MethodBase.GetCurrentMethod().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move mouse pointer to the control in the right. " + Environment.NewLine + "3. Drop on the right control." + Environment.NewLine + "4. Close the form."; form.DragControl.DragData = "SimpleDragDropMessage"; form.DragControl.AllowedEffects = DragDropEffects.Copy; form.DropControl.DropEffect = DragDropEffects.Move; Application.Run(form); Assert.AreEqual(DragDropEffects.None, form.DragControl.PerformedEffect, "A1"); Assert.AreEqual(1, form.DropControl.EnterFiredCount, "A2"); Assert.AreEqual(0, form.DropControl.DropFiredCount, "A3"); Assert.AreEqual(1, form.DropControl.LeaveFiredCount, "A4"); }
public void DropCancelledByEsc() { DNDForm form = new DNDForm(); form.Text = MethodBase.GetCurrentMethod().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move mouse pointer to the control in the right. " + Environment.NewLine + "3. While still pressing the mouse button, press ESC." + Environment.NewLine + "4. Close the form."; form.DragControl.DragData = "hello"; form.DragControl.AllowedEffects = DragDropEffects.All; form.DropControl.DropEffect = DragDropEffects.Copy; Application.Run(form); Assert.AreEqual(DragDropEffects.None, form.DragControl.PerformedEffect, "A1"); Assert.AreEqual(1, form.DropControl.EnterFiredCount, "A2"); Assert.AreEqual(1, form.DropControl.LeaveFiredCount, "A3"); Assert.AreEqual(0, form.DropControl.DropFiredCount, "A4"); }
public void DropCancelledByQuery () { DNDForm form = new DNDForm (); form.Text = MethodBase.GetCurrentMethod ().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move mouse pointer to the control in the right. " + Environment.NewLine + "3. The drop should be cancelled after some seconds." + Environment.NewLine + "4. Close the form."; form.DragControl.DragData = "hello"; form.DragControl.AllowedEffects = DragDropEffects.All; form.DropControl.DropEffect = DragDropEffects.Copy; query_counter = 0; form.DragControl.QueryContinueDrag += new QueryContinueDragEventHandler (DragControl_QueryContinueDrag); Application.Run (form); Assert.AreEqual (DragDropEffects.None, form.DragControl.PerformedEffect, "A1"); Assert.AreEqual (1, form.DropControl.EnterFiredCount, "A2"); Assert.AreEqual (1, form.DropControl.LeaveFiredCount, "A3"); Assert.AreEqual (0, form.DropControl.DropFiredCount, "A4"); }
public void DragDropInSameControl () { DNDForm form = new DNDForm (); form.Text = MethodBase.GetCurrentMethod ().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move the mouse inside left control. " + Environment.NewLine + "3. Drop on left control (same)." + Environment.NewLine + Environment.NewLine + "4. Click with left button on the control on the left again, holding it." + Environment.NewLine + "5. Move the mouse inside the left control. " + Environment.NewLine + "6. Press ESC, release mouse button and move mouse pointer outside control." + Environment.NewLine + "7. Close the form."; form.DragControl.DragData = "SameControl"; form.DragControl.AllowDrop = true; form.DragControl.AllowedEffects = DragDropEffects.Copy; data = null; drag_enter_count = drag_leave_count = 0; form.DragControl.DragEnter += new DragEventHandler (DragDropInSameControl_DragEnter); form.DragControl.DragLeave += new EventHandler (DragDropInSameControl_DragLeave); form.DragControl.DragDrop += new DragEventHandler (DragDropInSameControl_DragDrop); Application.Run (form); Assert.AreEqual (2, drag_enter_count, "A1"); Assert.AreEqual (1, drag_leave_count, "A2"); Assert.AreEqual (1, drag_drop_count, "A3"); Assert.AreEqual ("SameControl", data, "A4"); }
public void DropWithoutMovement () { DNDForm form = new DNDForm (); form.Text = MethodBase.GetCurrentMethod ().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it, WITHOUT MOVING IT." + Environment.NewLine + "2. Release the button." + Environment.NewLine + "3. Close the form."; form.DragControl.DragData = "no movement"; form.DragControl.AllowDrop = true; form.DragControl.AllowedEffects = DragDropEffects.Move; form.DragControl.DropEffect = DragDropEffects.Move; // Force to automatically do a dnd operation when mouse is pressed, // instead of waiting for movement form.DragControl.MouseDown += new MouseEventHandler (DragControl_MouseDown); Application.Run (form); Assert.AreEqual (1, form.DragControl.EnterFiredCount, "A1"); Assert.AreEqual (0, form.DragControl.LeaveFiredCount, "A2"); Assert.AreEqual (1, form.DragControl.DropFiredCount, "A3"); Assert.AreEqual (0, form.DragControl.DragOverFiredCount, "A4"); Assert.AreEqual (true, form.DragControl.Data != null, "A5"); // The assertion below is weird: We had a successfully drop, but the returned value is None Assert.AreEqual (DragDropEffects.None, form.DragControl.PerformedEffect, "A6"); }
public void SequentialOperations () { DNDForm form = new DNDForm (); form.Text = MethodBase.GetCurrentMethod ().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Drag on the control on the right. " + Environment.NewLine + Environment.NewLine + "3. Click with left button on the control on the left again, holding it." + Environment.NewLine + "4. Move the mouse pointer to the control in the right." + Environment.NewLine + "5. Move the mouse pointer outside the drop control." + Environment.NewLine + "6. Release mouse button." + Environment.NewLine + Environment.NewLine + "7. Click with left button on the control on the left again, holding it." + Environment.NewLine + "8. Drag on the control on the right. " + Environment.NewLine + Environment.NewLine + "9. Close the form."; form.DragControl.DragData = "SimpleDragDropMessage"; form.DragControl.AllowedEffects = DragDropEffects.Move; form.DropControl.DropEffect = DragDropEffects.Move; Application.Run (form); Assert.AreEqual (2, form.DropControl.DropFiredCount, "A1"); Assert.AreEqual (1, form.DropControl.LeaveFiredCount, "A2"); Assert.AreEqual (DragDropEffects.Move, form.DragControl.PerformedEffect, "A3"); }
public void NotAllowedDropEffect () { DNDForm form = new DNDForm (); form.Text = MethodBase.GetCurrentMethod ().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move mouse pointer to the control in the right. " + Environment.NewLine + "3. Drop on the right control." + Environment.NewLine + "4. Close the form."; form.DragControl.DragData = "SimpleDragDropMessage"; form.DragControl.AllowedEffects = DragDropEffects.Copy; form.DropControl.DropEffect = DragDropEffects.Move; Application.Run (form); Assert.AreEqual (DragDropEffects.None, form.DragControl.PerformedEffect, "A1"); Assert.AreEqual (1, form.DropControl.EnterFiredCount, "A2"); Assert.AreEqual (0, form.DropControl.DropFiredCount, "A3"); Assert.AreEqual (1, form.DropControl.LeaveFiredCount, "A4"); }
public void SimpleDragDrop () { DNDForm form = new DNDForm (); form.Text = MethodBase.GetCurrentMethod ().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move mouse pointer to the control in the right. " + Environment.NewLine + "3. Drop on the right control." + Environment.NewLine + "4. Close the form."; form.DragControl.DragData = "SimpleDragDropMessage"; form.DragControl.AllowedEffects = DragDropEffects.Copy; form.DropControl.DropEffect = DragDropEffects.Copy; Application.Run (form); Assert.AreEqual (DragDropEffects.Copy, form.DragControl.PerformedEffect, "A1"); Assert.IsTrue (form.DropControl.Data != null, "A2"); Assert.AreEqual (true, form.DropControl.Data.GetDataPresent (typeof (string)), "A3"); Assert.AreEqual ("SimpleDragDropMessage", form.DropControl.Data.GetData (typeof (string)), "A4"); }
public void EventsAfterDrop () { DNDForm form = new DNDForm (); form.Text = MethodBase.GetCurrentMethod ().Name; form.InstructionsText = "Instructions:" + Environment.NewLine + Environment.NewLine + "1. Click with left button on the control on the left, holding it." + Environment.NewLine + "2. Move mouse pointer to the control in the right. " + Environment.NewLine + "3. Move the pointer around and then release the mouse button." + Environment.NewLine + "4. Close the form."; form.DragControl.DragData = "hello"; form.DragControl.AllowedEffects = DragDropEffects.All; form.DropControl.DropEffect = DragDropEffects.Copy; // These should clear the event counters AND // thus the event counters should remain at 0 after drop occurred // AND we should get any MouseUp event. mouse_up_counter = 0; form.DropControl.DragDrop += new DragEventHandler (DropControl_DragDrop); form.DropControl.MouseUp += new MouseEventHandler (DropControl_MouseUp); Application.Run (form); Assert.AreEqual (DragDropEffects.Copy, form.DragControl.PerformedEffect, "A1"); Assert.AreEqual (0, form.DropControl.EnterFiredCount, "A2"); Assert.AreEqual (0, form.DropControl.LeaveFiredCount, "A3"); Assert.AreEqual (0, form.DropControl.DropFiredCount, "A4"); Assert.AreEqual (0, form.DropControl.DragOverFiredCount, "A5"); Assert.AreEqual (0, mouse_up_counter, "A6"); }