예제 #1
0
        public override void SetValueToSystemResource(SceneNodeProperty propertyKey, SystemResourceModel systemResource)
        {
            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.ApplyResource, "Apply system resource.");
            SceneViewModel viewModel = this.ViewModel;

            if (viewModel != null)
            {
                IDocumentContext documentContext = viewModel.Document.DocumentContext;
                IType            type            = viewModel.ProjectContext.ProjectNamespaces.GetType((IXmlNamespace)XmlNamespace.AvalonXmlNamespace, systemResource.CollectionName);
                if (type != null)
                {
                    IMember      memberId     = (IMember)type.GetMember(MemberType.LocalProperty | MemberType.Field, systemResource.ResourceName, MemberAccessTypes.Public);
                    DocumentNode documentNode = (DocumentNode)null;
                    if (memberId != null)
                    {
                        documentNode = (DocumentNode)DocumentNodeUtilities.NewDynamicResourceNode(documentContext, (DocumentNode)DocumentNodeUtilities.NewStaticNode(documentContext, memberId));
                    }
                    using (this.ShouldAllowAnimation ? (IDisposable)null : viewModel.AnimationEditor.DeferKeyFraming())
                        this.SetValue((PropertyReferenceProperty)propertyKey, (object)documentNode);
                }
            }
            PerformanceUtility.EndPerformanceSequence(PerformanceEvent.ApplyResource, "Apply resource.");
        }