public ModelChangedEventArgsImpl(List <ModelItem> itemsAdded, List <ModelItem> itemsRemoved, List <ModelProperty> propertiesChanged, ModelChangeInfo modelChangeInfo) { this.itemsAdded = itemsAdded; this.itemsRemoved = itemsRemoved; this.propertiesChanged = propertiesChanged; this.modelChangeInfo = modelChangeInfo; }
public override bool Apply() { ModelItem oldValue = this.Dictionary[this.Key]; if ((oldValue == null && this.NewValue == null) || (oldValue != null && this.NewValue != null && oldValue.GetCurrentValue().Equals(this.NewValue.GetCurrentValue()))) { return(false); } ((ModelItemDictionaryImpl)this.Dictionary).EditCore(this.Key, this.NewValue); ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreateDictionaryValueChanged(this.Dictionary, this.Key, this.OldValue, this.NewValue); if (this.OldValue != null) { this.ModelTreeManager.modelService.OnModelItemRemoved(this.OldValue, changeInfo); changeInfo = null; } if (this.NewValue != null) { this.ModelTreeManager.modelService.OnModelItemAdded(this.NewValue, changeInfo); } return(true); }
internal void EmitModelChangeInfo(ModelChangeInfo changInfo) { Fx.Assert(changInfo != null, "changInfo should not be null"); if (ModelChanged != null) { ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, null, null, changInfo)); modelTreeManager.SyncModelAndText(); } }
internal void OnModelItemRemoved(ModelItem modelItem, ModelChangeInfo changInfo) { Fx.Assert(modelItem != null, "modelItem should not be null"); if (ModelChanged != null) { List <ModelItem> modelItemsRemoved = new List <ModelItem>(1); modelItemsRemoved.Add(modelItem); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, modelItemsRemoved, null, changInfo)); modelTreeManager.SyncModelAndText(); } }
internal void OnModelItemAdded(ModelItem modelItem, ModelChangeInfo changeInfo) { Fx.Assert(modelItem != null, "modelItem should not be null"); if (ModelChanged != null) { Fx.Assert(modelItem != null, "trying to add empty model item"); List <ModelItem> modelItemsAdded = new List <ModelItem>(1); modelItemsAdded.Add(modelItem); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(modelItemsAdded, null, null, changeInfo)); modelTreeManager.SyncModelAndText(); } }
internal void OnModelPropertyChanged(ModelProperty property, ModelChangeInfo changeInfo) { Fx.Assert(property != null, "property cannot be null"); Fx.Assert(changeInfo != null, "changeInfo cannot be null"); if (ModelChanged != null) { List <ModelProperty> propertiesChanged = new List <ModelProperty>(1); propertiesChanged.Add(property); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, null, propertiesChanged, changeInfo)); modelTreeManager.SyncModelAndText(); } }
public override bool Apply() { Fx.Assert(this.ModelTreeManager != null, "Modeltreemanager cannot be null"); Fx.Assert(this.Owner != null, "Owner modelitem cannot be null"); Fx.Assert(!String.IsNullOrEmpty(this.PropertyName), " property name cannot be null or emptry"); ModelPropertyImpl dataModelProperty = (ModelPropertyImpl)this.Owner.Properties[this.PropertyName]; ModelItem oldValue = dataModelProperty.Value; if ((oldValue == null && this.NewValue == null) || (oldValue != null && this.NewValue != null && oldValue.GetCurrentValue().Equals(this.NewValue.GetCurrentValue()))) { return(false); } dataModelProperty.SetValueCore(this.NewValue); ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreatePropertyChanged(this.Owner, this.PropertyName, this.OldValue, this.NewValue); this.ModelTreeManager.NotifyPropertyChange(dataModelProperty, changeInfo); return(true); }
private void ApplyInsert() { Fx.Assert(this.ModelTreeManager != null, "ModelTreeManager cannot be null."); Fx.Assert(this.Collection != null, "this.Collection cannot be null."); if (this.Index >= 0) { ((ModelItemCollectionImpl)this.Collection).InsertCore(this.Index, this.Item); } else { Fx.Assert(this.Index == -1, "-1 must be used to indicate Add(item)"); this.Index = this.Collection.Count; ((ModelItemCollectionImpl)this.Collection).AddCore(this.Item); } ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreateCollectionItemAdded(this.Collection, this.Item); this.ModelTreeManager.NotifyCollectionInsert(this.Item, changeInfo); }
private void ApplyDelete() { Fx.Assert(this.ModelTreeManager != null, "ModelTreeManager cannot be null."); Fx.Assert(this.Collection != null, "this.Collection cannot be null."); if (this.Index >= 0) { ((ModelItemCollectionImpl)this.Collection).RemoveAtCore(this.Index); } else { Fx.Assert(this.Index == -1, "-1 must be used to indicate Remove(item)"); this.Index = this.Collection.IndexOf(this.Item); ((ModelItemCollectionImpl)this.Collection).RemoveCore(this.Item); } ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreateCollectionItemRemoved(this.Collection, this.Item); this.ModelTreeManager.NotifyCollectionRemove(this.Item, changeInfo); }
void ModelChanged(object sender, ModelChangedEventArgs e) { ModelChangeInfo changeInfo = e.ModelChangeInfo; if (changeInfo != null && changeInfo.ModelChangeType == ModelChangeType.PropertyChanged) { Type propertyType = changeInfo.Subject.ItemType; if (changeInfo.PropertyName == "Name") { if (propertyType.Equals(typeof(ActivityBuilder))) { activityBuilderDisplayNameProperty.NotifyPropertyChanged(changeInfo.Subject); } else if (propertyType.Equals(typeof(ActivityTemplateFactoryBuilder))) { activityTemplateFactoryBuilderDisplayNameProperty.NotifyPropertyChanged(changeInfo.Subject); } } } }
private void ApplyInsert() { ((ModelItemDictionaryImpl)this.Dictionary).AddCore(this.Key, this.Value); ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreateDictionaryKeyValueAdded(this.Dictionary, this.Key, this.Value); if (this.Key != null) { this.ModelTreeManager.modelService.OnModelItemAdded(this.Key, changeInfo); changeInfo = null; } if (this.Value != null) { this.ModelTreeManager.modelService.OnModelItemAdded(this.Value, changeInfo); changeInfo = null; } if (changeInfo != null) { this.ModelTreeManager.modelService.EmitModelChangeInfo(changeInfo); } }