void DrawSubitemText(BetterListViewDrawItemEventArgs eventArgs, int index) { var subitem = eventArgs.Item.SubItems[index]; var bounds = eventArgs.ItemBounds.SubItemBounds[index].BoundsInner; eventArgs.Graphics.DrawString(subitem.Text, subitem.Font, _isClassic && eventArgs.Item.Selected ? SystemBrushes.HighlightText : GetBrush(subitem.ForeColor), bounds, _flag); }
// FORMAT ITENS ID NUMBER //------------------------------------------------------------------------------------------------------------ private void lstItens_DrawItem(object sender, BetterListViewDrawItemEventArgs eventArgs) { if (int.TryParse(eventArgs.Item.Text, out int intValue)) { eventArgs.Item.Text = $"{intValue: 00}"; } }
// FORMAT ITENS ID NUMBER //------------------------------------------------------------------------------------------------------------ private void lstItens_DrawItem(object sender, BetterListViewDrawItemEventArgs eventArgs) { if (int.TryParse(eventArgs.Item.Text, out int intValue)) { eventArgs.Item.Text = $"{intValue: 00}"; } eventArgs.Item.SubItems[2].AlignHorizontal = TextAlignmentHorizontal.Right; //eventArgs.Item.SubItems[2].Text = $"{eventArgs.Item.SubItems[2].Value: 00}"; }
protected override void OnDrawItem(BetterListViewDrawItemEventArgs eventArgs) { eventArgs.DrawSelection = false; base.OnDrawItem(eventArgs); if (eventArgs.Item.Selected) { eventArgs.Graphics.DrawRectangle(Pens.Black, eventArgs.ItemBounds.BoundsSelection); } }
private void onDraw(object lvSender, BetterListViewDrawItemEventArgs eventArgs) { BetterListView lview = (BetterListView)lvSender; var item = eventArgs.Item; T tag = (T)item.Tag; var index = base.IndexOf(tag); item.ImageList.Images.Add(new Bitmap(1, 1)); if (updateList[index] == false) { updateList[index] = true; CollumnDisplay2(tag, item); } }
//public new List<BetterListViewExColumnHeader> Columns = new List<BetterListViewExColumnHeader>(); protected override void OnDrawItem(BetterListViewDrawItemEventArgs eventArgs) { int percentOutOf = 100; base.OnDrawItem(eventArgs); if (View != BetterListViewView.Details) { return; } Graphics graphics = eventArgs.Graphics; foreach (BetterListViewSubItem current in eventArgs.Item.SubItems) { if (current.Index >= base.Columns.Count) { break; } Rectangle boundsInner = eventArgs.ItemBounds.SubItemBounds[current.Index].BoundsInner; if ((boundsInner.Width > 0) && (boundsInner.Height > 0)) { BetterListViewExColumnHeader blvExColumnHeader = (BetterListViewExColumnHeader)Columns[current.Index]; switch (blvExColumnHeader?.ColumnType) { case BetterListViewExColumnType.PercentDone: if ((boundsInner.Width > 4) && (boundsInner.Height > 4) && current.Value is short) { int num3 = Math.Min(16, boundsInner.Height); Rectangle rectangle = new Rectangle(boundsInner.Left, boundsInner.Top + ((boundsInner.Height - num3) >> 1), boundsInner.Width - 2, num3); short num4 = (short)current.Value; if (ProgressBarRenderer.IsSupported) { Rectangle bounds = new Rectangle(rectangle.Left + 1, rectangle.Top + 1, (int)num4 * (rectangle.Width - 1) / percentOutOf, rectangle.Height - 2); ProgressBarRenderer.DrawHorizontalBar(graphics, rectangle); ProgressBarRenderer.DrawHorizontalChunks(graphics, bounds); } else { Rectangle rect3 = new Rectangle(rectangle.Left + 1, rectangle.Top + 1, (int)num4 * (rectangle.Width - 1) / percentOutOf, rectangle.Height - 1); graphics.FillRectangle(SystemBrushes.Window, rectangle); graphics.FillRectangle(SystemBrushes.Highlight, rect3); graphics.DrawRectangle(SystemPens.Control, rectangle); } } break; } } } }
private void LvTasksDrawItem(object sender, BetterListViewDrawItemEventArgs e) { int idxActivity = lvhActivity.Index; Rectangle rectInner = e.ItemBounds.SubItemBounds[idxActivity].BoundsInner; if (rectInner.Width <= 0 || rectInner.Height <= 0) { return; } TaskModel task = e.Item.DataObject <TaskModel>(); BetterListViewSubItem subActivity = e.Item.SubItems[idxActivity]; Image image = null; switch (task.State) { case TaskState.Idle: image = Resources.Resources.GreyBall; break; case TaskState.Active: image = Resources.Resources.GreenBall; break; case TaskState.Suspended: image = Resources.Resources.YellowBall; break; case TaskState.Deleted: image = Resources.Resources.RedBall; break; case TaskState.Closed: image = Resources.Resources.BlueBall; break; } if (subActivity.Image != image) { subActivity.Image = image; } }
// DRAW ITEMS //------------------------------------------------------------------------------------------------------------ private void lstUsuarios_DrawItem(object sender, BetterListViewDrawItemEventArgs eventArgs) { if (int.TryParse(eventArgs.Item.Text, out int intValue)) { eventArgs.Item.Text = $"{intValue: 0000}"; } if (eventArgs.Item.SubItems[3].Value != null) { eventArgs.Item.SubItems[3].AlignHorizontalImage = BetterListViewImageAlignmentHorizontal.OverlayCenter; if ((bool)eventArgs.Item.SubItems[3].Value == true) { eventArgs.Item.SubItems[3].Image = ItemAtivo; } else if ((bool)eventArgs.Item.SubItems[3].Value == false) { eventArgs.Item.SubItems[3].Image = ItemInativo; } } }
/// <summary> /// Raises the DrawItem event. /// </summary> /// <param name="eventArgs">The BetterListViewDrawItemEventArgs instance containing the event data.</param> protected override void OnDrawItem(BetterListViewDrawItemEventArgs eventArgs) { if (eventArgs.Item.SubItems.Count <= 6) { return; } var traincell = (ResultSubItems.TrainCodeSubItem)eventArgs.Item.SubItems[0]; var result = traincell.ResultItem; eventArgs.DrawSubItemTexts[1] = false; eventArgs.DrawSubItemTexts[2] = false; eventArgs.DrawSubItemTexts[3] = false; if (ShowStartAndEndStation) { eventArgs.DrawSubItemTexts[4] = false; eventArgs.DrawSubItemTexts[5] = false; } //备注 eventArgs.DrawSubItemTexts[eventArgs.Item.SubItems.Count - 1] = false; base.OnDrawItem(eventArgs); //发站 DrawSubitemText(eventArgs, 1); DrawSubitemText(eventArgs, 2); DrawSubitemText(eventArgs, 3); if (ShowStartAndEndStation) { DrawSubitemText(eventArgs, 4); DrawSubitemText(eventArgs, 5); } var ticketStartIndex = 4 + (ShowStartAndEndStation ? 2 : 0); for (var i1 = ticketStartIndex; i1 < eventArgs.Item.SubItems.Count - 1; i1++) { var tcell = (ResultSubItems.TicketCellSubItem)eventArgs.Item.SubItems[i1]; var price = result.TicketCount.GetTicketData(tcell.Code); if (price == null) { continue; } if (price.Price > 0.01 || !price.MemoText.IsNullOrEmpty()) { var innerBoun = eventArgs.ItemBounds.SubItemBounds[i1].BoundsInner; var text = price.MemoText ?? "¥" + (price.Price ?? 0.0).ToString("#0.0"); eventArgs.Graphics.DrawString(text, _priceFont, _isClassic && eventArgs.Item.Selected ? SystemBrushes.HighlightText : (price.MemoTextColor ?? (price.HasDiscount ? Brushes.BlueViolet : price.NotNeed || price.NoTicket ? Brushes.Gray : Brushes.Green)), new PointF(innerBoun.Left, innerBoun.Bottom - 10)); } } //备注 DrawSubitemText(eventArgs, eventArgs.Item.SubItems.Count - 1); var statusMsg = ""; if (result.ControlFlag != 0) { statusMsg += result.ControlMessage; } if (result.IsLimitSell) { statusMsg += result.ButtonTextInfo; } if (!result.IsAvailable) { if (result.BeginSellTime != null) { statusMsg += result.SellTimeTip; } else if (result.IsLimitSell) { statusMsg += result.ButtonTextInfo; } } if (!statusMsg.IsNullOrEmpty()) { var bounds = eventArgs.Item.Bounds; var ticketPriceBounds = eventArgs.ItemBounds.SubItemBounds[ticketStartIndex]; //var size = eventArgs.Graphics.MeasureString("鱼", Font); var xbound = new Rectangle(ticketPriceBounds.BoundsCell.Location, new Size(bounds.BoundsInner.Width - ticketPriceBounds.BoundsCell.X, ticketPriceBounds.BoundsCell.Height)); //eventArgs.Graphics.DrawString(statusMsg, Font, Brushes.Chocolate, ticketPriceBounds.BoundsCell.X, ticketPriceBounds.BoundsCell.Y + (ticketPriceBounds.BoundsCell.Height - size.Height) / 2); eventArgs.Graphics.DrawString(statusMsg, Font, Brushes.Chocolate, xbound, _stringflag_leftcenter); } }