public static string GetElementNameFromBoundProperty(SceneNodeProperty property) { if (property == null || property.SceneNodeObjectSet == null || property.SceneNodeObjectSet.ViewModel == null) { return((string)null); } bool isMixed; BindingSceneNode bindingSceneNode = property.SceneNodeObjectSet.ViewModel.GetSceneNode(property.GetLocalValueAsDocumentNode(true, out isMixed)) as BindingSceneNode; if (bindingSceneNode == null) { return((string)null); } if (!string.IsNullOrEmpty(bindingSceneNode.ElementName)) { if (!string.IsNullOrEmpty(bindingSceneNode.Path)) { return(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}.{1}", new object[2] { (object)bindingSceneNode.ElementName, (object)bindingSceneNode.Path })); } return(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}", new object[1] { (object)bindingSceneNode.ElementName })); } return(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}", new object[1] { (object)bindingSceneNode.Path })); }
private static bool IsAnySourcelessBindings(SceneNode sceneNode) { if (sceneNode == null) { return(false); } DocumentCompositeNode documentCompositeNode = sceneNode.DocumentNode as DocumentCompositeNode; if (documentCompositeNode == null) { return(false); } IProperty dataContextProperty = DataContextHelper.GetDataContextProperty(documentCompositeNode.Type); foreach (IProperty property in (IEnumerable <IProperty>)documentCompositeNode.Properties.Keys) { if (property.MemberType != MemberType.DesignTimeProperty && property != dataContextProperty) { BindingSceneNode binding = sceneNode.GetBinding((IPropertyId)property); if (binding != null && !DataContextHelper.GetDataSourceInfoFromBinding((DocumentCompositeNode)binding.DocumentNode).HasSource) { return(true); } } } return(false); }
public override void Execute() { BaseFrameworkElement selectedElement = this.SelectedElement; SceneViewModel sceneViewModel1 = this.SceneViewModel; bool flag1 = true; BaseFrameworkElement frameworkElement = selectedElement; int num1 = flag1 ? true : false; ILayoutDesigner designerForChild = sceneViewModel1.GetLayoutDesignerForChild((SceneElement)frameworkElement, num1 != 0); SceneNode parent = selectedElement.Parent; IProperty propertyForChild = parent.GetPropertyForChild((SceneNode)selectedElement); ISceneNodeCollection <SceneNode> collectionForProperty = parent.GetCollectionForProperty((IPropertyId)propertyForChild); int index = collectionForProperty.IndexOf((SceneNode)selectedElement); if (!BehaviorHelper.EnsureBlendSDKLibraryAssemblyReferenced(this.SceneViewModel, "Microsoft.Expression.Controls") || !ProjectContext.GetProjectContext(selectedElement.ProjectContext).IsTypeSupported(ProjectNeutralTypes.PathListBox)) { return; } using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove()) { SceneViewModel sceneViewModel2 = this.SceneViewModel; bool flag2 = false; string unitMakeLayoutPath = StringTable.UndoUnitMakeLayoutPath; int num2 = flag2 ? true : false; using (SceneEditTransaction editTransaction = sceneViewModel2.CreateEditTransaction(unitMakeLayoutPath, num2 != 0)) { using (this.SceneViewModel.ForceBaseValue()) { using (this.SceneViewModel.DisableDrawIntoState()) { this.SceneViewModel.ElementSelectionSet.Clear(); Rect childRect = designerForChild.GetChildRect(selectedElement); selectedElement.EnsureNamed(); PathListBoxElement pathListBoxElement = (PathListBoxElement)this.SceneViewModel.CreateSceneNode(ProjectNeutralTypes.PathListBox); LayoutPathNode layoutPathNode = (LayoutPathNode)this.SceneViewModel.CreateSceneNode(ProjectNeutralTypes.LayoutPath); BindingSceneNode bindingSceneNode = (BindingSceneNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Binding); bindingSceneNode.ElementName = selectedElement.Name; layoutPathNode.SetValue(LayoutPathNode.SourceElementProperty, (object)bindingSceneNode.DocumentNode); pathListBoxElement.LayoutPaths.Add((SceneNode)layoutPathNode); if (!collectionForProperty.FixedCapacity.HasValue || collectionForProperty.Count < collectionForProperty.FixedCapacity.Value) { collectionForProperty.Insert(index, (SceneNode)pathListBoxElement); } else { GridElement gridElement = (GridElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Grid); collectionForProperty[index] = (SceneNode)gridElement; gridElement.Children.Add((SceneNode)pathListBoxElement); gridElement.Children.Add((SceneNode)selectedElement); } editTransaction.Update(); designerForChild.SetChildRect((BaseFrameworkElement)pathListBoxElement, childRect); this.SceneViewModel.ElementSelectionSet.SetSelection((SceneElement)pathListBoxElement); editTransaction.Commit(); } } } } }
protected void SetAdvancedPropertiesIfNeeded(BindingSceneNode binding) { if (!this.setAdvancedProperties) { return; } using (this.ViewModel.AnimationEditor.DeferKeyFraming()) this.SetCommonBindingValues(binding); }
protected override DocumentNode CreateValue(BaseFrameworkElement source) { source.EnsureNamed(); DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)base.CreateValue(source); BindingSceneNode bindingSceneNode = BindingSceneNode.Factory.Instantiate(source.ViewModel); bindingSceneNode.ElementName = source.Name; documentCompositeNode.Properties[BrushNode.VisualBrushVisualProperty] = bindingSceneNode.DocumentNode; return((DocumentNode)documentCompositeNode); }
private DocumentCompositeNode GenerateHierarchicalDataTemplateIfNeeded(SceneNode targetNode) { DocumentCompositeNode documentCompositeNode = this.GenerateDataTemplateIfNeeded(targetNode, ProjectNeutralTypes.HierarchicalDataTemplate); if (documentCompositeNode == null) { return((DocumentCompositeNode)null); } IType type = this.DragModel.RelativeDropSchemaPath.Type; IType typeId = type != null ? type.ItemType : (IType)null; if (typeId == null) { return(documentCompositeNode); } string path; if (PlatformTypes.IEnumerable.IsAssignableFrom((ITypeId)typeId) && !PlatformTypes.String.IsAssignableFrom((ITypeId)typeId)) { path = string.Empty; } else { IProperty property1 = (IProperty)null; MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess((ITypeResolver)this.ProjectContext, typeId); List <IProperty> list = new List <IProperty>(typeId.GetProperties(allowableMemberAccess)); list.Sort((Comparison <IProperty>)((a, b) => StringLogicalComparer.Instance.Compare(a.Name, b.Name))); foreach (IProperty property2 in list) { IType propertyType = property2.PropertyType; if (propertyType == type) { property1 = property2; break; } if (property1 == null && PlatformTypes.IEnumerable.IsAssignableFrom((ITypeId)propertyType) && !PlatformTypes.String.IsAssignableFrom((ITypeId)propertyType)) { property1 = property2; } } if (property1 == null) { return(documentCompositeNode); } path = property1.Name; } BindingSceneNode bindingSceneNode = (BindingSceneNode)this.DragModel.ViewModel.CreateSceneNode(PlatformTypes.Binding); if (!string.IsNullOrEmpty(path)) { bindingSceneNode.SetPath(path); } documentCompositeNode.Properties[DataBindingDragDropDefaultHandler.HierarchicalItemsSourceProperty] = bindingSceneNode.DocumentNode; return(documentCompositeNode); }
protected void SetCommonBindingValues(BindingSceneNode binding) { IDocumentContext documentContext = binding.DocumentContext; bool flag = !string.IsNullOrEmpty(binding.Path) || binding.SupportsXPath && !string.IsNullOrEmpty(binding.XPath); BindingMode bindingMode = this.CurrentBindingMode; if (!flag && (bindingMode == BindingMode.Default || bindingMode == BindingMode.OneWayToSource || bindingMode == BindingMode.TwoWay)) { bindingMode = BindingMode.OneWay; } if (bindingMode == BindingMode.TwoWay && binding.SupportsUpdateSourceTrigger) { if (binding.GetDefaultValue(BindingSceneNode.UpdateSourceTriggerProperty) == this.CurrentUpdateSourceTrigger) { binding.ClearLocalValue(BindingSceneNode.UpdateSourceTriggerProperty); } else { binding.UpdateSourceTrigger = this.CurrentUpdateSourceTrigger; } } BindingModeInfo defaultBindingMode = BindingPropertyHelper.GetDefaultBindingMode(this.TargetElement.DocumentNode, (IPropertyId)this.TargetProperty, this.CurrentDataPath); if (defaultBindingMode.IsOptional && defaultBindingMode.Mode == bindingMode) { binding.ClearLocalValue(BindingSceneNode.ModeProperty); } else { binding.Mode = bindingMode; } if (!string.IsNullOrEmpty(this.BindingFallbackValue)) { binding.FallbackValue = (DocumentNode)documentContext.CreateNode(this.BindingFallbackValue); } SceneNode sceneNode = (SceneNode)null; if (this.CurrentValueConverter != null) { sceneNode = this.CurrentValueConverter.GenerateConverter(); } else if (this.originalValueConverter != null) { sceneNode = this.ViewModel.GetSceneNode(this.originalValueConverter.Clone(binding.DocumentContext)); } if (sceneNode != null) { binding.SetValueAsSceneNode(BindingSceneNode.ConverterProperty, sceneNode); } if (string.IsNullOrEmpty(this.valueConverterParameter)) { return; } binding.ConverterParameter = (object)this.valueConverterParameter; }
public BindingSceneNode CreateElementNameBinding(SceneNode targetNode) { BindingSceneNode binding = (BindingSceneNode)this.ViewModel.CreateSceneNode(PlatformTypes.Binding); ReferenceStep selectedBindingField = this.SelectedBindingField; targetNode.EnsureNamed(); binding.ElementName = targetNode.Name; binding.SetPath(selectedBindingField.Name); this.SetAdvancedPropertiesIfNeeded(binding); return(binding); }
public static void FixElementNameBindingsInStoredProperties(SceneNode source, SceneNode target, Dictionary <IPropertyId, SceneNode> properties) { foreach (KeyValuePair <IPropertyId, SceneNode> keyValuePair in properties) { BindingSceneNode bindingSceneNode = keyValuePair.Value as BindingSceneNode; if (bindingSceneNode != null && bindingSceneNode.SupportsElementName && bindingSceneNode.ElementName == source.Name) { target.EnsureNamed(); bindingSceneNode.ElementName = target.Name; } } }
protected void InitializeCurrentValueConverter() { if (this.TargetProperty == null) { return; } BindingSceneNode binding = this.TargetElement.GetBinding((IPropertyId)this.TargetProperty); if (binding == null) { return; } string str = binding.ConverterParameter as string; if (str != null) { this.ValueConverterParameter = str; } DocumentCompositeNode node = binding.Converter as DocumentCompositeNode; if (node == null) { return; } ValueConverterModel valueConverterModel = (ValueConverterModel)null; if (node.Type.IsResource) { string key = DocumentPrimitiveNode.GetValueAsString(ResourceNodeHelper.GetResourceKey(node)); if (string.IsNullOrEmpty(key)) { return; } valueConverterModel = Enumerable.FirstOrDefault <ValueConverterModel>((IEnumerable <ValueConverterModel>) this.ValueConverters, (Func <ValueConverterModel, bool>)(vc => vc.DisplayName == key)); } else { SceneNode sceneNode = this.ViewModel.GetSceneNode((DocumentNode)node); if (sceneNode != null) { valueConverterModel = ValueConverterModelFactory.CreateValueConverterModel(sceneNode); if (valueConverterModel != null) { this.ValueConverters.Add(valueConverterModel); } } } if (valueConverterModel == null) { return; } this.CurrentValueConverter = valueConverterModel; }
private void SetExistingBindingValues(BindingSceneNode existingBinding) { string path = existingBinding.PathOrXPath; DocumentNode node1 = (DocumentNode)null; DocumentCompositeNode node2 = existingBinding.SupportsSource ? existingBinding.Source as DocumentCompositeNode : (DocumentCompositeNode)null; if (node2 != null && node2.Type.IsResource) { node1 = ResourceNodeHelper.GetResourceKey(node2); } if (node1 != null) { this.InitializeDataSource(DocumentPrimitiveNode.GetValueAsString(node1), path); } else if (existingBinding.SupportsElementName && existingBinding.ElementName != null && this.elementPropertyModel != null) { this.InitializeElementName(existingBinding.ElementName, path); } else { this.InitializeExplicitDataContext(path); } if (this.bindingSourcesProxy.Value.Path != path) { if (this.CurrentBindingSource.Schema is EmptySchema && existingBinding.SupportsXPath && !string.IsNullOrEmpty(existingBinding.XPath)) { path = "XPath=" + path; } this.CustomBindingExpression = path; this.UseCustomBindingExpression = true; } DocumentNode node3 = existingBinding.SupportsFallbackValue ? existingBinding.FallbackValue : (DocumentNode)null; if (node3 != null) { string valueAsString = DocumentPrimitiveNode.GetValueAsString(node3); if (valueAsString != null) { this.BindingFallbackValue = valueAsString; } } if (existingBinding.IsModeSet) { this.CurrentBindingMode = existingBinding.Mode; } if (!existingBinding.SupportsUpdateSourceTrigger) { return; } this.CurrentUpdateSourceTrigger = existingBinding.UpdateSourceTrigger; }
public override void ApplyChange(SceneViewModel viewModel) { if (this.Change.BreakingChange) { return; } BindingSceneNode bindingSceneNode = viewModel.GetSceneNode((DocumentNode)this.DocumentNode) as BindingSceneNode; if (bindingSceneNode == null) { return; } bindingSceneNode.SetPath(this.Change.NewPath); }
protected void LinkDetailsWithMasterControl(SceneElement detailsContainerElement) { BaseFrameworkElement masterControl = this.FindMasterControl(detailsContainerElement); if (masterControl == null) { return; } masterControl.EnsureNamed(); BindingSceneNode binding = (BindingSceneNode)this.DragModel.ViewModel.CreateSceneNode(PlatformTypes.Binding); binding.ElementName = masterControl.Name; binding.SetPath("SelectedItem"); detailsContainerElement.SetBinding(BaseFrameworkElement.DataContextProperty, binding); }
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); }
private bool UpdateInvokeCommandAction(SceneNode actionNode) { if (!ProjectNeutralTypes.InvokeCommandAction.IsAssignableFrom((ITypeId)actionNode.Type)) { return(false); } DataSchemaNodePath primaryAbsolutePath = this.DragModel.DataSource.PrimaryAbsolutePath; BindingSceneNode bindingSceneNode = this.DragModel.ViewModel.BindingEditor.CreateAndSetBindingOrData(actionNode, DataBindingDragDropAddTriggerHandler.CommandProperty, primaryAbsolutePath) as BindingSceneNode; if (bindingSceneNode == null) { return(false); } bindingSceneNode.ClearLocalValue(BindingSceneNode.ModeProperty); return(true); }
private BindingSceneNode CreateFallbackBind(SceneViewModel viewModel, string bindingPath, SceneNode targetNode, IProperty targetProperty) { BindingSceneNode binding = BindingSceneNode.Factory.Instantiate(viewModel); if (this.ResourceKey != null) { DocumentNode keyNode = this.ResourceKey.Clone(viewModel.Document.DocumentContext); binding.Source = (DocumentNode)DocumentNodeUtilities.NewStaticResourceNode(viewModel.Document.DocumentContext, keyNode); } if (bindingPath.Length > 0) { binding.XPath = bindingPath; } using (targetNode.ViewModel.AnimationEditor.DeferKeyFraming()) targetNode.SetBinding((IPropertyId)targetProperty, binding); return(binding); }
public BindingDialogModelBase(SceneNode targetElement, ReferenceStep targetProperty) { this.TargetElement = targetElement; this.TargetProperty = targetProperty; IType type1 = this.ViewModel.ProjectContext.ResolveType(PlatformTypes.BindingMode); this.supportedBindingModeNames = Enum.GetNames(type1.RuntimeType); this.bindingModeProxy = new BindingProxy <BindingMode>(); this.bindingModesCollection = new ObservableCollection <BindingMode>(); foreach (BindingMode bindingMode in this.bindingModes) { if (this.IsBindingModeSupported(bindingMode)) { this.bindingModesCollection.Add(bindingMode); } } this.bindingModesView = (CollectionView) new DataBindingProxyCollectionView <BindingMode>(this.bindingModesCollection, (IDataBindingProxy <BindingMode>) this.bindingModeProxy); this.bindingModesView.MoveCurrentToFirst(); this.bindingModeProxy.Value = BindingPropertyHelper.GetDefaultBindingMode(this.TargetElement.DocumentNode, (IPropertyId)this.TargetProperty, (DataSchemaNodePath)null).Mode; if (this.TargetProperty != null) { BindingSceneNode binding = this.TargetElement.GetBinding((IPropertyId)this.TargetProperty); if (binding != null) { this.originalValueConverter = binding.Converter; } } this.updateSourceTriggerProxy = new BindingProxy <object>(); ObservableCollection <object> collection = new ObservableCollection <object>(); IType type2 = this.ViewModel.ProjectContext.ResolveType(PlatformTypes.UpdateSourceTrigger); if (!this.ViewModel.ProjectContext.PlatformMetadata.IsNullType((ITypeId)type2)) { IProperty property = this.ViewModel.ProjectContext.ResolveProperty(BindingSceneNode.UpdateSourceTriggerProperty); if (property != null) { this.updateSourceTriggerProxy.Value = property.GetDefaultValue(type1.RuntimeType); } foreach (object obj in (IEnumerable)MetadataStore.GetTypeConverter(type2.RuntimeType).GetStandardValues()) { collection.Add(obj); } } this.updateSourceTriggersView = (CollectionView) new DataBindingProxyCollectionView <object>(collection, (IDataBindingProxy <object>) this.updateSourceTriggerProxy); }
public void SelectElement(SceneElement element, SceneNodeProperty editingProperty) { ISchema schemaForDataSource = SchemaManager.GetSchemaForDataSource((SceneNode)element); using (SceneEditTransaction editTransaction = element.ViewModel.CreateEditTransaction(StringTable.CreateElementPropertyBindingUndo)) { BindingSceneNode elementNameBinding = MiniBindingDialog.CreateElementNameBinding(new DataSchemaNodePath(schemaForDataSource, schemaForDataSource.Root), (SceneNode)element, editingProperty.PropertyTypeId); if (elementNameBinding != null) { editingProperty.SetValue((object)elementNameBinding.DocumentNode); editTransaction.Commit(); } else { editTransaction.Cancel(); } } }
private SceneNode CreateDataGridBoundColumn(DataSchemaNodePath schemaPath, ITypeId columnType) { DataGridColumnNode dataGridColumnNode = (DataGridColumnNode)this.DragModel.ViewModel.CreateSceneNode(columnType); string columnName = DataBindingDragDropDefaultHandler.GetColumnName(schemaPath); dataGridColumnNode.SetLocalValue(DataGridColumnNode.ColumnHeaderProperty, (object)columnName); BindingSceneNode bindingSceneNode = (BindingSceneNode)this.DragModel.ViewModel.CreateSceneNode(PlatformTypes.Binding); bindingSceneNode.SetPath(schemaPath.Path); BindingModeInfo defaultBindingMode = BindingPropertyHelper.GetDefaultBindingMode(dataGridColumnNode.DocumentNode, DataGridColumnNode.BoundColumnBindingProperty, schemaPath); if (!defaultBindingMode.IsOptional) { bindingSceneNode.Mode = defaultBindingMode.Mode; } dataGridColumnNode.SetValueAsSceneNode(DataGridColumnNode.BoundColumnBindingProperty, (SceneNode)bindingSceneNode); return((SceneNode)dataGridColumnNode); }
private bool UpdateCallMethodAction(SceneNode actionNode) { if (!ProjectNeutralTypes.CallMethodAction.IsAssignableFrom((ITypeId)actionNode.Type)) { return(false); } DataSchemaNodePath primaryAbsolutePath = this.DragModel.DataSource.PrimaryAbsolutePath; DataSchemaNode node = primaryAbsolutePath.Node; DataSchemaNodePath bindingPath = new DataSchemaNodePath(primaryAbsolutePath.Schema, node.Parent); BindingSceneNode bindingSceneNode = this.DragModel.ViewModel.BindingEditor.CreateAndSetBindingOrData(actionNode, DataBindingDragDropAddTriggerHandler.TargetObjectProperty, bindingPath) as BindingSceneNode; if (bindingSceneNode == null) { return(false); } bindingSceneNode.ClearLocalValue(BindingSceneNode.ModeProperty); actionNode.SetValue(DataBindingDragDropAddTriggerHandler.MethodNameProperty, (object)node.PathName); return(true); }
private SceneNode CreateBindingOrDataInternal(bool bindingNeededForVerification) { SceneNode sceneNode = (SceneNode)null; BindingSceneNode bindingSceneNode1 = (BindingSceneNode)null; if (this.CurrentBindingSource != null) { if (bindingNeededForVerification) { sceneNode = this.CurrentBindingSource.CreateBindingOrData(this.TargetElement.ViewModel, this.TargetElement, (IProperty)this.TargetProperty); } else if (this.useCustomBindingExpression) { sceneNode = this.CurrentBindingSource.CreateBindingOrData(this.TargetElement.ViewModel, this.customBindingExpression, this.TargetElement, (IProperty)this.TargetProperty); BindingSceneNode bindingSceneNode2 = sceneNode as BindingSceneNode; if (bindingSceneNode2 != null) { if (this.customBindingExpression.StartsWith("Path=", StringComparison.Ordinal)) { bindingSceneNode2.ClearValue(BindingSceneNode.XPathProperty); bindingSceneNode1 = bindingSceneNode2.SetPath(this.customBindingExpression.Substring("Path=".Length)); } else if (this.customBindingExpression.StartsWith("XPath=", StringComparison.Ordinal) && bindingSceneNode2.SupportsXPath) { bindingSceneNode2.XPath = this.customBindingExpression.Substring("XPath=".Length); bindingSceneNode2.ClearValue(BindingSceneNode.PathProperty); } } } else { sceneNode = this.CurrentBindingSource.CreateBindingOrData(this.TargetElement.ViewModel, this.TargetElement, (IProperty)this.TargetProperty); } BindingSceneNode binding = sceneNode as BindingSceneNode; if (binding != null) { this.SetCommonBindingValues(binding); } } return(sceneNode); }
public SceneNode CreateBindingOrData(SceneViewModel viewModel, string bindingPath, SceneNode targetNode, IProperty targetProperty) { BindingSceneNode bindingSceneNode = BindingSceneNode.Factory.Instantiate(viewModel); if (bindingPath.Length > 0) { if (this.Schema is ClrObjectSchema) { bindingSceneNode = bindingSceneNode.SetPath(bindingPath); } else if (this.Schema is XmlSchema) { bindingSceneNode.XPath = bindingPath; } else { bindingSceneNode = bindingSceneNode.SetPath(bindingPath); } } return((SceneNode)bindingSceneNode); }
public DataStorePropertyEntry FindMatchDataStorePropertyEntry(SceneNodeProperty property, string propertyName) { if (property == null) { return((DataStorePropertyEntry)null); } bool isMixed = false; DocumentNode valueAsDocumentNode = property.GetLocalValueAsDocumentNode(false, out isMixed); if (valueAsDocumentNode != null && property.SceneNodeObjectSet.ViewModel.IsExternal(valueAsDocumentNode)) { return((DataStorePropertyEntry)null); } BindingSceneNode bindingSceneNode = property.SceneNodeObjectSet.ViewModel.GetSceneNode(valueAsDocumentNode) as BindingSceneNode; if (bindingSceneNode == null) { return((DataStorePropertyEntry)null); } string path = propertyName ?? bindingSceneNode.Path; string dataStore = (string)null; DocumentCompositeNode node = bindingSceneNode.Source as DocumentCompositeNode; if (node != null && PlatformTypes.StaticResource.IsAssignableFrom((ITypeId)node.Type)) { DocumentPrimitiveNode documentPrimitiveNode = ResourceNodeHelper.GetResourceKey(node) as DocumentPrimitiveNode; if (documentPrimitiveNode != null) { dataStore = documentPrimitiveNode.GetValue <string>(); } } return(Enumerable.FirstOrDefault <DataStorePropertyEntry>(Enumerable.Where <DataStorePropertyEntry>((IEnumerable <DataStorePropertyEntry>) this.Properties, (Func <DataStorePropertyEntry, bool>)(entry => { if (entry.Name == path) { return entry.DataSetName == dataStore; } return false; })))); }
private BindingSceneNode CreateBinding(SceneViewModel viewModel, string bindingPath) { BindingSceneNode bindingSceneNode = (BindingSceneNode)null; if (this.SelectedNode != null) { bindingSceneNode = BindingSceneNode.Factory.Instantiate(viewModel); if (!string.IsNullOrEmpty(this.Source)) { bindingSceneNode.ElementName = this.Source; } else { bindingSceneNode.ElementBindingTarget = (SceneNode)this.SelectedNode.Element; } if (bindingPath.Length > 0) { bindingSceneNode = bindingSceneNode.SetPath(bindingPath); } } return(bindingSceneNode); }
private static void SetBindingOrData(SceneNode targetNode, IPropertyId targetProperty, SceneNode bindingOrData, DataSchemaNodePath bindingPath) { BindingSceneNode binding = bindingOrData as BindingSceneNode; using (targetNode.ViewModel.AnimationEditor.DeferKeyFraming()) { if (binding != null) { IPropertyId propertyKey = targetProperty; if (binding.Source != null) { propertyKey = BindingEditor.RefineDataContextProperty(targetNode, targetProperty, bindingPath.Schema.DataSource.DocumentNode); } targetNode.SetBinding(propertyKey, binding); } else { IPropertyId propertyKey = BindingEditor.RefineDataContextProperty(targetNode, targetProperty, bindingOrData.DocumentNode); targetNode.SetValueAsSceneNode(propertyKey, bindingOrData); } } }
public override void SelectElement(SceneElement element, SceneNodeProperty editingProperty) { if (element == null || editingProperty == null || (editingProperty.SceneNodeObjectSet == null || editingProperty.IsMixedValue)) { return; } SceneNodeObjectSet sceneNodeObjectSet = editingProperty.SceneNodeObjectSet; BindingSceneNode bindingSceneNode = sceneNodeObjectSet.ViewModel.CreateSceneNode(PlatformTypes.Binding) as BindingSceneNode; LayoutPathNode layoutPathNode = sceneNodeObjectSet.ViewModel.CreateSceneNode(ProjectNeutralTypes.LayoutPath) as LayoutPathNode; using (SceneEditTransaction editTransaction = sceneNodeObjectSet.ViewModel.CreateEditTransaction(StringTable.AddLayoutPathUndo)) { using (sceneNodeObjectSet.ViewModel.ForceBaseValue()) { element.EnsureNamed(); editTransaction.Update(); bindingSceneNode.ElementName = element.Name; layoutPathNode.SetValue(LayoutPathNode.SourceElementProperty, (object)bindingSceneNode.DocumentNode); editingProperty.AddValue((object)layoutPathNode.DocumentNode); editTransaction.Commit(); } } }
private SceneNode CreateDataSource(SceneNode target, DataSchemaNodePath bindingPath, bool isSourcePathLess) { DocumentNode resourceKey = bindingPath.Schema.DataSource.ResourceKey; if (resourceKey == null) { if (!isSourcePathLess && !string.IsNullOrEmpty(bindingPath.Path)) { return((SceneNode)null); } DocumentNode documentNode = bindingPath.Schema.DataSource.DocumentNode; IProjectItem designDataFile = DesignDataHelper.GetDesignDataFile(documentNode); DocumentNode node; if (designDataFile != null) { node = DesignDataHelper.CreateDesignDataExtension(designDataFile, target.DocumentContext); } else { if (PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)bindingPath.Schema.DataSource.DocumentNode.Type)) { return((SceneNode)null); } node = documentNode.Clone(target.DocumentContext); } return(target.ViewModel.GetSceneNode(node)); } if (!this.EnsureDataSourceReachable(target, bindingPath.Schema.DataSource)) { return((SceneNode)null); } BindingSceneNode bindingSceneNode = BindingSceneNode.Factory.Instantiate(target.ViewModel); DocumentNode keyNode = resourceKey.Clone(target.DocumentContext); bindingSceneNode.Source = (DocumentNode)DocumentNodeUtilities.NewStaticResourceNode(keyNode.Context, keyNode); return((SceneNode)bindingSceneNode); }
public static SceneNode CreateAndSetBindingOrData(DesignerContext designerContext, SceneNode target, ReferenceStep targetProperty) { SceneNode sceneNode = (SceneNode)null; using (DataBindingDialog dataBindingDialog = new DataBindingDialog(target, targetProperty)) { bool?nullable = dataBindingDialog.ShowDialog(); if ((!nullable.GetValueOrDefault() ? 1 : (!nullable.HasValue ? true : false)) != 0) { return((SceneNode)null); } using (target.ViewModel.AnimationEditor.DeferKeyFraming()) { using (SceneEditTransaction editTransaction = target.ViewModel.CreateEditTransaction(StringTable.UndoUnitSetBinding)) { sceneNode = dataBindingDialog.model.CreateBindingOrData(); bool flag = sceneNode != null; BindingSceneNode binding = sceneNode as BindingSceneNode; if (binding != null) { flag = false; if (binding.ElementBindingTarget != null) { binding.ElementBindingTarget.EnsureNamed(); binding.ElementName = binding.ElementBindingTarget.Name; } string errorMessage; if (!binding.IsBindingLegal(target, targetProperty, out errorMessage)) { MessageBoxArgs args = new MessageBoxArgs() { Message = errorMessage, Button = MessageBoxButton.OK, Image = MessageBoxImage.Hand }; int num = (int)designerContext.MessageDisplayService.ShowMessage(args); } else { IPropertyId propertyKey = (IPropertyId)targetProperty; if (binding.Source != null) { ISchema schema = dataBindingDialog.model.CurrentBindingSource.Schema; if (schema != null && schema.DataSource != null && schema.DataSource.DocumentNode != null) { propertyKey = BindingEditor.RefineDataContextProperty(target, (IPropertyId)targetProperty, schema.DataSource.DocumentNode); } } target.SetBinding(propertyKey, binding); flag = true; } } if (flag) { editTransaction.Commit(); } else { editTransaction.Cancel(); } } } return(sceneNode); } }