public void DeleteSelectedItems()
        {
            if (ItemsDeleting != null)
            {
                if (m_listBox.SelectedItems != null)
                {
                    ProjectTreeCancelEventArgs args = new ProjectTreeCancelEventArgs(m_listBox.SelectedItems.OfType <ProjectItem>().ToArray());
                    ItemsDeleting(this, args);
                    if (args.Cancel)
                    {
                        return;
                    }
                }
            }

            m_windowManager.Confirmation(
                m_localization.GetString("ID_RTEditor_ProjectFolderView_DeleteSelectedAssets", "Delete Selected Assets"),
                m_localization.GetString("ID_RTEditor_ProjectFolderView_YouCanNotUndoThisAction", "You cannot undo this action"),
                (sender, arg) =>
            {
                m_listBox.RemoveSelectedItems();
                bool wasEnabled          = Editor.Undo.Enabled;
                Editor.Undo.Enabled      = false;
                Editor.Selection.objects = null;
                Editor.Undo.Enabled      = wasEnabled;
            },
                (sender, arg) => { },
                m_localization.GetString("ID_RTEditor_ProjectFolderView_BtnDelete", "Delete"),
                m_localization.GetString("ID_RTEditor_ProjectFolderView_BtnCancel", "Cancel"));
        }
Esempio n. 2
0
        public void DeleteSelectedItems()
        {
            if (m_treeView.SelectedItem != null)
            {
                ProjectItem[] projectItems = m_treeView.SelectedItems.OfType <ProjectItem>().ToArray();
                if (ItemsDeleting != null)
                {
                    ProjectTreeCancelEventArgs args = new ProjectTreeCancelEventArgs(projectItems);
                    ItemsDeleting(this, args);
                    if (args.Cancel)
                    {
                        return;
                    }
                }

                if (projectItems.Any(p => p.Parent == null))
                {
                    m_wm.MessageBox(
                        m_localization.GetString("ID_RTEditor_ProjectTreeView_UnableToRemove", "Unable to remove"),
                        m_localization.GetString("ID_RTEditor_ProjectTreeView_UnableToRemoveRootFolder", "Unable to remove root folder"));
                }
                else
                {
                    m_wm.Confirmation(
                        m_localization.GetString("ID_RTEditor_ProjectTreeView_DeleteSelectedAssets", "Delete selected assets"),
                        m_localization.GetString("ID_RTEditor_ProjectTreeView_YouCannotUndoThisAction", "You cannot undo this action"), (dialog, arg) =>
                    {
                        m_treeView.RemoveSelectedItems();
                    },
                        (dialog, arg) => { },
                        m_localization.GetString("ID_RTEditor_ProjectTreeView_Btn_Delete", "Delete"),
                        m_localization.GetString("ID_RTEditor_ProjectTreeView_Btn_Cancel", "Cancel"));
                }
            }
        }
        private void OpenValidate(MenuItemValidationArgs args)
        {
            ProjectItem selectedItem = (ProjectItem)m_listBox.SelectedItem;
            ProjectTreeCancelEventArgs cancelArgs = new ProjectTreeCancelEventArgs(new[] { selectedItem });

            if (m_listBox.SelectedItemsCount != 1 || !selectedItem.IsFolder && !m_project.IsScene(selectedItem))
            {
                cancelArgs.Cancel = true;
            }
            if (ValidateContextMenuOpenCommand != null)
            {
                ValidateContextMenuOpenCommand(this, cancelArgs);
            }

            args.IsValid = !cancelArgs.Cancel;
        }