Пример #1
0
        internal static IEnumerable <SceneDocument> GetDesignTimeResourceDocuments(IProjectContext projectContext)
        {
            if (projectContext == null || projectContext.Documents == null)
            {
                return(Enumerable.Empty <SceneDocument>());
            }
            List <SceneDocument> list            = new List <SceneDocument>();
            IProjectContext      projectContext1 = projectContext;
            IProjectDocument     application     = projectContext.Application;

            if (application != null)
            {
                SceneDocument sceneDocument = application.Document as SceneDocument;
                if (sceneDocument != null)
                {
                    list.Add(sceneDocument);
                    projectContext1 = sceneDocument.ProjectContext;
                }
            }
            foreach (IProjectDocument projectDocument in (IEnumerable <IProjectDocument>)projectContext1.Documents)
            {
                if (projectDocument.ProjectItem != null && projectDocument.ProjectItem.ContainsDesignTimeResources)
                {
                    SceneDocument sceneDocument = projectDocument.Document as SceneDocument;
                    if (sceneDocument != null)
                    {
                        list.Add(sceneDocument);
                    }
                }
            }
            return((IEnumerable <SceneDocument>)list);
        }
Пример #2
0
        protected override void RefreshInstance(SceneElement element, SceneDocument sceneDocument, string url)
        {
            ImageElement imageElement = element as ImageElement;

            if (imageElement == null)
            {
                return;
            }
            string uri = imageElement.Uri;

            imageElement.Uri = (string)null;
            imageElement.Uri = uri;
        }
Пример #3
0
        protected SceneViewModel GetSceneViewModel(SceneDocument sceneDocument)
        {
            SceneViewModel sceneViewModel = (SceneViewModel)null;

            foreach (IView view in (IEnumerable <IView>) this.designerContext.ViewService.Views)
            {
                SceneView sceneView = view as SceneView;
                if (sceneView != null && sceneView.Document.DocumentRoot == sceneDocument.DocumentRoot)
                {
                    sceneViewModel = sceneView.ViewModel;
                    break;
                }
            }
            return(sceneViewModel);
        }
Пример #4
0
        public static DocumentNode GetParsedOrSniffedRootNode(IProjectItem projectItem, IProjectContext projectContext)
        {
            if (projectItem.Document != null)
            {
                SceneDocument sceneDocument = projectItem.Document as SceneDocument;
                if (sceneDocument != null && sceneDocument.DocumentRoot != null)
                {
                    return(sceneDocument.DocumentRoot.RootNode);
                }
            }
            DocumentContext documentContext = DocumentContextHelper.CreateDocumentContext((IProject)projectContext.GetService(typeof(IProject)), projectContext, DocumentReferenceLocator.GetDocumentLocator(projectItem.DocumentReference));
            IType           type            = DocumentContextHelper.SniffRootNodeType(projectItem, documentContext);

            if (type != null && type.RuntimeType != (Type)null)
            {
                return((DocumentNode)documentContext.CreateNode((ITypeId)type));
            }
            return((DocumentNode)null);
        }
Пример #5
0
        internal SceneDocument CreateDocument(IProject project, IProjectItem projectItem, ITextBuffer textBuffer, bool isReadOnly, Encoding encoding)
        {
            IProjectContext   projectContext    = (IProjectContext)ProjectXamlContext.GetProjectContext(project);
            DocumentReference documentReference = projectItem.DocumentReference;
            DocumentContext   documentContext   = DocumentContextHelper.CreateDocumentContext(project, projectContext, DocumentReferenceLocator.GetDocumentLocator(documentReference), projectItem.Properties["BuildAction"] == "Content");
            SceneXamlDocument xamlDocument      = new SceneXamlDocument((IDocumentContext)documentContext, (IUndoService) new UndoService(), PlatformTypes.Object, textBuffer, encoding);

            if (xamlDocument.ParseErrorsCount > 0)
            {
                IErrorService errorManager = this.designerContext.ErrorManager;
                if (errorManager != null)
                {
                    errorManager.DisplayErrors();
                }
            }
            SceneDocument sceneDocument = this.CreateSceneDocument(documentReference, xamlDocument, isReadOnly, this.designerContext);

            documentContext.DocumentLocator = (IDocumentLocator)sceneDocument;
            return(sceneDocument);
        }
Пример #6
0
        public override void RefreshAllInstances(DocumentReference documentReference, IDocument document)
        {
            SceneDocument sceneDocument = document as SceneDocument;

            if (sceneDocument == null)
            {
                return;
            }
            SceneViewModel sceneViewModel = this.GetSceneViewModel(sceneDocument);

            if (sceneViewModel == null)
            {
                return;
            }
            bool         flag        = false;
            SceneElement rootElement = sceneViewModel.RootNode as SceneElement;

            if (rootElement == null)
            {
                return;
            }
            using (SceneEditTransaction editTransaction = sceneDocument.CreateEditTransaction(StringTable.AssetFileUpdatedUndo, true))
            {
                foreach (SceneElement element in SceneElementHelper.GetLogicalTree(rootElement))
                {
                    if (this.DoesNodeReferenceUrl(element.DocumentNode, documentReference.Path))
                    {
                        this.RefreshInstance(element, sceneDocument, documentReference.Path);
                        flag = true;
                    }
                }
                if (flag)
                {
                    editTransaction.Commit();
                }
                else
                {
                    editTransaction.Cancel();
                }
            }
        }
Пример #7
0
 protected override void RefreshInstance(SceneElement element, SceneDocument sceneDocument, string url)
 {
 }
Пример #8
0
 protected abstract void RefreshInstance(SceneElement element, SceneDocument sceneDocument, string url);