コード例 #1
0
        internal void SetCurrentUri(FrameWrapper frame, Uri itemUri)
        {
            var context = GetNewOrExistingContext(itemUri);

            _mapFrameToUri[frame] = context;
        }
コード例 #2
0
        internal Uri GetCurrentUri(FrameWrapper frame)
        {
            EditingContext context = null;
            if (!_mapFrameToUri.TryGetValue(frame, out context))
            {
                if (context == null)
                {
                    SetCurrentUri(frame, frame.Uri);
                    return frame.Uri;
                }
            }

            var artifactService = context.GetEFArtifactService();
            Debug.Assert(
                artifactService != null && artifactService.Artifact != null,
                "There is no artifact service/artifact tied to this editing context!");
            if (artifactService != null
                && artifactService.Artifact != null)
            {
                return artifactService.Artifact.Uri;
            }
            return null;
        }
コード例 #3
0
 internal void SetCurrentUri(FrameWrapper frame, Uri itemUri)
 {
     var context = GetNewOrExistingContext(itemUri);
     _mapFrameToUri[frame] = context;
 }
コード例 #4
0
 internal Collection<Uri> GetAssociatedUris(FrameWrapper frame)
 {
     if (frame.IsDesignerDocInDesigner)
     {
         return new Collection<Uri>(new[] { frame.Uri });
     }
     if (frame.IsDesignerDocInXmlEditor)
     {
         return GetAssociatedUris(frame.Uri);
     }
     return null;
 }
コード例 #5
0
        internal void OnCloseFrame(FrameWrapper closingFrame)
        {
            if (_mapFrameToUri.ContainsKey(closingFrame))
            {
                _mapFrameToUri.Remove(closingFrame);

                if (null != closingFrame.Uri)
                {
                    var rdt = new RunningDocumentTable(_package);
                    var doc = rdt.FindDocument(closingFrame.Uri.LocalPath);
                    if (doc != null)
                    {
                        var isModified = false;
                        using (var docData = new DocData(doc))
                        {
                            isModified = docData.Modified;
                        }
                        if (isModified)
                        {
                            // document was modified but was closed without saving changes;
                            // we need to refresh all sets that refer to the document
                            // so that they revert to the document that is persisted in the file system

                            // TODO: add this functinality
                            //ModelManager.RefreshModelForLocation(closingFrame.Uri);
                        }
                    }
                }
            }
        }
コード例 #6
0
 private void ReloadArtifactIfNecessary(FrameWrapper frameWrapper)
 {
     if (frameWrapper != null
         &&
         frameWrapper.Uri != null
         &&
         frameWrapper.IsDocumentOpen(_package)) // don't need to reload if the document isn't open at all
     {
         // It is important here to check that the file is open in the designer's editor 
         // and not just check the extension since the document could be open in the Xml Editor. 
         // In which case, the document would the designer's extension but we don't want to do anything
         // designer-related
         if (frameWrapper.IsDesignerDocInDesigner)
         {
             var context = EditingContextManager.GetNewOrExistingContext(frameWrapper.Uri);
             var artifact = context.GetEFArtifactService().Artifact;
             if (artifact.RequireDelayedReload)
             {
                 try
                 {
                     artifact.ReloadArtifact();
                 }
                 finally
                 {
                     artifact.RequireDelayedReload = false;
                 }
             }
         }
     }
 }
コード例 #7
0
        /// <summary>
        ///     Used whenever we need to change window frame selection (switching/opening/closing). This is used
        ///     when we are explicitly given a new window frame.
        /// </summary>
        /// <param name="frame"></param>
        private void UpdateToolWindowsAndCmdsForFrame(FrameWrapper newFrame)
        {
            if (newFrame.ShouldShowToolWindows)
            {
                var artifactUri = _editingContextMgr.GetCurrentUri(newFrame);

                var context = _editingContextMgr.GetNewOrExistingContext(artifactUri);
                Debug.Assert(context != null, "Context is null in UpdateToolWindowsForFrame! The tool windows may not show.");

                SetCurrentContext(context);
            }
            else
            {
                SetCurrentContext(null);
            }
        }
コード例 #8
0
 /// <summary>
 ///     Used when we need to update the tool windows for the active frame. This is a wrapper around
 ///     UpdateToolWindowsForFrame.
 /// </summary>
 /// <param name="closingFrame"></param>
 private void UpdateToolWindowsAndCmdsForActiveFrame(FrameWrapper closingFrame)
 {
     object pvarValue;
     NativeMethods.ThrowOnFailure(_sel.GetCurrentElementValue((uint)VSConstants.VSSELELEMID.SEID_DocumentFrame, out pvarValue));
     var activeFrame = CreateFrameWrapper(pvarValue as IVsWindowFrame);
     if (!activeFrame.Equals(closingFrame))
     {
         UpdateToolWindowsAndCmdsForFrame(activeFrame);
     }
 }