void EntryRemoved(EntryEvent<CarKey, Car> _event) { if (this.InvokeRequired) { this.Invoke( new MethodInvoker( delegate() { EntryRemoved(_event); })); } else { long modelId = _event.GetKey().ModelId; BindingList<RowData> list = bindingSource.DataSource as BindingList<RowData>; for (int i = 0; i < list.Count; i++) { if (modelId == list[i].ModelId) { list.RemoveAt(i); } } } }
void EntryUpdated(EntryEvent<CarKey, Car> _event) { if (this.InvokeRequired) { this.Invoke( new MethodInvoker( delegate() { EntryUpdated(_event); })); } else { Console.WriteLine("UPDATE RECEIVED"); long modelId = _event.GetKey().ModelId; BindingList<RowData> list = bindingSource.DataSource as BindingList<RowData>; for (int i = 0; i < list.Count; i++) { if (modelId == list[i].ModelId) { CarKey key = _event.GetKey(); Car car = _event.GetValue(); var row = list[i]; row.Update(key, car); list[i] = row; } } } }
void EntryAdded(EntryEvent<CarKey, Car> _event) { if (this.InvokeRequired) { this.Invoke( new MethodInvoker( delegate() { EntryAdded(_event); })); } else { BindingList<RowData> list = bindingSource.DataSource as BindingList<RowData>; CarKey key = _event.GetKey(); Car car = _event.GetValue(); list.Add(new RowData(key, car)); } }