Esempio n. 1
0
        public void Drop(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState)
        {
            if (data.GetDataPresent(typeof(IResourceList)))
            {
                // The resources we're dragging
                IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList));

                // Currently, only the Deleted Resources view has a drop handler
                if (FilterRegistry.IsDeletedResourcesView(targetResource))
                {
                    // Delete the resources dropped onto the deleted items view
                    foreach (IResource res in dragResources)
                    {
                        IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(res.Type);
                        if (deleter != null)
                        {
                            try
                            {
                                Core.ResourceAP.RunJob(new ResourceDelegate(deleter.DeleteResource), res);
//								deleter.DeleteResource( res );
                            }
                            catch (NotImplementedException)
                            {
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
            }
        }
Esempio n. 2
0
        public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState)
        {
            if (data.GetDataPresent(typeof(IResourceList)))
            {
                // The resources we're dragging
                IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList));

                // Currently, only the Deleted Resources view has a drop handler
                if (!FilterRegistry.IsDeletedResourcesView(targetResource))
                {
                    return(DragDropEffects.None);
                }

                // Collect all the direct and indirect parents of the droptarget; then we'll check to avoid dropping parent on its children
                IntArrayList parentList = IntArrayListPool.Alloc();
                try
                {
                    IResource parent = targetResource;
                    while (parent != null)
                    {
                        parentList.Add(parent.Id);
                        parent = parent.GetLinkProp(Core.Props.Parent);
                    }

                    // Check
                    foreach (IResource res in dragResources)
                    {
                        // Dropping parent over its child?
                        if (parentList.IndexOf(res.Id) >= 0)
                        {
                            return(DragDropEffects.None);
                        }
                        // Cannot delete resource containers this way
                        if ((Core.ResourceStore.ResourceTypes[res.Type].Flags & ResourceTypeFlags.ResourceContainer) != 0)
                        {
                            return(DragDropEffects.None); // Cannot delete containers
                        }
                    }
                    return(DragDropEffects.Move);
                }
                finally
                {
                    IntArrayListPool.Dispose(parentList);
                }
            }
            else
            {
                return(DragDropEffects.None);
            }
        }