public NotifyCollectionChangingEventArgs(NotifyCollectionChangeAction action, object item, int index, int oldIndex) { Action = action; Item = item; Index = index; OldIndex = oldIndex; }
public void RememberOldValues(object sender, NotifyCollectionChangingEventArgs e) { if (List != null) { throw new InvalidOperationException("Old value is already initialized"); } List = (IList)sender; Action = e.Action; Index = e.Index; switch (e.Action) { case NotifyCollectionChangeAction.Add: break; case NotifyCollectionChangeAction.Remove: OldValue = e.Item; break; case NotifyCollectionChangeAction.Replace: OldValue = List[e.Index]; // remember value being replaced break; } }
private void FireCollectionChangedEvent(NotifyCollectionChangeAction action, object item, int index, object oldItem = null) { try { if (CollectionChanged != null) { EditActionAttribute.BubbleIndentCounter++; if (EventSettings.EnableLogging) { eventsLog.DebugFormat(EditActionAttribute.BubbleIndent + "CollectionChanged L<< '{0}[{1}]', item:{2}, index:{3}, action:{4} - END <<<<<<<<<<<<<<", "EventedList", typeof(T).Name, item, index, action); } var args = new NotifyCollectionChangingEventArgs(action, item, index, -1) { OldItem = oldItem }; CollectionChanged(this, args); EditActionAttribute.BubbleIndentCounter--; } } finally { EditActionAttribute.FireAfterEventCall(this, false, false); } }
public void RememberOldValues(object sender, NotifyCollectionChangingEventArgs e) { if (List != null) { throw new InvalidOperationException("Old value is already initialized"); } List = (IList)sender; Action = e.Action; Index = e.Index; switch(e.Action) { case NotifyCollectionChangeAction.Add: break; case NotifyCollectionChangeAction.Remove: OldValue = e.Item; break; case NotifyCollectionChangeAction.Replace: OldValue = List[e.Index]; // remember value being replaced break; } }
private bool FireCollectionChangingEvent(NotifyCollectionChangeAction action, T item, int index) { EditActionAttribute.FireBeforeEventCall(this, false); if (CollectionChanging != null) { if (EventSettings.EnableLogging) { eventsLog.DebugFormat(EditActionAttribute.BubbleIndent + "CollectionChanging L>> '{0}[{1}]', item:{2}, index:{3}, action:{4} - BEGIN >>>>>>>>>>>>>>", "EventedList", typeof(T).Name, item, index, action); } var args = new NotifyCollectionChangingEventArgs(action, item, index, -1); try { CollectionChanging(this, args); } catch { EditActionAttribute.FireAfterEventCall(this, false, args.Cancel); throw; } if (args.Cancel) { EditActionAttribute.FireAfterEventCall(this, false, args.Cancel); } return(!args.Cancel); } return(true); }
public MultiDimensionalArrayChangingEventArgs(NotifyCollectionChangeAction action, IList items, int index, int oldIndex, int[] stride, int[] shape) { Stride = stride; // TODO: maybe we should clone it here, will be slow Action = action; Items = items; Shape = shape; Index = index; OldIndex = oldIndex; }
private void FireCollectionChanged(NotifyCollectionChangeAction action, object value, int index1d, int oldIndex1d) { FireCollectionChanged(action, new[] { value }, index1d, oldIndex1d, new[] { 1 }); /*if(CollectionChanged == null) * { * return; * } * * CollectionChanged(this, new MultiDimensionalArrayChangingEventArgs(action, value, index1d, oldIndex1d, stride));*/ }
private void FireCollectionChanged(NotifyCollectionChangeAction action, IList values, int index1d, int oldIndex1d, int[] shape) { if (CollectionChanged == null) { return; } var eventArgs = new MultiDimensionalArrayChangingEventArgs(action, values, index1d, oldIndex1d, stride, shape); CollectionChanged(this, eventArgs); }
private void FireCollectionChangedEvent(NotifyCollectionChangeAction action, object item, int index, object oldItem = null) { if (CollectionChanged != null) { var args = new NotifyCollectionChangingEventArgs(action, item, index, -1) { OldItem = oldItem }; CollectionChanged(this, args); } }
private bool FireCollectionChangingEvent(NotifyCollectionChangeAction action, T item, int index) { if (CollectionChanging != null) { var args = new NotifyCollectionChangingEventArgs(action, item, index, -1); CollectionChanging(this, args); return(!args.Cancel); } return(true); }
private MultiDimensionalArrayChangingEventArgs FireCollectionChanging(NotifyCollectionChangeAction action, IList values, int index1d, int[] itemsShape) { if (CollectionChanging == null) { return(null); } var eventArgs = new MultiDimensionalArrayChangingEventArgs(action, values, index1d, -1, stride, itemsShape); CollectionChanging(this, eventArgs); return(eventArgs); }
private NotifyCollectionChangeAction GetInvertedAction(NotifyCollectionChangeAction action) { switch (action) { case NotifyCollectionChangeAction.Add: return(NotifyCollectionChangeAction.Remove); case NotifyCollectionChangeAction.Remove: return(NotifyCollectionChangeAction.Add); case NotifyCollectionChangeAction.Replace: return(NotifyCollectionChangeAction.Replace); } throw new NotSupportedException("Unknown action"); }
/// <summary> /// Resizes functions for the given argumentVariable. if x is dependend on y, x gets resized /// </summary> /// <param name="argumentVariable">The argument variable that is altered</param> /// <param name="action">action on the argument</param> /// <param name="index">index in argument array</param> /// <param name="oldIndex"></param> /// <param name="i"></param> private void ResizeDependendFunctionValuesForArgument(IVariable argumentVariable, NotifyCollectionChangeAction action, int index, int oldIndex, int length) { switch (action) { case NotifyCollectionChangeAction.Add: foreach (IVariable dependentVariable in DependentVariables[argumentVariable]) { int dependentVariableIndex = Functions.IndexOf(dependentVariable); int argumentIndex = dependentVariable.Arguments.IndexOf(argumentVariable); //argument based dependency if (argumentIndex != -1) { FunctionValues[dependentVariableIndex].InsertAt(argumentIndex, index, length); } } break; case NotifyCollectionChangeAction.Remove: foreach (IVariable dependentVariable in DependentVariables[argumentVariable]) { int dependentVariableIndex = Functions.IndexOf(dependentVariable); int argumentIndex = dependentVariable.Arguments.IndexOf(argumentVariable); //argument based dependency if (argumentIndex != -1) { FunctionValues[dependentVariableIndex].RemoveAt(argumentIndex, index); } } break; case NotifyCollectionChangeAction.Replace: if (index != oldIndex) { foreach (IVariable dependentVariable in DependentVariables[argumentVariable]) { int dependentVariableIndex = Functions.IndexOf(dependentVariable); int argumentIndex = dependentVariable.Arguments.IndexOf(argumentVariable); //argument based dependency if ((oldIndex != -1) && FunctionValues[dependentVariableIndex].Count != 0) { // TODO: extend it to work with Length > 1 FunctionValues[dependentVariableIndex].Move(argumentIndex, oldIndex, 1, index); } } } break; } }
private void ResizeDependendFunctionValuesForArgument(IVariable argumentVariable, NotifyCollectionChangeAction action, int index, int oldIndex, int length) { doNotCheckForDependentVariableResize = true; foreach (var dependentVariable in DependentVariables[argumentVariable]) { int dependentVariableIndex = Functions.IndexOf(dependentVariable); int argumentIndex = dependentVariable.Arguments.IndexOf(argumentVariable); var array = FunctionValues[dependentVariableIndex]; switch (action) { case NotifyCollectionChangeAction.Add: //argument based dependency if (argumentIndex != -1) { array.InsertAt(argumentIndex, index, length); } break; case NotifyCollectionChangeAction.Remove: //argument based dependency if (argumentIndex != -1) { array.RemoveAt(argumentIndex, index); } break; case NotifyCollectionChangeAction.Replace: if (index != oldIndex) { //argument based dependency if ((oldIndex != -1) && array.Count != 0) { // TODO: extend it to work with Length > 1 array.Move(argumentIndex, oldIndex, 1, index); } } break; } } doNotCheckForDependentVariableResize = false; }
private MultiDimensionalArrayChangingEventArgs FireCollectionChanging(NotifyCollectionChangeAction action, object value, int index1d) { return(FireCollectionChanging(action, new[] { value }, index1d, new[] { 1 })); }
public CollectionChangeKey(object sender, object item, NotifyCollectionChangeAction action) { this.sender = sender; this.item = item; this.action = action; }