public DataBindingDialogModel(DataPanelModel model, SceneNode targetElement, ReferenceStep targetProperty) : base(targetElement, targetProperty) { this.isBinding = true; this.addXmlDataSourceCommand = model.AddXmlDataSourceCommand; this.createSampleDataCommand = model.CreateSampleDataCommand; this.createSampleDataFromXmlCommand = model.CreateSampleDataFromXmlCommand; this.addClrObjectDataSourceCommand = model.AddClrObjectDataSourceCommand; DataContextInfo dataContextInfo = new DataContextEvaluator().Evaluate(targetElement, (IPropertyId)targetProperty, true); if (dataContextInfo.DataSource.IsValidWithSource) { ISchema schemaForDataSource = SchemaManager.GetSchemaForDataSource(dataContextInfo.DataSource.SourceNode); if (schemaForDataSource != null && !(schemaForDataSource is EmptySchema)) { this.dataContext = schemaForDataSource.GetNodePathFromPath(dataContextInfo.DataSource.Path); } } this.bindsTwoWayByDefault = this.BindsTwoWayByDefault(targetElement, targetProperty); this.bindingFilterModes = new ObservableCollection <BindingFilterMode>(); this.bindingFilterModes.Add(BindingFilterMode.None); this.bindingFilterModes.Add(BindingFilterMode.FilterByType); ICollectionView defaultView = CollectionViewSource.GetDefaultView((object)this.bindingFilterModes); defaultView.MoveCurrentTo((object)BindingFilterMode.FilterByType); this.bindingSources = new ObservableCollection <IBindingSourceModel>(); this.dataSourceModel = new DataSourceBindingSourceModel(model, new DataSchemaItemFilter(this.BindingFilter)); this.AddBindingSource((IBindingSourceModel)this.dataSourceModel); if (targetElement.ViewModel.ActiveEditingContainer is SceneElement) { this.elementPropertyModel = new ElementPropertyBindingSourceModel(targetElement, new DataSchemaItemFilter(this.BindingFilter)); this.AddBindingSource((IBindingSourceModel)this.elementPropertyModel); } this.explicitDataContextModel = new ExplicitDataContextBindingSourceModel(targetElement, targetProperty, new DataSchemaItemFilter(this.BindingFilter)); this.AddBindingSource((IBindingSourceModel)this.explicitDataContextModel); this.bindingSourcesProxy = new BindingProxy <IBindingSourceModel>(); this.bindingSourcesProxy.PropertyChanged += new PropertyChangedEventHandler(this.BindingSourcesProxy_PropertyChanged); this.bindingSourcesView = (CollectionView) new DataBindingProxyCollectionView <IBindingSourceModel>(this.bindingSources, (IDataBindingProxy <IBindingSourceModel>) this.bindingSourcesProxy); BindingSceneNode binding = targetElement.GetBinding((IPropertyId)targetProperty); if (binding != null) { this.SetExistingBindingValues(binding); } else if (!(this.explicitDataContextModel.Schema is EmptySchema)) { this.bindingSourcesView.MoveCurrentTo((object)this.explicitDataContextModel); } else { this.bindingSourcesView.MoveCurrentTo((object)this.dataSourceModel); } if (binding == null || !binding.IsModeSet) { this.CurrentBindingMode = BindingPropertyHelper.GetDefaultBindingMode(this.TargetElement.DocumentNode, (IPropertyId)this.TargetProperty, this.CurrentDataPath).Mode; } this.bindingSourcesView.CurrentChanging += new CurrentChangingEventHandler(this.BindingSourcesView_CurrentChanging); defaultView.CurrentChanged += new EventHandler(this.BindingFilterModesView_CurrentChanged); this.PropertyChanged += new PropertyChangedEventHandler(this.DataBindingDialogModel_PropertyChanged); }
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); }