Exemplo n.º 1
0
        protected override void OnDragEnter(DragEventArgs drgevent)
        {
            base.OnDragEnter(drgevent);
            var dragDropTarget = TargetGame();

            foreach (DomNode ghost in m_ghosts)
            {
                ghost.RemoveFromParent();
            }
            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)
                    {
                        var resGob = resourceConverter.Convert(iterNode as IResource);
                        node = resGob.As <DomNode>();
                    }
                }

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

                node.InitializeExtensions();

                var  hierarchical = dragDropTarget.AsAll <IHierarchical>();
                bool wasInserted  = false;
                foreach (var h in hierarchical)
                {
                    if (h.AddChild(node))
                    {
                        wasInserted = true; break;
                    }
                }

                if (wasInserted)
                {
                    m_ghosts.Add(node);
                }
            }

            drgevent.Effect = (m_ghosts.Count > 0) ? (DragDropEffects.Move | DragDropEffects.Link) : DragDropEffects.None;
        }
Exemplo n.º 2
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;
        }