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); }
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(); } } }
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); }
public SceneNode CreateAndSetBindingOrData(ref ReferenceStep targetProperty) { targetProperty = this.SelectedBindingField; if (this.useDesignDataContext && BaseFrameworkElement.DataContextProperty.Equals((object)targetProperty)) { targetProperty = (ReferenceStep)DesignTimeProperties.ResolveDesignTimePropertyKey(DesignTimeProperties.DesignDataContextProperty, (IPlatformMetadata)this.TargetElement.Platform.Metadata); } SceneNode setBindingOrData = this.ViewModel.BindingEditor.CreateAndSetBindingOrData(this.TargetElement, (IPropertyId)targetProperty, this.BindingPath); BindingSceneNode binding = setBindingOrData as BindingSceneNode; if (binding != null) { this.SetAdvancedPropertiesIfNeeded(binding); } return(setBindingOrData); }