示例#1
0
        private void FormReplaceObject_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ItemType)))
            {
                var item = ItemInstance.FromItemType((ItemType)e.Data.GetData(typeof(ItemType)));
                PositionBasedObjectInstance instance;

                if (item is StaticInstance)
                {
                    instance = new StaticInstance()
                    {
                        WadObjectId = item.ItemType.StaticId
                    }
                }
                ;
                else if (item is MoveableInstance)
                {
                    instance = new MoveableInstance()
                    {
                        WadObjectId = item.ItemType.MoveableId
                    }
                }
                ;
                else
                {
                    return;
                }

                bool dest = e.Y >= PointToScreen(lblDest.Location).Y;
                ToggleItem(instance, dest ? ObjectSelectionType.Destination : ObjectSelectionType.Source);
            }
        }