private void UpdateExternalNodes()
        {
            ISceneViewHost sceneViewHost = (ISceneViewHost)this.multiDocumentReferenceChangeModel.ProjectContext.GetService(typeof(ISceneViewHost));

            foreach (IGrouping <IDocumentRoot, ChangedNodeInfo> grouping in Enumerable.Select <IGrouping <IDocumentRoot, ChangedNodeInfo>, IGrouping <IDocumentRoot, ChangedNodeInfo> >(Enumerable.GroupBy <ChangedNodeInfo, IDocumentRoot>((IEnumerable <ChangedNodeInfo>) this.multiDocumentReferenceChangeModel.NodesForExternalUpdate, (Func <ChangedNodeInfo, IDocumentRoot>)(changeInfo => changeInfo.Node.DocumentRoot)), (Func <IGrouping <IDocumentRoot, ChangedNodeInfo>, IGrouping <IDocumentRoot, ChangedNodeInfo> >)(documentGroup => documentGroup)))
            {
                SceneView      sceneView      = sceneViewHost.OpenView(grouping.Key, false);
                SceneViewModel sceneViewModel = sceneView != null ? sceneView.ViewModel : (SceneViewModel)null;
                using (SceneEditTransaction editTransaction = sceneViewModel.CreateEditTransaction(this.UndoDescription))
                {
                    if (sceneViewModel != null)
                    {
                        foreach (ChangedNodeInfo changedNodeInfo in (IEnumerable <ChangedNodeInfo>)grouping)
                        {
                            this.ApplyChange(changedNodeInfo);
                        }
                    }
                    if (this.documentsToClose.Contains(sceneViewModel.Document))
                    {
                        this.documentsToClose.Remove(sceneViewModel.Document);
                    }
                    editTransaction.Commit();
                }
            }
        }
        public override void EnsureEditable()
        {
            base.EnsureEditable();
            if (this.contentProvider.Document == null)
            {
                this.contentProvider.ProjectItem.OpenDocument(false);
            }
            if (this.contentProvider.View != null || this.contentProvider.Document == null)
            {
                return;
            }
            ISceneViewHost sceneViewHost = (ISceneViewHost)this.ProjectContext.GetService(typeof(ISceneViewHost));

            if (sceneViewHost == null)
            {
                return;
            }
            this.contentProvider.View = sceneViewHost.OpenView((IDocumentRoot)this.contentProvider.Document, false);
        }
            protected override void Work()
            {
                IProjectDocument projectDocument = this.model.ResourceEntryNode.ProjectContext.OpenDocument(this.documentPaths[this.documentPathIndex]);

                if (projectDocument == null)
                {
                    return;
                }
                SceneDocument sceneDocument = projectDocument.Document as SceneDocument;

                if (sceneDocument == null)
                {
                    return;
                }
                SceneViewModel sceneViewModel = (SceneViewModel)null;
                ISceneViewHost sceneViewHost  = (ISceneViewHost)sceneDocument.ProjectContext.GetService(typeof(ISceneViewHost));

                if (sceneViewHost != null)
                {
                    SceneView sceneView = sceneViewHost.OpenView(sceneDocument.DocumentRoot, false);
                    sceneViewModel = sceneView != null ? sceneView.ViewModel : (SceneViewModel)null;
                }
                if (sceneViewModel == null)
                {
                    return;
                }
                List <SceneNode> list = new List <SceneNode>();

                sceneViewModel.FindInternalResourceReferences((DocumentCompositeNode)this.model.ResourceEntryNode.DocumentNode, (ICollection <SceneNode>)list);
                if (list.Count <= 0)
                {
                    return;
                }
                using (SceneEditTransaction editTransaction = sceneDocument.CreateEditTransaction(StringTable.ReferencesFixupEditTransaction))
                {
                    foreach (SceneNode reference in list)
                    {
                        this.model.FixupIndividualReference((DocumentCompositeNode)this.model.ResourceEntryNode.DocumentNode, reference);
                    }
                    editTransaction.Commit();
                }
            }
Exemple #4
0
        internal static void EditControl(SceneElement sceneElement)
        {
            if (sceneElement == null || sceneElement.DocumentNode == null)
            {
                return;
            }
            IType type = sceneElement.DocumentNode.Type;

            if (type.XamlSourcePath == null)
            {
                return;
            }
            try
            {
                IDocumentRoot  documentRoot  = sceneElement.ProjectContext.GetDocumentRoot(type.XamlSourcePath);
                ISceneViewHost sceneViewHost = sceneElement.ProjectContext as ISceneViewHost;
                if (sceneViewHost == null || documentRoot == null)
                {
                    return;
                }
                sceneViewHost.OpenView(documentRoot, true);
            }
            catch (Exception ex)
            {
                if (ex is ArgumentException || ex is IOException || (ex is InvalidOperationException || ex is UnauthorizedAccessException))
                {
                    string message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.FileOpenFailedDialogMessage, new object[2]
                    {
                        (object)Path.GetFileName(type.XamlSourcePath),
                        (object)ex.Message
                    });
                    sceneElement.DesignerContext.MessageDisplayService.ShowError(message);
                }
                else
                {
                    throw;
                }
            }
        }