Dev2.Studio.UserInterfaceLayoutProvider.RemoveDocument C# (CSharp) Method

RemoveDocument() public method

Removes the document passed in from the tab collection
public RemoveDocument ( object document ) : bool
document object The Document that will be removed
return bool
        public bool RemoveDocument(object document)
        {
            bool removeTab = false;
            var documentToRemove = document as FrameworkElement;
            if (documentToRemove != null)
            {
                if (documentToRemove.DataContext is IWorkflowDesignerViewModel)
                {
                    var viewModel = documentToRemove.DataContext as IWorkflowDesignerViewModel;
                    //19.10.2012: massimo.guerrera - Added for PBI 5782
                    bool dontShowPopup = viewModel.ResourceModel.IsWorkflowSaved(viewModel.ServiceDefinition);
                    if (!dontShowPopup)
                    {
                        //TODO - Call to get all the errors for this workflow
                        string errorMessages = string.Empty;

                        IPopUp pop = new PopUp(
                            "Workflow not saved...",
                            string.Concat(
                                "The workflow that you are closing is not saved.\r\nWould you like to save the  workflow?\r\n-------------------------------------------------------------------\r\nClicking Yes will save the workflow\r\nClicking No will discard your changes\r\nClicking Cancel will return you to the workflow",
                                errorMessages),
                            MessageBoxImage.Information,
                            MessageBoxButton.YesNoCancel
                            );
                        MessageBoxResult res = pop.Show();
                        switch (res)
                        {
                            case MessageBoxResult.No:
                                removeTab = true;
                                break;
                            case MessageBoxResult.Yes:
                                Mediator.SendMessage(MediatorMessages.SaveResource, viewModel.ResourceModel);
                                removeTab = true;
                                break;
                        }
                    }
                    else
                    {
                        removeTab = true;
                    }
                    if (removeTab)
                    {
                        if (ActiveDocument != null && ActiveDocument.Equals(documentToRemove))
                        {
                            RemoveDataList();
                        }
                        Tabs.Remove(documentToRemove);
                        RemoveWorkspaceItem(viewModel);
                        viewModel.Dispose();
                    }
                }
                else
                {
                    if (ActiveDocument.Equals(documentToRemove))
                    {
                        RemoveDataList();
                    }
                    Tabs.Remove(documentToRemove);
                    removeTab = true;
                }
            }
            return removeTab;
        }