private void _pictureBox_DragEnter(Object sender, DragEventArgs e) { if (NuGenArgument.GetCompatibleDataObjectType(e.Data, typeof(IDescriptor)) != null) { e.Effect = DragDropEffects.Copy; } }
private void _pictureBox_DragDrop(Object sender, DragEventArgs e) { Type descriptorType = NuGenArgument.GetCompatibleDataObjectType(e.Data, typeof(IDescriptor)); IDescriptor descriptor = (IDescriptor)e.Data.GetData(descriptorType); NodeBase nodeToAdd = descriptor.CreateNode(this); Point cp = _pictureBox.PointToClient(new Point(e.X, e.Y)); AddNode(nodeToAdd, new Point((Int32)(cp.X / _scale), (Int32)(cp.Y / _scale))); }
public void GetCompatibleDataObjectTypeInheritanceTest() { Assert.AreEqual( typeof(Button), NuGenArgument.GetCompatibleDataObjectType(_dataObject, typeof(Control)) ); Assert.IsNull( NuGenArgument.GetCompatibleDataObjectType(_dataObject, typeof(TextBox)) ); }
public void GetCompatibleDataObjectTypeInterfaceTest() { MockDataTarget mockDataTarget = new MockDataTarget(); Assert.AreEqual( typeof(MockDataTarget), NuGenArgument.GetCompatibleDataObjectType(new DataObject(mockDataTarget), typeof(IMockDataTarget)) ); Assert.IsNull( NuGenArgument.GetCompatibleDataObjectType(_dataObject, typeof(IMockObject)) ); }
/* * OnDragEnter */ /// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.DragEnter"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.DragEventArgs"></see> that contains the event data.</param> protected override void OnDragEnter(DragEventArgs e) { if (NuGenArgument.GetCompatibleDataObjectType(e.Data, typeof(NuGenTaskTreeNodeBase)) != null) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } base.OnDragEnter(e); }
public void GetCompatibleDataObjectTypeArgumentNullExceptionOnCompatibleType() { NuGenArgument.GetCompatibleDataObjectType(_dataObject, null); }
public void GetCompatibleDataObjectTypeArgumentNullExceptionOnDataObject() { NuGenArgument.GetCompatibleDataObjectType(null, typeof(IMockDataTarget)); }