Esempio n. 1
0
        private bool ReferencedBy(IProjectItem projectItem)
        {
            if (projectItem == this)
            {
                return(false);
            }
            bool flag = false;

            if (projectItem.DocumentType.CanView)
            {
                bool isOpen = false;
                if (!projectItem.IsOpen)
                {
                    projectItem.OpenDocument(false, true);
                    isOpen = projectItem.IsOpen;
                }
                if (projectItem.IsOpen)
                {
                    flag = projectItem.Document.ReferencesDocument(base.DocumentReference);
                }
                if (isOpen)
                {
                    projectItem.CloseDocument();
                }
            }
            return(flag);
        }
        private void CleanupAfterCancel(IProjectItem itemToOpen)
        {
            IProject project = itemToOpen.Project;

            itemToOpen.CloseDocument();
            project.RemoveItems(1 != 0, itemToOpen);
        }
Esempio n. 3
0
        private string GetDocumentText(IProjectItem projectItem)
        {
            string str  = (string)null;
            bool   flag = false;

            if (projectItem.Document == null)
            {
                flag = projectItem.OpenDocument(false, true);
            }
            if (projectItem.Document != null)
            {
                IReadableTextBuffer readableTextBuffer = projectItem.Document as IReadableTextBuffer;
                str = readableTextBuffer.GetText(0, readableTextBuffer.Length);
            }
            if (flag)
            {
                projectItem.CloseDocument();
            }
            return(str);
        }
Esempio n. 4
0
 protected override void RemoveProjectItem(IProjectItem projectItem, bool deleteFiles)
 {
     try
     {
         if (projectItem.Children.Any <IProjectItem>())
         {
             base.RemoveProjectItems(deleteFiles, projectItem.Children.ToArray <IProjectItem>());
         }
         base.RemoveProjectItem(projectItem, deleteFiles);
         if (projectItem.IsOpen)
         {
             projectItem.CloseDocument();
         }
         base.OnItemRemoved(new ProjectItemEventArgs(projectItem));
         if (deleteFiles)
         {
             base.DeleteProjectItem(projectItem);
         }
     }
     finally
     {
         projectItem.Dispose();
     }
 }
Esempio n. 5
0
        private void Project_ItemChanged(object sender, ProjectItemEventArgs e)
        {
            IProjectItem projectItem = e.ProjectItem;

            if (projectItem.IsOpen)
            {
                MessageBoxResult messageBoxResult = MessageBoxResult.No;
                string           projectItemChangedDialogFileDirtyMessage = null;
                if (projectItem.IsDirty)
                {
                    if ((e.Options & ProjectItemEventOptions.SilentIfDirty) != ProjectItemEventOptions.SilentIfDirty)
                    {
                        projectItemChangedDialogFileDirtyMessage = StringTable.ProjectItemChangedDialogFileDirtyMessage;
                    }
                    else
                    {
                        messageBoxResult = MessageBoxResult.Yes;
                    }
                }
                else if ((e.Options & ProjectItemEventOptions.SilentIfOpen) != ProjectItemEventOptions.SilentIfOpen)
                {
                    projectItemChangedDialogFileDirtyMessage = StringTable.ProjectItemChangedDialogFileCleanMessage;
                }
                else
                {
                    messageBoxResult = MessageBoxResult.Yes;
                }
                if (!SolutionBase.IsReloadPromptEnabled())
                {
                    messageBoxResult = MessageBoxResult.Yes;
                    projectItemChangedDialogFileDirtyMessage = null;
                }
                if (!string.IsNullOrEmpty(projectItemChangedDialogFileDirtyMessage))
                {
                    MessageBoxArgs messageBoxArg  = new MessageBoxArgs();
                    CultureInfo    currentCulture = CultureInfo.CurrentCulture;
                    object[]       path           = new object[] { projectItem.DocumentReference.Path, base.Services.ExpressionInformationService().ShortApplicationName };
                    messageBoxArg.Message = string.Format(currentCulture, projectItemChangedDialogFileDirtyMessage, path);
                    messageBoxArg.Button  = MessageBoxButton.YesNo;
                    messageBoxArg.Image   = MessageBoxImage.Exclamation;
                    MessageBoxArgs messageBoxArg1 = messageBoxArg;
                    messageBoxResult = base.Services.MessageDisplayService().ShowMessage(messageBoxArg1);
                }
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    bool isReadOnly = projectItem.Document.IsReadOnly;
                    bool document   = projectItem.Document == base.Services.DocumentService().ActiveDocument;
                    bool flag       = false;
                    foreach (IView view in base.Services.ViewService().Views)
                    {
                        IDocumentView documentView = view as IDocumentView;
                        if (documentView == null || documentView.Document != projectItem.Document)
                        {
                            continue;
                        }
                        flag = true;
                        break;
                    }
                    projectItem.CloseDocument();
                    projectItem.OpenDocument(isReadOnly);
                    if (projectItem.IsOpen && flag)
                    {
                        projectItem.OpenView(document);
                    }
                }
            }
        }