예제 #1
0
        private void DeleteDocument_Unsynchronized(Main.IProjectItem document, bool force)
        {
            if (!force &&
                false == Current.Gui.YesNoMessageBox(string.Format("Are you sure to remove the {0} and the corresponding views?", document.GetType().Name), "Attention", false))
            {
                return;
            }

            // close all windows
            var foundContent = Current.Workbench.GetViewModels <IViewContent>(document);

            foreach (IViewContent content in foundContent.ToArray()) // ToArray because we change the collection by closing
            {
                if (content.CloseCommand.CanExecute(true))
                {
                    content.CloseCommand.Execute(true);
                }
            }

            Current.Project.RemoveItem(document);

            // the following sequence is related to a bug encountered when closing a tabbed window by the program:
            // the active view content is not updated because the dockpanel lost the focus
            // to circumvent this, we focus on a new viewcontent, in this case the first one
            SelectFirstAvailableView();
        }
예제 #2
0
        /// <summary>
        /// This function will delete a project item and close the corresponding views.
        /// </summary>
        /// <param name="document">The project item to delete</param>
        /// <param name="force">If true, the document is deleted without safety question,
        /// if false, the user is ask before the document is deleted.</param>
        public override void DeleteDocument(Main.IProjectItem document, bool force)
        {
            if (null == document)
            {
                throw new ArgumentNullException(nameof(document));
            }

            Current.Dispatcher.InvokeIfRequired(DeleteDocument_Unsynchronized, document, force);
        }