void listViewResults_DrawItem(object sender, DrawListViewItemEventArgs e) { if (0 != (e.State & ListViewItemStates.Selected)) { e.Graphics.FillRectangle(Brushes.Yellow, e.Bounds); //ForeColor = Color.White; } else { //ForeColor = Color.Black; if (e.ItemIndex % 2 == 0) { e.Graphics.FillRectangle(Brushes.BlanchedAlmond, e.Bounds); } else { e.Graphics.FillRectangle(Brushes.White, e.Bounds); } if (0 != (e.State & ListViewItemStates.Focused)) { e.DrawFocusRectangle(); } } e.DrawText(); }
private void lvIcons_DrawItem(object sender, DrawListViewItemEventArgs e) { e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; if ((e.State & ListViewItemStates.Hot) != 0 && (e.State & ListViewItemStates.Selected) == 0) { this._ItemHoverRenderer.DrawBackground(e.Graphics, e.Bounds); } else if ((e.State & ListViewItemStates.Hot) != 0 && (e.State & ListViewItemStates.Selected) != 0) { this._Selectedx2Renderer.DrawBackground(e.Graphics, e.Bounds); } else if ((e.State & ListViewItemStates.Selected) != 0) { this._ItemSelectedRenderer.DrawBackground(e.Graphics, e.Bounds); } else { e.DrawBackground(); } var ico = _Icons[(int)e.Item.Tag].Icon; if (ico.Width <= 48) { e.Graphics.DrawIcon(_Icons[(int)e.Item.Tag].Icon, e.Bounds.X + (e.Bounds.Width - ico.Width) / 2, e.Bounds.Y + (e.Bounds.Height - ico.Height) / 2 - 5); } e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter | TextFormatFlags.WordEllipsis); }
private void drawframe(object sender, DrawListViewItemEventArgs e) { int i = (int)e.Item.Tag; bool patched; Bitmap bmp = Art.GetStatic(i, out patched); if (bmp == null) { if (e.Item.Selected)//((e.State & ListViewItemStates.Focused) != 0) e.Graphics.FillRectangle(BrushSelectBack, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 14); else e.Graphics.DrawRectangle(PenCommonBorder, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13); e.Graphics.FillRectangle(BrushEmptyBack, e.Bounds.X + 5, e.Bounds.Y + 5, e.Bounds.Width - 10, e.Bounds.Height - 10); return; } else { if (e.Item.Selected)//((e.State & ListViewItemStates.Focused) != 0) e.Graphics.FillRectangle(BrushSelectBack, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13); else if (ChangesInTiledataOrRadarCol[LandMaxIndex + i]) e.Graphics.FillRectangle(BrushChangeBack, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13); else if (patched) e.Graphics.FillRectangle(BrushPatchBack, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13); else e.Graphics.FillRectangle(BrushBackground, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13); if (frames_ParentControl == null ? frameClipToolStripMenuItem.Checked : Options.ArtItemClip) { e.Graphics.DrawImage(bmp, e.Bounds.X + 1, e.Bounds.Y + 1, new Rectangle(0, 0, e.Bounds.Width - 1, e.Bounds.Height - 14), GraphicsUnit.Pixel); } else { int width = bmp.Width; int height = bmp.Height; int boundWidth = e.Bounds.Width; int boundHeight = e.Bounds.Height - 13; if (width > boundWidth) { width = boundWidth; height = boundHeight * bmp.Height / bmp.Width; } if (height > boundHeight) { height = boundHeight; width = boundWidth * bmp.Width / bmp.Height; } e.Graphics.DrawImage(bmp, new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, width, height)); } //e.Graphics.DrawImage(bmp, e.Bounds.X, e.Bounds.Y, width, height); e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter); //e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); if (!e.Item.Selected)//((e.State & ListViewItemStates.Focused) == 0) e.Graphics.DrawRectangle(PenCommonBorder, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13); else e.Graphics.DrawRectangle(PenSelectBorder, e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 14); } }
private void listViewdrawItem(object sender, DrawListViewItemEventArgs e) { int graphic = (int)e.Item.Tag; int hue = 0; frames = Animations.GetAnimation(graphic, 0, 1, ref hue, false, true); if (frames == null) return; Bitmap bmp = frames[0].Bitmap; int width = bmp.Width; int height = bmp.Height; if (width > e.Bounds.Width) width = e.Bounds.Width; if (height > e.Bounds.Height) height = e.Bounds.Height; e.Graphics.DrawImage(bmp, e.Bounds.X, e.Bounds.Y, width, height); e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter); if (listView.SelectedItems.Contains(e.Item)) e.DrawFocusRectangle(); else e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); }
private void Frames_ListView_DrawItem(object sender, DrawListViewItemEventArgs e) { Bitmap bmp = m_Animation[(int)e.Item.Tag]; int width = bmp.Width; int height = bmp.Height; if (width > e.Bounds.Width) width = e.Bounds.Width; if (height > e.Bounds.Height) height = e.Bounds.Height; e.Graphics.DrawImage(bmp, e.Bounds.X, e.Bounds.Y, width, height); e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter); e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); }
/// <summary> /// Draws text for the listview item /// </summary> private void DataListView_DrawItem(object sender, DrawListViewItemEventArgs e) { // Draw the item text for views other than the Details view. if (DataListView.View != View.Details) e.DrawText(); }
private void lvMasterDesField_DrawItem(object sender, DrawListViewItemEventArgs e) { e.DrawBackground(); e.DrawText(); e.DrawFocusRectangle(); ListViewItem.ListViewSubItem LVSI = e.Item.SubItems[3]; if (LVSI != null) { Rectangle cellBounds = LVSI.Bounds; Rectangle rect = cellBounds; Point buttonLocation = new Point(); buttonLocation.Y = cellBounds.Y + 1; buttonLocation.X = cellBounds.X + 1; Rectangle ButtonBounds = new Rectangle(); ButtonBounds.X = cellBounds.X + 1; ButtonBounds.Y = cellBounds.Y + 1; ButtonBounds.Width = cellBounds.Width - 2; ButtonBounds.Height = cellBounds.Height - 3; Pen pen1 = new Pen(Brushes.White, 1); Pen pen2 = new Pen(Brushes.Black, 1); Pen pen3 = new Pen(Brushes.DimGray, 1); SolidBrush myBrush = new SolidBrush(SystemColors.Control); e.Graphics.FillRectangle(myBrush, ButtonBounds.X, ButtonBounds.Y, ButtonBounds.Width, ButtonBounds.Height); e.Graphics.DrawLine(pen2, ButtonBounds.X, ButtonBounds.Y + ButtonBounds.Height, ButtonBounds.X + ButtonBounds.Width, ButtonBounds.Y + ButtonBounds.Height); e.Graphics.DrawLine(pen2, ButtonBounds.X + ButtonBounds.Width, ButtonBounds.Y, ButtonBounds.X + ButtonBounds.Width, ButtonBounds.Y + ButtonBounds.Height); StringFormat sf1 = new StringFormat(); sf1.Alignment = StringAlignment.Center; sf1.LineAlignment = StringAlignment.Center; e.Graphics.DrawString("...", new Font("SimSun", 5), Brushes.Black, ButtonBounds.X + 10, ButtonBounds.Y + 5, sf1); } }
private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e) { // if(ImageLoadingTip.Length != (sender as ListView).Items.Count) { return; } string imageKey = e.Item.ImageKey; #region 非大图标默认显示 if (listView1.View != View.LargeIcon) { int id; if (int.TryParse(e.Item.ImageKey, out id)) { listView1.Items.Find(e.Item.Name, true)[0].ImageKey = "image"; } e.DrawDefault = true; return; } #endregion SRRC_ResourceEntity ent = e.Item.Tag as SRRC_ResourceEntity; //SRLogHelper.Instance.AddLog("日志", "DrawItem," + e.Item.Name + "," + DateTime.Now.ToString("ss.ffff")); //大图标,图片,未加载,图像字典中不包含。使用未加载是因为图像已提交加载,但未加载完成时,预防再次提交而使用。 if (listView1.View == View.LargeIcon && e.Item.ImageKey == "image" && !ImageLoadingTip[e.ItemIndex] && !SROperation2.Instance.Center1ImageDict.ContainsKey(ent.Id.ToString())) //图片类型,未加载图片 { ImageLoadingTip[e.ItemIndex] = true; // Thread t = new Thread(new ParameterizedThreadStart(DownLoadImage)); // t.Start(new string[] { ent.Id.ToString(), ent.Serverip.Replace(Param.IP,Param.ServerCacheIP.Trim('\\')) + ent.Path }); SROperation2.Instance.Center1ImageBlockingCollection.Add(new KeyValuePair<string, string>(ent.Id.ToString(), ent.Serverip.Replace(Param.IP, Param.ServerCacheIP.Trim('\\')) + ent.Path)); e.DrawDefault = true; } else { try { Image image1; if(SROperation2.Instance.Center1ImageDict.ContainsKey(ent.Id.ToString())) { image1 = SROperation2.Instance.Center1ImageDict[ent.Id.ToString()]; } else { image1 = SROperation2.Instance.Center1ImageDict[e.Item.ImageKey]; } Size size = e.Item.ImageList.ImageSize; e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; if ((e.State & ListViewItemStates.Selected) != 0 && e.Item.Selected) { e.Graphics.FillRectangle(new SolidBrush(Color.Gray), e.Bounds); Rectangle re = new Rectangle(e.Bounds.X + (e.Bounds.Width - size.Width) / 2, e.Bounds.Y + 2, size.Width, size.Height); e.Graphics.DrawImage(image1, re); //绘制次数 re = new Rectangle(re.X, re.Y + (re.Height - listView1.Font.Height + 2), re.Width, listView1.Font.Height + 2); //e.Graphics.FillRectangle(new SolidBrush(Color.Silver), re); e.Graphics.DrawString((e.Item.Tag as SRRC_ResourceEntity).Usecount.ToString(), listView1.Font, new SolidBrush(Color.Red), re, new StringFormat() { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Center }); if(ent.Iscomposite) { e.Graphics.DrawString("*", listView1.Font, new SolidBrush(Color.Red), re, new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center }); } } else { Rectangle re = new Rectangle(e.Bounds.X + (e.Bounds.Width - size.Width) / 2, e.Bounds.Y + 2, size.Width, size.Height); e.Graphics.DrawImage(image1, re); //绘制次数 re = new Rectangle(re.X, re.Y + (re.Height - listView1.Font.Height + 2), re.Width, listView1.Font.Height + 2); //e.Graphics.FillRectangle(new SolidBrush(Color.Silver), re); e.Graphics.DrawString((e.Item.Tag as SRRC_ResourceEntity).Usecount.ToString(), listView1.Font, new SolidBrush(Color.Red), re, new StringFormat() { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Center }); if (ent.Iscomposite) { e.Graphics.DrawString("*", listView1.Font, new SolidBrush(Color.Red), re, new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center }); } } e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter); } catch (Exception ex) { SRLogHelper.Instance.AddLog("异常","Center1","DrawItem", ex.Message); } } }
private void DrawFrameItem(object sender, DrawListViewItemEventArgs e) { AnimIdx edit = Ultima.AnimationEdit.GetAnimation(FileType, CurrBody, CurrAction, CurrDir); Bitmap[] currbits = edit.GetFrames(); Bitmap bmp = currbits[(int)e.Item.Tag]; int width = bmp.Width; int height = bmp.Height; if (listView1.SelectedItems.Contains(e.Item)) e.Graphics.DrawRectangle(new Pen(Color.Red), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); else e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); e.Graphics.DrawImage(bmp, e.Bounds.X, e.Bounds.Y, width, height); e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter); }
private void lstFiles_DrawItem(object sender, DrawListViewItemEventArgs e) { e.DrawBackground(); e.DrawDefault = true; e.DrawText(); e.DrawFocusRectangle(); }
void C1_DrawItem(object sender, DrawListViewItemEventArgs e) { if (main == null) return; e.DrawBackground(); e.DrawFocusRectangle(); RectangleF E = e.Bounds; SizeF Q = e.Graphics.MeasureString(e.Item.Text, F); Guid g = Guid.Empty; if (e.Item.Tag is gCInventory_PS_Wrapper.InventoryItem) g = (e.Item.Tag as gCInventory_PS_Wrapper.InventoryItem).ItemGuid; else g = (Guid)e.Item.Tag; if (ResourceManager.Rects.ContainsKey(g)) { RectangleF r0 = ResourceManager.Rects[g]; RectangleF r1 = E; r1.Height -= Q.Height; float sh = (r1.Height / r0.Height); float sw = (r1.Width / r0.Width); if (sw > sh)//new box not heigh enough { float h = r0.Height * sh; float w = r0.Width * sh; float q0 = (r1.Width - w) / 2.0f; r1.X += q0; r1.Width = w; r1.Height = h; } else { } e.Graphics.DrawImage(main, r1, r0, GraphicsUnit.Pixel); } e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter); }
/// <summary> /// Draws the backgrounds for entire ListView items. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListView_DrawItem(object sender, DrawListViewItemEventArgs e) { if ((e.State & ListViewItemStates.Selected) != 0) { // Draw the background and focus rectangle for a selected item. e.Graphics.FillRectangle(Brushes.Aqua, e.Bounds); e.DrawFocusRectangle(); } else { // Draw the background for an unselected item. using (LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, Color.White, Color.Aqua, LinearGradientMode.BackwardDiagonal)) { e.Graphics.FillRectangle(brush, e.Bounds); } } // Draw the item text for views other than the Details view. //if (listView1.View != View.Details) //{ e.DrawText(); //} }
private void listView_DrawItem(object sender, DrawListViewItemEventArgs e) { if (e.Item.Tag != null) { e.Item.Checked = (bool)e.Item.Tag; } e.DrawBackground(); e.DrawText(); }
private void OnDrawItem(object sender, DrawListViewItemEventArgs e) { Graphics g = e.Graphics; //画图标 Image img = ((ListViewNF)(e.Item.ListView)).ImageListNF[e.Item.ImageIndex]; Rectangle bounds = e.Bounds; int imgStartX = -img.Width / 2; int imgStartY = -img.Height / 2; g.TranslateTransform(bounds.Left + bounds.Width/2, bounds.Top + 2 + img.Height / 2); if (m_isSetting) { g.RotateTransform(m_rockAngle); } if (e.Item == m_hotItem)//(e.State & ListViewItemStates.Selected) != 0) { //选中的暗色处理 ImageAttributes attr = new ImageAttributes(); float[][] colorMatrixElements = { new float[] {0.5f, 0, 0, 0, 0}, new float[] {0, 0.5f, 0, 0, 0}, new float[] {0, 0, 0.5f, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0.1f, 0.2f, 0.2f, 0, 1}}; ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements); attr.SetColorMatrix(colorMatrix,ColorMatrixFlag.Default,ColorAdjustType.Bitmap); g.DrawImage(img, new Rectangle(imgStartX, imgStartY, img.Width , img.Height ), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, attr); } else g.DrawImage(img, new Point(imgStartX, imgStartY)); //画删除小圈 if (m_isSetting) { g.CompositingQuality = CompositingQuality.HighQuality; g.SmoothingMode = SmoothingMode.AntiAlias; g.FillEllipse(new SolidBrush(Color.White), new Rectangle(imgStartX, imgStartY-2, 18, 18)); g.FillEllipse(new SolidBrush(Color.Black), new Rectangle(imgStartX + 2, imgStartY, 14, 14)); g.DrawLine(new Pen(Color.White), new Point(imgStartX + 4, imgStartY + 2), new Point(imgStartX + 14, imgStartY + 12)); g.DrawLine(new Pen(Color.White), new Point(imgStartX + 14, imgStartY + 2), new Point(imgStartX + 4, imgStartY + 12)); } //画文字 e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter); }
private void listViewShowItems_Highlight(object sender, DrawListViewItemEventArgs e) { // If this item is the selected item if (e.Item != null) { if (e.Item.Selected) { // If the selected item has focus Set the colors to the normal colors for a selected item e.Item.ForeColor = SystemColors.HighlightText; e.Item.BackColor = SystemColors.Highlight; } else { // Set the normal colors for items that are not selected e.Item.ForeColor = listViewShowItems.ForeColor; e.Item.BackColor = listViewShowItems.BackColor; } e.DrawBackground(); e.DrawText(); } }
private void listObjects_DrawItem(object sender, DrawListViewItemEventArgs e) { e.DrawDefault = false; e.DrawBackground(); e.DrawText(); }
private void listView_DrawItem(object sender, DrawListViewItemEventArgs e) { e.DrawBackground(); e.DrawText(); }
private void lvwRadar_DrawItem(object sender, DrawListViewItemEventArgs e) { ////e.DrawBackground(); ////if (e.ItemIndex < 0) return; ////ListViewItem itemToDraw = lvwRadar.Items[e.ItemIndex]; ////if ((e.State & ListViewItemStates.Selected) != 0) ////{ //// // Draw the background and focus rectangle for a selected item. //// e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds); //// e.DrawFocusRectangle(); ////} ////else ////{ //// // Draw the background for an unselected item. //// using (LinearGradientBrush brush = //// new LinearGradientBrush(e.Bounds, Color.Orange, //// Color.Maroon, LinearGradientMode.Horizontal)) //// { //// e.Graphics.FillRectangle(brush, e.Bounds); //// } ////} ////// Draw the item text for views other than the Details view. ////if (lvwRadar.View != View.Details) ////{ //// e.DrawText(); ////} e.DrawBackground(); ////TextFormatFlags flags = TextFormatFlags.Left; //ListViewItem itemToDraw = lvwRadar.Items[e.ItemIndex]; ////Brush textBrush = null; ////Brush dBrush = null; ////Brush rBrush = null; ////Font boldFont = new Font("Arial", 8, FontStyle.Bold); ////Font regularFont = new Font("Arial", 8, FontStyle.Regular); ////Font italicFont = new Font("Arial", 7, FontStyle.Italic); //if ((e.State & ListViewItemStates.Selected) != 0) //{ // //textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.HighlightText)); // //dBrush = new SolidBrush(Color.Yellow); // e.Graphics.FillRectangle(Brushes.White, e.Bounds); // e.DrawFocusRectangle(); //} //else //{ // //textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.ControlText)); // //dBrush = new SolidBrush(Color.RoyalBlue); // e.Graphics.FillRectangle(Brushes.RoyalBlue, e.Bounds); //} ////float nameX = e.Bounds.Location.X; ////float nameY = e.Bounds.Location.Y; //string name = string.Empty; ////string description = string.Empty; ////string distance = string.Empty; //name = itemToDraw.Name; //if (avtyping.Contains(name)) //{ // //rBrush = new SolidBrush(Color.Red); // //e.Graphics.DrawString(name, regularFont, rBrush, nameX, nameY); //} //else if (client.Self.AgentID == (UUID)itemToDraw.Tag) //{ // //e.Graphics.DrawString(name, boldFont, textBrush, nameX, nameY); // e.Graphics.DrawImage(Properties.Resources.green_orb, e.Bounds.Location); //} //else //{ // //e.Graphics.DrawString(name, regularFont, textBrush, nameX, nameY); //} ////e.Graphics.DrawLine(new Pen(Color.FromArgb(200, 200, 200)), new Point(e.Bounds.Left, e.Bounds.Bottom - 1), new Point(e.Bounds.Right, e.Bounds.Bottom - 1)); //////e.DrawFocusRectangle(); ////boldFont.Dispose(); ////regularFont.Dispose(); ////textBrush.Dispose(); ////boldFont = null; ////regularFont = null; ////textBrush = null; ////dBrush = null; ////rBrush = null; ////e.DrawText(flags); //// Draw the item text for views other than the Details view. //if (lvwRadar.View != View.Details) //{ e.DrawText(); //} }