private void OnSeriesSymbolRendering(object sender, RenderSymbolEventArgs e) { if (e.Series == null && e.Series.Name == null) { return; } var args = new ItemFormattingEventArgs(e.Index, e.Series.Name); ItemFormatting?.Invoke(this, args); style = args.Style; if (style != null) { var backColor = style.BackColor; if (!backColor.IsEmpty) { e.Engine.SetFill(backColor.ToArgb()); } var borderColor = args.Style.BorderColor; if (!borderColor.IsEmpty) { e.Engine.SetStroke(borderColor.ToArgb()); } } }
private void FormattablePieChart_SliceRendering(object sender, RenderSliceEventArgs e) { var pie = (IPieChart)this; var args = new ItemFormattingEventArgs(e.Index, Binding); ItemFormatting?.Invoke(this, args); style = args.Style; if (style != null) { var backColor = style.BackColor; if (!backColor.IsEmpty) { e.Engine.SetFill(backColor.ToArgb()); } var borderColor = args.Style.BorderColor; if (!borderColor.IsEmpty) { e.Engine.SetStroke(borderColor.ToArgb()); } } }
/// <summary> /// Apply a style to the given row /// </summary> /// <param name="olvi"></param> /// <param name="style"></param> protected virtual void ApplyRowStyle(OLVListItem olvi, IItemStyle style) { if (style == null) return; if (this.FullRowSelect || this.View != View.Details) { if (style.Font != null) olvi.Font = style.Font; if (style.FontStyle != FontStyle.Regular) olvi.Font = new Font(olvi.Font ?? this.Font, style.FontStyle); if (!style.ForeColor.IsEmpty) { if (olvi.UseItemStyleForSubItems) olvi.ForeColor = style.ForeColor; else { foreach (ListViewItem.ListViewSubItem x in olvi.SubItems) { x.ForeColor = style.ForeColor; } } } if (!style.BackColor.IsEmpty) { if (olvi.UseItemStyleForSubItems) olvi.BackColor = style.BackColor; else { foreach (ListViewItem.ListViewSubItem x in olvi.SubItems) { x.BackColor = style.BackColor; } } } } else { olvi.UseItemStyleForSubItems = false; foreach (ListViewItem.ListViewSubItem x in olvi.SubItems) { if (style.BackColor.IsEmpty) x.BackColor = olvi.BackColor; else x.BackColor = style.BackColor; } this.ApplyCellStyle(olvi, 0, style); } }
/// <summary> /// Apply a style to a cell /// </summary> /// <param name="olvi"></param> /// <param name="columnIndex"></param> /// <param name="style"></param> protected virtual void ApplyCellStyle(OLVListItem olvi, int columnIndex, IItemStyle style) { if (style == null) return; // Don't apply formatting to subitems when not in Details view if (this.View != View.Details && columnIndex > 0) return; olvi.UseItemStyleForSubItems = false; ListViewItem.ListViewSubItem subItem = olvi.SubItems[columnIndex]; if (style.Font != null) subItem.Font = style.Font; if (style.FontStyle != FontStyle.Regular) subItem.Font = new Font(subItem.Font ?? olvi.Font ?? this.Font, style.FontStyle); if (!style.ForeColor.IsEmpty) subItem.ForeColor = style.ForeColor; if (!style.BackColor.IsEmpty) subItem.BackColor = style.BackColor; }
/// <summary> /// Apply a style to the given row /// </summary> /// <param name="olvi"></param> /// <param name="style"></param> /// <param name="primaryColumnOnly"></param> protected virtual void ApplyRowStyle(OLVListItem olvi, IItemStyle style, bool primaryColumnOnly) { if (style == null) return; if (!primaryColumnOnly || this.View != View.Details) { Font font = style.Font ?? olvi.Font; if (style.FontStyle != FontStyle.Regular) font = new Font(font ?? this.Font, style.FontStyle); if (!Equals(font, olvi.Font)) { if (olvi.UseItemStyleForSubItems) olvi.Font = font; else { foreach (ListViewItem.ListViewSubItem x in olvi.SubItems) { x.Font = font; } } } if (!style.ForeColor.IsEmpty) { if (olvi.UseItemStyleForSubItems) olvi.ForeColor = style.ForeColor; else { foreach (ListViewItem.ListViewSubItem x in olvi.SubItems) { x.ForeColor = style.ForeColor; } } } if (!style.BackColor.IsEmpty) { if (olvi.UseItemStyleForSubItems) olvi.BackColor = style.BackColor; else { foreach (ListViewItem.ListViewSubItem x in olvi.SubItems) { x.BackColor = style.BackColor; } } } } else { olvi.UseItemStyleForSubItems = false; foreach (ListViewItem.ListViewSubItem x in olvi.SubItems) { x.BackColor = style.BackColor.IsEmpty ? olvi.BackColor : style.BackColor; x.ForeColor = style.ForeColor.IsEmpty ? olvi.ForeColor : style.ForeColor; } this.ApplyCellStyle(olvi, 0, style); } }