private void addPaintCardActions(PaintActions actions, Rectangle clipRectangle) { var hotTrackBgBrush = new SolidBrush(SelectionOptions.HotTrackBackColor); var hotTrackBgPen = new Pen(SelectionOptions.HotTrackBorderColor); for (int i = 0; i < Cards.Count; i++) { var card = Cards[i]; int rowHandle = getRowHandle(displayIndex: i); if (!card.Visible || card.DataSource == null) { continue; } var cardArea = new Rectangle(card.Location, card.Size); if (!clipRectangle.IntersectsWith(cardArea)) { continue; } actions.Back.Add(e => card.PaintSelf(e.Graphics, card.Location, BackColor)); foreach (var field in card.Fields) { var fieldArea = new Rectangle(card.Location.Plus(field.Location), field.Size); if (!clipRectangle.IntersectsWith(fieldArea)) { continue; } actions.Back.Add(e => paintFieldBg(e, field, fieldArea, hotTrackBgBrush, hotTrackBgPen)); actions.FieldData.Add(e => paintFieldData(e, card, field, fieldArea, rowHandle)); actions.FieldButtons.Add(e => paintButtons(e, field, card)); } } }
private void paint(object sender, PaintEventArgs eArgs) { var paintActions = new PaintActions(); // implicit connection: data_source_sync lock (DataSource) { paintActions.Back.Add(e => e.Graphics.Clear(BackColor)); addPaintCardActions(paintActions, eArgs.ClipRectangle); paintActions.AlignButtons.Add(paintAlignButtons); paintActions.Selection.Add(paintSelection); eArgs.Graphics.SmoothingMode = SmoothingMode.HighQuality; eArgs.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; paintActions.Back.Paint(eArgs); paintActions.FieldData.Paint(eArgs); paintActions.Selection.Paint(eArgs); paintActions.AlignButtons.Paint(eArgs); // paint field buttons over align buttons paintActions.FieldButtons.Paint(eArgs); } }