コード例 #1
0
 private void _pictureBox_DragEnter(Object sender, DragEventArgs e)
 {
     if (NuGenArgument.GetCompatibleDataObjectType(e.Data, typeof(IDescriptor)) != null)
     {
         e.Effect = DragDropEffects.Copy;
     }
 }
コード例 #2
0
        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)));
        }
コード例 #3
0
        public void GetCompatibleDataObjectTypeInheritanceTest()
        {
            Assert.AreEqual(
                typeof(Button),
                NuGenArgument.GetCompatibleDataObjectType(_dataObject, typeof(Control))
                );

            Assert.IsNull(
                NuGenArgument.GetCompatibleDataObjectType(_dataObject, typeof(TextBox))
                );
        }
コード例 #4
0
        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))
                );
        }
コード例 #5
0
        /*
         * 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);
        }
コード例 #6
0
 public void GetCompatibleDataObjectTypeArgumentNullExceptionOnCompatibleType()
 {
     NuGenArgument.GetCompatibleDataObjectType(_dataObject, null);
 }
コード例 #7
0
 public void GetCompatibleDataObjectTypeArgumentNullExceptionOnDataObject()
 {
     NuGenArgument.GetCompatibleDataObjectType(null, typeof(IMockDataTarget));
 }