void Blink(ListChangedEventArgs e) { if (BlinkTime <= 0) { return; } ChangedFieldInfoCollection changeFields = GetChangedFields(); bool anyCellInvalidated = false; if (changeFields != null) { foreach (ChangedFieldInfo ci in changeFields) { PropertyDescriptor pd = _pdc[ci.Name]; object item = SourceList[e.NewIndex]; DataRow row = item as DataRow; BlinkState bs = BlinkState.None; if (e.ListChangedType == ListChangedType.ItemAdded) { bs = BlinkState.NewRecord; } else { object value = ci.NewValue; object oldValue = ci.OldValue; int cmp = CompareColumns.CompareNullableObjects(value, oldValue); if (cmp > 0) { bs = BlinkState.Increased; if (oldValue == null || oldValue is DBNull) { bs = BlinkState.NewValue; } } else if (cmp < 0) { bs = BlinkState.Reduced; if (value == null || value is DBNull) { bs = BlinkState.NullValue; } } } if (bs != BlinkState.None) { RowColumnIndex key = BlinkInfo.GetKey(e.NewIndex, ci.FieldIndex); BlinkInfo biOld; if (_blinkTable.TryGetValue(key, out biOld)) { int n = _blinkQueue.IndexOf(biOld); if (n != -1) { _blinkQueue.RemoveAt(n); } } BlinkInfo bi = new BlinkInfo(bs, e.NewIndex, ci.FieldIndex, Environment.TickCount, ci); _blinkQueue.Add(bi); _blinkTable[key] = bi; int record = e.NewIndex; int rowIndex = record + 1; int columnIndex = bi.fieldIndex + 1; RowColumnIndex cellRowColumnIndex = new RowColumnIndex(rowIndex, columnIndex); RenderStyles.Clear(cellRowColumnIndex); if (IsCellVisible(cellRowColumnIndex)) { InvalidateCellRenderStyleBackground(cellRowColumnIndex); anyCellInvalidated = true; } } } } if (anyCellInvalidated) { InvalidateVisual(false); } }
private void OnSourceListItemChanged(ListChangedEventArgs e) { //Console.WriteLine("OnSourceListItemChanged: {0} {1}", e.NewIndex, ((DataRowView)SourceList[e.NewIndex])[0]); int rowIndex = e.NewIndex + 1; bool rowVisible = IsRowVisible(rowIndex); bool anyCellVisible = false; ChangedFieldInfoCollection cc = GetChangedFields(); if (cc.Count > 0) { foreach (ChangedFieldInfo fi in cc) { int columnIndex = fi.FieldIndex + 1; PropertyDescriptor pd = _pdc[columnIndex - 1]; if (pd.PropertyType == typeof(double)) { _totals[columnIndex - 1] += fi.Delta; if (!_invalidateWholeSummaryRow) { InvalidateCell(new RowColumnIndex(SourceList.Count + 1, columnIndex)); } } RowColumnIndex cellRowColumnIndex = new RowColumnIndex(rowIndex, columnIndex); if (CurrentCell.CellRowColumnIndex == cellRowColumnIndex) { if (!CurrentCell.IsInConfirmChanges) { CurrentCell.RejectChanges(); Model.VolatileCellStyles.Clear(cellRowColumnIndex); RenderStyles.Clear(cellRowColumnIndex); CurrentCell.Renderer.RefreshContent(); } else { this.InvalidateCell(cellRowColumnIndex); continue; } } else { InvalidateCell(cellRowColumnIndex); } if (rowVisible) { anyCellVisible |= IsColumnVisible(columnIndex); } } if (_invalidateWholeSummaryRow) { InvalidateCell(GridRangeInfo.Row(SourceList.Count + 1)); } } else { for (int n = 0; n < _pdc.Count; n++) { int columnIndex = n + 1; RowColumnIndex cell = new RowColumnIndex(rowIndex, columnIndex); if (rowVisible) { anyCellVisible |= IsColumnVisible(columnIndex); } } } Blink(e); ProcessBlinkQueue(); if (anyCellVisible) { InvalidateVisual(false); } }