private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.ColumnIndex == 1) { using (var ms = new MemoryStream()) { using (var sw = new StreamWriter(ms)) { sw.Write(e.SubItem.Text); sw.Flush(); ms.Seek(0, SeekOrigin.Begin); var rtb = new RichTextBox(); { rtb.BorderStyle = BorderStyle.None; rtb.LoadFile(ms, RichTextBoxStreamType.RichText); rtb.Location = e.SubItem.Bounds.Location; rtb.Size = e.SubItem.Bounds.Size; rtb.Parent = sender as Control; var bmp = new Bitmap(128, 32); rtb.DrawToBitmap(bmp, rtb.DisplayRectangle); //bmp.Save("test.bmp"); e.Graphics.DrawImageUnscaledAndClipped(bmp, e.SubItem.Bounds); //e.DrawBackground(); //e.Graphics.DrawString(rtb.Text, SystemFonts.DefaultFont, SystemBrushes.ControlText, e.SubItem.Bounds); } } } } else { e.DrawBackground(); e.DrawText(); } }
private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawBackground(); e.DrawText(); }
/************************************************************* * CSVリストビューを縞模様に描画 *************************************************************/ private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { // 奇数行の場合は背景色を変更し、縞々に見えるようにする if (e.ItemIndex % 2 > 0) { e.Graphics.FillRectangle(Brushes.Azure, e.Bounds); } // テキストを忘れずに描画する e.DrawText(); }
private void listViewFilterItem_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawText(); }
private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { Brush brush; Color backColor; Color foreColor; if (e.Item.Selected) { if (listView.Focused) { brush = SystemBrushes.Highlight; backColor = SystemColors.Highlight; foreColor = SystemColors.HighlightText; } else { // We use the same colors here as TreeViewMS does for // drawing unfocused selected rows. brush = Brushes.LightGray; backColor = Color.LightGray; foreColor = SystemColors.WindowText; } } else { brush = SystemBrushes.Window; backColor = SystemColors.Window; foreColor = SystemColors.WindowText; } if (e.ColumnIndex == 0) { // Erase the entire background when drawing the first sub-item e.Graphics.FillRectangle(brush, e.Item.Bounds); } if (e.ColumnIndex == colHdrDisplayText.Index) { var findResult = (FindResult) e.Item.Tag; var textRendererHelper = new TextRendererHelper { ForeColor = foreColor, BackColor = backColor, Font = e.Item.Font, HighlightFont = new Font(e.Item.Font, FontStyle.Bold), }; textRendererHelper.DrawHighlightedText(e.Graphics, e.SubItem.Bounds, findResult.FindMatch); } else { e.SubItem.ForeColor = foreColor; e.DrawText(); } if (e.ColumnIndex == 0) { e.DrawFocusRectangle(e.Bounds); } }
private void nodeListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.ColumnIndex > 0) { Rectangle bounds = e.SubItem.Bounds; if (e.Item.Selected) { e.Graphics.FillRectangle(HL_BRUSH, bounds); e.SubItem.ForeColor = SystemColors.HighlightText; } else { e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), bounds); e.SubItem.ForeColor = e.Item.ForeColor; } e.DrawText(TextFormatFlags.VerticalCenter); e.Graphics.DrawLine(LINE_PEN, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom); } else { e.DrawDefault = true; } }
private void DrawSubItem(DrawListViewSubItemEventArgs e, decimal Width, bool Focused) { Rectangle rect, origrect = e.Bounds; if (Focused) e.Graphics.FillRectangle(SystemBrushes.Highlight, origrect); // Draw the background and focus rectangle for a selected item. else e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), origrect); // Draw the background for an unselected item. origrect.X += 1; origrect.Y += 1; origrect.Height -= 3; origrect.Width -= 3; rect = origrect; e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), rect); rect.Width = (int)((double)Width / 100.0 * origrect.Width); if (rect.Width > 0 && rect.Height > 0) { Brush br; if (Program.Settings.NoGradientTorrentList) br = new SolidBrush(Color.LimeGreen); else br = new LinearGradientBrush(rect, Color.ForestGreen, Color.LightGreen, LinearGradientMode.Horizontal); e.Graphics.FillRectangle(br, rect); } e.Graphics.DrawRectangle(LightLightGray, origrect); e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter); }
private void DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { TextFormatFlags flag = e.ColumnIndex > 0 ? TextFormatFlags.HorizontalCenter : TextFormatFlags.Left; e.DrawBackground(); e.DrawText(flag); }
void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { // 選択されている場合 if (e.Item.Selected) { e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds); } else { // 自デバイス宛のパケットだけ色を変える if (Adapter != null) { if(e.Item.Tag.ToString().ToUpper() == Adapter.Mac.ToUpper()){ e.Graphics.FillRectangle(Brushes.LightSteelBlue, e.Bounds); } } } // テキストを描画 e.DrawText(); }
private void lvServerBrowser_DrawSubItem(Object sender, DrawListViewSubItemEventArgs e) { if (e.ColumnIndex == 0) { Image imgLock = Properties.Resources.theLock; Image imgUnlock = Properties.Resources.theUnlock; if (lvServerBrowser.Items[e.ItemIndex].SubItems[e.ColumnIndex].Text.Equals("true")) { e.Graphics.DrawImage(imgLock, lvServerBrowser.Items[e.ItemIndex].SubItems[e.ColumnIndex].Bounds.Location); } else { e.Graphics.DrawImage(imgUnlock, lvServerBrowser.Items[e.ItemIndex].SubItems[e.ColumnIndex].Bounds.Location); } e.DrawFocusRectangle(lvServerBrowser.Items[e.ItemIndex].SubItems[e.ColumnIndex].Bounds); } else { e.DrawText(); } }
private void OnListViewDrawSubItem(object sender, DrawListViewSubItemEventArgs e) { //Controller.WriteLine("e.SubItem.Name: {0}", e.SubItem.Text); if (!e.SubItem.Text.Contains("23")) { e.DrawDefault = true; return; } //e.DrawBackground(); if ((e.ItemState & ListViewItemStates.Selected) == ListViewItemStates.Selected) { // } Rectangle b = new Rectangle(e.Bounds.Left + e.Bounds.Width / 4, e.Bounds.Top, e.Bounds.Width / 2, e.Bounds.Height); e.Graphics.FillRectangle(SystemBrushes.Highlight, b); e.DrawText(TextFormatFlags.Default); }
private void lstShow_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.ColumnIndex > 0) { e.DrawBackground(); string searchTerm = ""; int index = e.SubItem.Text.IndexOf(searchTerm); if (index >= 0) { string sBefore = e.SubItem.Text.Substring(0, index); Size bounds = new Size(e.Bounds.Width, e.Bounds.Height); Size s1 = TextRenderer.MeasureText(e.Graphics, sBefore, this.Font, bounds); Size s2 = TextRenderer.MeasureText(e.Graphics, searchTerm, this.Font, bounds); Rectangle rect = new Rectangle(e.Bounds.X + s1.Width, e.Bounds.Y, s2.Width, e.Bounds.Height); e.Graphics.SetClip(e.Bounds); e.Graphics.FillRectangle(new SolidBrush(Color.Yellow), rect); e.Graphics.ResetClip(); } e.DrawText(); } }
private void lvWindows_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { GameWindow window = Windows[e.ItemIndex]; if (lastForegroundWindow == window.HWnd) { // Draw the background and focus rectangle for a selected item. e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds); } else if (ActiveWindow == window) { // Draw the background and focus rectangle for a selected item. e.Graphics.FillRectangle( new SolidBrush(System.Drawing.SystemColors.Highlight), e.Bounds ); } if (e.ColumnIndex == 0) { if (e.Item.Checked) { ControlPaint.DrawCheckBox(e.Graphics, e.Bounds.X + 1, e.Bounds.Top + 1, 14, 14, ButtonState.Normal | ButtonState.Checked); } else { ControlPaint.DrawCheckBox(e.Graphics, e.Bounds.X + 1, e.Bounds.Top + 1, 14, 14, ButtonState.Normal); } e.Graphics.DrawString( e.Item.Text, lvWindows.Font, Brushes.Black, new PointF(e.Bounds.X + 16, e.Bounds.Top + 1) ); } else { e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.Left); } }
void lvLibrary_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { TextFormatFlags flags = TextFormatFlags.Left; using (StringFormat sf = new StringFormat()) { // Store the column text alignment, letting it default // to Left if it has not been set to Center or Right. switch (e.Header.TextAlign) { case HorizontalAlignment.Center: sf.Alignment = StringAlignment.Center; flags = TextFormatFlags.HorizontalCenter; break; case HorizontalAlignment.Right: sf.Alignment = StringAlignment.Far; flags = TextFormatFlags.Right; break; } // Draw the text and background for a subitem with a // negative value. double subItemValue; if (e.ColumnIndex > 0 && Double.TryParse( e.SubItem.Text, NumberStyles.Currency, NumberFormatInfo.CurrentInfo, out subItemValue) && subItemValue < 0) { // Unless the item is selected, draw the standard // background to make it stand out from the gradient. if ((e.ItemState & ListViewItemStates.Selected) == 0) { e.DrawBackground(); } // Draw the subitem text in red to highlight it. e.Graphics.DrawString(e.SubItem.Text, lvLibrary.Font, Brushes.Red, e.Bounds, sf); return; } // Draw normal text for a subitem with a nonnegative // or nonnumerical value. e.DrawText(flags); } }
private static void OnDrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.Header.Index > 0) { TextFormatFlags tff = TextFormatFlags.Left; // Workout the text alignment switch (e.Header.TextAlign) { case HorizontalAlignment.Center: tff = TextFormatFlags.HorizontalCenter; break; case HorizontalAlignment.Right: tff = TextFormatFlags.Right; break; } // draw the strings e.DrawText(tff); } }