コード例 #1
0
        private void ProcessPotentialDataContextOwner(DocumentNode documentNode, bool needDesignTimeProperty)
        {
            IProperty dataContextProperty = DataContextHelper.GetDataContextProperty(documentNode.Type, needDesignTimeProperty);

            if (dataContextProperty == null)
            {
                return;
            }
            DocumentCompositeNode documentCompositeNode1 = documentNode as DocumentCompositeNode;

            if (documentCompositeNode1 == null)
            {
                return;
            }
            DocumentCompositeNode documentCompositeNode2 = documentCompositeNode1.Properties[(IPropertyId)dataContextProperty] as DocumentCompositeNode;

            if (documentCompositeNode2 == null)
            {
                return;
            }
            RawDataSourceInfoBase rawDataSourceInfo = DataContextHelper.GetRawDataSourceInfo((DocumentNode)documentCompositeNode2);

            if (!rawDataSourceInfo.HasSource || !rawDataSourceInfo.IsValidClr || !this.SampleData.IsTypeOwner(rawDataSourceInfo.SourceType))
            {
                return;
            }
            this.documentNodesToModify.Add(documentCompositeNode1);
        }
コード例 #2
0
        public RawDataSourceInfoBase GetRawDataContextInfo(DocumentCompositeNode documentNode)
        {
            if (documentNode == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            IProperty    ptoperty       = DesignTimeProperties.ResolveDesignTimePropertyKey(DesignTimeProperties.DesignDataContextProperty, documentNode.PlatformMetadata);
            DocumentNode dataSourceNode = documentNode.Properties[(IPropertyId)ptoperty];

            if (dataSourceNode == null)
            {
                ptoperty = DataContextHelper.GetDataContextProperty(documentNode.Type);
                if (ptoperty != null)
                {
                    dataSourceNode = documentNode.Properties[(IPropertyId)ptoperty];
                }
            }
            if (dataSourceNode == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            RawDataSourceInfoBase rawDataSourceInfo = DataContextHelper.GetRawDataSourceInfo(dataSourceNode);

            if (rawDataSourceInfo != null && rawDataSourceInfo.IsValid)
            {
                this.OnDataSourceFound(documentNode, ptoperty);
            }
            return(rawDataSourceInfo);
        }
コード例 #3
0
        private void ApplyChanges(SceneDocument sceneDocument)
        {
            List <DocumentCompositeNode> list = new List <DocumentCompositeNode>();

            for (int index = this.documentNodesToModify.Count - 1; index >= 0; --index)
            {
                DocumentCompositeNode documentCompositeNode = this.documentNodesToModify[index];
                if (documentCompositeNode.DocumentRoot == this.CurrentDocument.DocumentRoot)
                {
                    list.Add(documentCompositeNode);
                    this.documentNodesToModify.RemoveAt(index);
                }
            }
            if (this.IsKilled || list.Count == 0)
            {
                return;
            }
            SceneView sceneView   = this.GetSceneView(sceneDocument);
            string    description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, this.SampleData.IsEnabledAtRuntime ? StringTable.SampleDataEnableTransaction : StringTable.SampleDataDisableTransaction, new object[1]
            {
                (object)this.SampleData.Name
            });

            using (SceneEditTransaction editTransaction = sceneDocument.CreateEditTransaction(description))
            {
                using (sceneView.ViewModel.AnimationEditor.DeferKeyFraming())
                {
                    foreach (DocumentCompositeNode documentCompositeNode in list)
                    {
                        IProperty    dataContextProperty = DataContextHelper.GetDataContextProperty(documentCompositeNode.Type);
                        IProperty    property            = DesignTimeProperties.ResolveDesignTimePropertyKey(DesignTimeProperties.DesignDataContextProperty, documentCompositeNode.PlatformMetadata);
                        DocumentNode documentNode1       = documentCompositeNode.Properties[(IPropertyId)dataContextProperty];
                        DocumentNode documentNode2       = documentCompositeNode.Properties[(IPropertyId)property];
                        SceneNode    sceneNode           = sceneView.ViewModel.GetSceneNode((DocumentNode)documentCompositeNode);
                        if (documentNode2 == null)
                        {
                            sceneNode.ClearValue((IPropertyId)dataContextProperty);
                        }
                        else
                        {
                            sceneNode.SetValue((IPropertyId)dataContextProperty, (object)documentNode2);
                        }
                        if (documentNode1 == null)
                        {
                            sceneNode.ClearValue((IPropertyId)property);
                        }
                        else
                        {
                            sceneNode.SetValue((IPropertyId)property, (object)documentNode1);
                        }
                    }
                    editTransaction.Commit();
                }
            }
        }
コード例 #4
0
        public MiniTargetBindingDialogModel(DataSchemaNodePath bindingPath, SceneNode targetElement, ReferenceStep targetProperty, bool useDesignDataContext)
            : base(bindingPath, targetElement, targetProperty)
        {
            this.useDesignDataContext     = useDesignDataContext;
            this.targetBindableProperties = BindingPropertyHelper.GetBindableTargetProperties(this.TargetElement);
            IProperty dataContextProperty = DataContextHelper.GetDataContextProperty(this.TargetElement.Type);

            if (dataContextProperty != null && !this.TargetElement.ViewModel.BindingEditor.CanCreateAndSetBindingOrData(targetElement, (IPropertyId)dataContextProperty, bindingPath, true))
            {
                this.targetBindableProperties.Remove((ReferenceStep)dataContextProperty);
            }
            this.Initialize();
        }
コード例 #5
0
        public static IProperty GetDataContextProperty(IType type, bool needDesignDataContextProperty)
        {
            IProperty property = DataContextHelper.GetDataContextProperty(type);

            if (property == null)
            {
                return((IProperty)null);
            }
            if (needDesignDataContextProperty)
            {
                property = DesignTimeProperties.ResolveDesignTimePropertyKey(DesignTimeProperties.DesignDataContextProperty, type.PlatformMetadata);
            }
            return(property);
        }
コード例 #6
0
        private RawDataSourceInfoBase GetDataSourceFromProperty(DataBindingProcessingContext context, IProperty property)
        {
            if (DataContextHelper.GetDataContextProperty(context.DocumentNode.Type) == property)
            {
                return(context.DataContext);
            }
            DocumentNode dataSourceNode = context.DocumentCompositeNode.Properties[(IPropertyId)property];

            if (dataSourceNode == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            RawDataSourceInfoBase rawDataSourceInfo = DataContextHelper.GetRawDataSourceInfo(dataSourceNode);

            return(this.CombineDataSources(context.DataContext, rawDataSourceInfo));
        }
コード例 #7
0
 public static bool IsDataContextProperty(DocumentNode documentNode, IPropertyId property)
 {
     if (property != null && documentNode != null)
     {
         if (property.MemberType == MemberType.DesignTimeProperty)
         {
             return(DesignTimeProperties.DesignDataContextProperty.Equals((object)property));
         }
         IProperty dataContextProperty = DataContextHelper.GetDataContextProperty(documentNode.Type);
         if (dataContextProperty != null && dataContextProperty.Equals((object)property))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #8
0
 public static bool HasDataContextProperty(IType type)
 {
     return(DataContextHelper.GetDataContextProperty(type) != null);
 }