Esempio n. 1
0
 private static void DoDelete(IResourceList resList)
 {
     foreach (IResource res in resList.ValidResources)
     {
         string           type    = res.Type;
         IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(type);
         if (ResourceDeleterOptions.GetDeleteAlwaysPermanently(type))
         {
             deleter.DeleteResourcePermanent(res);
         }
         else
         {
             deleter.DeleteResource(res);
         }
     }
 }
Esempio n. 2
0
 public override void OK()
 {
     foreach (JetListViewNode node in _deletersListView.Nodes)
     {
         IResource resType = (IResource)node.Data;
         string    type    = resType.GetPropText(Core.Props.Name);
         if (type.Length > 0)
         {
             CheckBoxState state = _confirmDeleteColumn.GetItemCheckState(resType);
             if (state == CheckBoxState.Checked)
             {
                 ResourceDeleterOptions.SetConfirmDeleteToRecycleBin(type, true);
             }
             else if (state == CheckBoxState.Unchecked)
             {
                 ResourceDeleterOptions.SetConfirmDeleteToRecycleBin(type, false);
             }
             ResourceDeleterOptions.SetConfirmDeletePermanently(type,
                                                                _confirmPermanentDeleteColumn.GetItemCheckState(resType) == CheckBoxState.Checked);
             ResourceDeleterOptions.SetDeleteAlwaysPermanently(type,
                                                               _alwaysDeletePermanentlyColumn.GetItemCheckState(resType) == CheckBoxState.Checked);
         }
     }
 }
Esempio n. 3
0
 private static void  SetDefaultContactConfirmation()
 {
     ResourceDeleterOptions.SetConfirmDeleteToRecycleBin("Contact", true);
 }
Esempio n. 4
0
        public void Execute(IActionContext context)
        {
            IResourceList resourcesToDelete = null;
            IResourceList selResources      = context.SelectedResourcesExpanded;

            string[]       selTypes     = selResources.GetAllTypes();
            IResourceStore store        = Core.ResourceStore;
            IResourceList  allDeleted   = store.FindResourcesWithProp(null, Core.Props.IsDeleted);
            bool           shiftPressed = Control.ModifierKeys == Keys.Shift;

            foreach (string resType in selTypes)
            {
                IResourceList typedResources = selResources.Intersect(store.GetAllResources(resType));
                IResourceList deletedTypedResources;
                bool          deletePermanent = shiftPressed;
                if (deletePermanent || ResourceDeleterOptions.GetDeleteAlwaysPermanently(resType))
                {
                    deletedTypedResources = typedResources;
                    typedResources        = store.EmptyResourceList;
                    deletePermanent       = true;
                }
                else
                {
                    deletedTypedResources = typedResources.Intersect(allDeleted);
                    typedResources        = typedResources.Minus(deletedTypedResources);
                }
                IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(resType);
                DialogResult     result  = DialogResult.No;
                if (typedResources.Count > 0)
                {
                    if (!ResourceDeleterOptions.GetConfirmDeleteToRecycleBin(resType))
                    {
                        result = DialogResult.Yes;
                    }
                    else
                    {
                        result = deleter.ConfirmDeleteResources(typedResources, deletePermanent, (selTypes.Length > 1));
                    }
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                    if (result == DialogResult.Yes)
                    {
                        resourcesToDelete = typedResources.Union(resourcesToDelete);
                    }
                }
                if (deletedTypedResources.Count > 0)
                {
                    if (!ResourceDeleterOptions.GetConfirmDeletePermanently(resType))
                    {
                        result = DialogResult.Yes;
                    }
                    else
                    {
                        result = deleter.ConfirmDeleteResources(deletedTypedResources, true, (selTypes.Length > 1));
                    }
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                    if (result == DialogResult.Yes)
                    {
                        resourcesToDelete = deletedTypedResources.Union(resourcesToDelete);
                    }
                }
            }

            if (resourcesToDelete != null)
            {
                Core.ResourceAP.QueueJob(JobPriority.Immediate, "Deleting resources",
                                         new ResourceListDelegate(DoDelete), resourcesToDelete);
            }
        }
Esempio n. 5
0
        private void ShowPaneImpl()
        {
            if (!Core.UserInterfaceAP.IsOwnerThread)
            {
                Core.UserInterfaceAP.QueueJob(new MethodInvoker(ShowPaneImpl));
                return;
            }
            _deletersListView.Nodes.Clear();
            IResourceList resTypes = Core.ResourceStore.GetAllResources("ResourceType");

            foreach (IResource resType in resTypes.ValidResources)
            {
                if (resType.GetIntProp("Internal") != 0)
                {
                    continue;
                }
                string type = resType.GetPropText(Core.Props.Name);
                if (type.Length > 0 && Core.ResourceStore.ResourceTypes.Exist(type))
                {
                    IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(type);
                    if (deleter != null)
                    {
                        _deletersListView.Nodes.Add(resType);
                        bool canDelete = deleter.CanDeleteResource(null, false);
                        if (!canDelete)
                        {
                            _confirmDeleteColumn.SetItemCheckState(resType, CheckBoxState.Grayed | CheckBoxState.Unchecked);
                        }
                        else
                        {
                            _confirmDeleteColumn.SetItemCheckState(resType,
                                                                   ResourceDeleterOptions.GetConfirmDeleteToRecycleBin(type) ? CheckBoxState.Checked : CheckBoxState.Unchecked);
                        }
                        bool canDeletePermanently = deleter.CanDeleteResource(null, true);
                        if (!canDeletePermanently)
                        {
                            _confirmPermanentDeleteColumn.SetItemCheckState(resType, CheckBoxState.Grayed | CheckBoxState.Unchecked);
                        }
                        else
                        {
                            _confirmPermanentDeleteColumn.SetItemCheckState(resType,
                                                                            ResourceDeleterOptions.GetConfirmDeletePermanently(type) ? CheckBoxState.Checked : CheckBoxState.Unchecked);
                        }

                        if (!deleter.CanIgnoreRecyclebin())
                        {
                            _alwaysDeletePermanentlyColumn.SetItemCheckState(resType, CheckBoxState.Grayed | CheckBoxState.Unchecked);
                        }
                        else
                        if (canDelete != canDeletePermanently)
                        {
                            _alwaysDeletePermanentlyColumn.SetItemCheckState(resType, CheckBoxState.Grayed |
                                                                             (canDelete ? CheckBoxState.Unchecked : CheckBoxState.Checked));
                        }
                        else
                        {
                            _alwaysDeletePermanentlyColumn.SetItemCheckState(resType,
                                                                             ResourceDeleterOptions.GetDeleteAlwaysPermanently(type) ? CheckBoxState.Checked : CheckBoxState.Unchecked);
                        }
                    }
                }
            }
        }