コード例 #1
0
        /// <summary>
        /// Save the given document that is subordinate to this document.
        /// </summary>
        /// <param name="subordinateDocument"></param>
        /// <param name="fileName"></param>
        protected override void SaveSubordinateFile(DslShell::DocData subordinateDocument, string fileName)
        {
            // In this case, the only subordinate is the diagram.
            DslModeling::SerializationResult serializationResult = new DslModeling::SerializationResult();

            global::System.Collections.Generic.IList <DslDiagrams::PresentationElement> diagrams = DslDiagrams::PresentationViewsSubject.GetPresentation(this.RootElement);
            if (diagrams.Count > 0)
            {
                global::pelsoft.FWK_Dsl.ClassDiagram diagram = diagrams[0] as global::pelsoft.FWK_Dsl.ClassDiagram;
                if (diagram != null)
                {
                    try
                    {
                        this.SuspendFileChangeNotification(fileName);

                        global::pelsoft.FWK_Dsl.FWK_DslSerializationHelper.Instance.SaveDiagram(serializationResult, diagram, fileName, this.Encoding, false);
                    }
                    finally
                    {
                        this.ResumeFileChangeNotification(fileName);
                    }
                }
            }
            // Report serialization messages.
            this.SuspendErrorListRefresh();
            try
            {
                foreach (DslModeling::SerializationMessage serializationMessage in serializationResult)
                {
                    this.AddErrorListItem(new DslShell::SerializationErrorListItem(this.ServiceProvider, serializationMessage));
                }
            }
            finally
            {
                this.ResumeErrorListRefresh();
            }

            if (!serializationResult.Failed)
            {
                // Notify the Running Document Table that the subordinate has been saved
                if (this.ServiceProvider != null)
                {
                    VSShellInterop::IVsRunningDocumentTable rdt = (VSShellInterop.IVsRunningDocumentTable) this.ServiceProvider.GetService(typeof(VSShellInterop::IVsRunningDocumentTable));
                    if (rdt != null && this.diagramDocumentLockHolder != null && this.diagramDocumentLockHolder.SubordinateDocData != null)
                    {
                        global::Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(rdt.NotifyOnAfterSave(this.diagramDocumentLockHolder.SubordinateDocData.Cookie));
                    }
                }
            }
            else
            {
                // Save failed.
                throw new global::System.InvalidOperationException(global::pelsoft.FWK_Dsl.FWK_DslDomainModel.SingletonResourceManager.GetString("CannotSaveDocument"));
            }
        }
コード例 #2
0
 /// <summary>
 /// Notify the RDT that the sub-ordinate document has been saved, assuming saved to the same file as registered in the RDT
 /// </summary>
 protected virtual void NotifySubordinateDocumentSaved(string oldFileName, string newFileName)
 {
     if (this.ServiceProvider != null)
     {
         if (global::System.StringComparer.OrdinalIgnoreCase.Compare(oldFileName, newFileName) == 0)
         {
             VSShellInterop::IVsRunningDocumentTable rdt = (VSShellInterop.IVsRunningDocumentTable) this.ServiceProvider.GetService(typeof(VSShellInterop::SVsRunningDocumentTable));
             if (rdt != null && this.diagramDocumentLockHolder != null && this.diagramDocumentLockHolder.SubordinateDocData != null)
             {
                 global::Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(rdt.NotifyOnAfterSave(this.diagramDocumentLockHolder.SubordinateDocData.Cookie));
             }
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Handle when document has been saved
        /// </summary>
        /// <param name="e"></param>
        protected override void OnDocumentSaved(System.EventArgs e)
        {
            base.OnDocumentSaved(e);

            // Notify the Running Document Table that the subordinate has been saved
            if (this.ServiceProvider != null)
            {
                VSShellInterop::IVsRunningDocumentTable rdt = (VSShellInterop.IVsRunningDocumentTable) this.ServiceProvider.GetService(typeof(VSShellInterop::IVsRunningDocumentTable));
                if (rdt != null && this.diagramDocumentLockHolder != null && this.diagramDocumentLockHolder.SubordinateDocData != null)
                {
                    global::Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(rdt.NotifyOnAfterSave(this.diagramDocumentLockHolder.SubordinateDocData.Cookie));
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Handle when document has been saved
        /// </summary>
        /// <param name="e"></param>
        protected override void OnDocumentSaved(global::System.EventArgs e)
        {
            base.OnDocumentSaved(e);

            // Notify the Running Document Table that the subordinate has been saved
            // If this was a SaveAs, then let the subordinate document do this notification itself.
            // Otherwise VS will never ask the subordinate to save itself.
            DslShell::DocumentSavedEventArgs savedEventArgs = e as DslShell::DocumentSavedEventArgs;

            if (savedEventArgs != null && this.ServiceProvider != null)
            {
                if (global::System.StringComparer.OrdinalIgnoreCase.Compare(savedEventArgs.OldFileName, savedEventArgs.NewFileName) == 0)
                {
                    VSShellInterop::IVsRunningDocumentTable rdt = (VSShellInterop.IVsRunningDocumentTable) this.ServiceProvider.GetService(typeof(VSShellInterop::IVsRunningDocumentTable));
                    if (rdt != null && this.diagramDocumentLockHolder != null && this.diagramDocumentLockHolder.SubordinateDocData != null)
                    {
                        global::Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(rdt.NotifyOnAfterSave(this.diagramDocumentLockHolder.SubordinateDocData.Cookie));
                    }
                }
            }
        }