示例#1
0
        protected override void OnDragEnter(DragEventArgs drgevent)
        {
            base.OnDragEnter(drgevent);
            IGame dragDropTarget = TargetGame();

            if (dragDropTarget.RootGameObjectFolder.IsLocked)
            {
                drgevent.Effect = DragDropEffects.None;
                return;
            }

            IGameObjectFolder rootFolder = dragDropTarget.RootGameObjectFolder;

            m_ghosts.Clear();

            ResourceConverterService resourceConverter = Globals.MEFContainer.GetExportedValue <ResourceConverterService>();


            IEnumerable <object> nodes = Util.ConvertData(drgevent.Data, false);

            foreach (object iterNode in nodes)
            {
                DomNode node = iterNode as DomNode;
                if (node == null)
                {
                    if (resourceConverter != null)
                    {
                        IGameObject resGob = resourceConverter.Convert(iterNode as IResource);
                        node = resGob.As <DomNode>();
                    }
                }

                IGameObject gob = node.As <IGameObject>();
                if (gob == null || node.GetRoot().Is <IGame>())
                {
                    continue;
                }

                node.InitializeExtensions();
                m_ghosts.Add(node);
                rootFolder.GameObjects.Add(gob);
            }

            drgevent.Effect = m_ghosts.Count > 0 ? DragDropEffects.Move | DragDropEffects.Link
            : DragDropEffects.None;
        }