protected override void OnDrawItem(DrawItemEventArgs e)
    {
        RectangleF tabFill = (RectangleF)GetTabRect(e.Index);

        if (e.Index == SelectedIndex)
        {
            Brush textBrush = new SolidBrush(Color.Black);
            Brush fillBrush = new SolidBrush(Color.White);
            e.Graphics.FillRectangle(fillBrush, tabFill);
            e.Graphics.DrawString(TabPages[e.Index].Text, Font, textBrush, new Point(e.Bounds.X + 5, e.Bounds.Y + 5));
            int offset = (e.Bounds.Height - 16) / 2;
            e.Graphics.DrawImage(Image.FromFile(pathCloseImg), e.Bounds.X + e.Bounds.Width - 20, e.Bounds.Y + offset);
            textBrush.Dispose();
            fillBrush.Dispose();
        }
        else
        {
            Brush textBrush = new SolidBrush(Color.White);
            Brush fillBrush = new SolidBrush(Color.DimGray);
            e.Graphics.FillRectangle(fillBrush, tabFill);
            fillBrush.Dispose();
            e.Graphics.DrawString(TabPages[e.Index].Text, Font, textBrush, new Point(e.Bounds.X + 5, e.Bounds.Y + 3));
            int offset = (e.Bounds.Height - 16) / 2;
            e.Graphics.DrawImage(Image.FromFile(pathCloseImg), e.Bounds.X + e.Bounds.Width - 20, e.Bounds.Y + offset + 2);
            textBrush.Dispose();
            fillBrush.Dispose();
        }
    }
示例#2
0
        protected override void OnDrawItem(object sender, DrawItemEventArgs e)
        {
            Brush textBrush; //Brush for the text

            Rectangle rc = e.Bounds;
            rc.X += DRAW_OFFSET;
            //Check if the item is selected
            if (e.State == DrawItemState.Selected)
            {
                //Highlighted
                e.DrawBackground();
                textBrush = new SolidBrush(SystemColors.HighlightText);
            }
            else
            {
                //Change the background for every even item
                if ((e.Index % 2) == 0)
                {
                    e.DrawBackground(Color.Thistle);
                }
                else
                {

                    e.DrawBackground(this.BackColor);
                }

                textBrush = new SolidBrush(this.ForeColor);
            }

            //Get the ListItem
            ListItem item = (ListItem)this.Items[e.Index];
            //			//Check if the item has a image
            if (item.ImageIndex > -1)
            {
                Image img = imageList.Images[item.ImageIndex];
                if (img != null)
                {
                    imageAttr = new ImageAttributes();
                    //Set the transparency key
                    imageAttr.SetColorKey(BackgroundImageColor(img), BackgroundImageColor(img));
                    //imageAttr.SetColorKey(Color.White, Color.White);
                    //Image's rectangle
                    Rectangle imgRect = new Rectangle(2, rc.Y+1, img.Width, img.Height);
                    //Draw the image
                    e.Graphics.DrawImage(img, imgRect, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imageAttr);
                    //Shift the text to the right
                    rc.X+=img.Width + 2;
                }
            }

            //Draw item's text
            e.Graphics.DrawString(item.Text, e.Font, textBrush,  rc);
            //Draw the line
            e.Graphics.DrawLine(new Pen(Color.Navy), 0, e.Bounds.Bottom, e.Bounds.Width, e.Bounds.Bottom);
            //Call the base's OnDrawEvent
            base.OnDrawItem (sender, e);
        }
示例#3
0
    protected override void OnDrawItem(DrawItemEventArgs e)
    {
        const TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.VerticalCenter;

        e.DrawBackground();
        e.DrawFocusRectangle();

        if (DesignMode)
        {
            e.Graphics.DrawRectangle(Pens.Red, 1, e.Bounds.Y + 1, IMAGE_WIDTH, IMAGE_WIDTH);
            var textRect = e.Bounds;
            textRect.X += IMAGE_WIDTH + 1;
            textRect.Width -= IMAGE_WIDTH + 1;
            string itemText = "AddressListBox";
            TextRenderer.DrawText(e.Graphics, itemText, e.Font, textRect, e.ForeColor, flags);
            e.DrawFocusRectangle();
         }
        else if (e.Index >= 0)
        {
            Library lib = Items[e.Index] as Library;
            if (null == lib) return;

            e.Graphics.DrawImage(lib.Thumbnail, 0, e.Bounds.Y + 1);

            var textRect = e.Bounds;
            textRect.X += IMAGE_WIDTH + 1;
            textRect.Width -= IMAGE_WIDTH + 1;

            Font fontBold = new System.Drawing.Font(e.Font, FontStyle.Bold);

            Rectangle itemRect0 = new Rectangle(textRect.X, textRect.Y, 100, 20);
            TextRenderer.DrawText(e.Graphics, "Name         ", e.Font, itemRect0, e.ForeColor, flags); itemRect0.Y += itemRect0.Height;
            TextRenderer.DrawText(e.Graphics, "Description  ", e.Font, itemRect0, e.ForeColor, flags); itemRect0.Y += itemRect0.Height;
            TextRenderer.DrawText(e.Graphics, "Author       ", e.Font, itemRect0, e.ForeColor, flags); itemRect0.Y += itemRect0.Height;
            TextRenderer.DrawText(e.Graphics, "Date created ", e.Font, itemRect0, e.ForeColor, flags); itemRect0.Y += itemRect0.Height;

            Rectangle itemRect1 = new Rectangle(textRect.X + 100, textRect.Y, 10, 20);
            TextRenderer.DrawText(e.Graphics, ":", e.Font, itemRect1, e.ForeColor, flags); itemRect1.Y += itemRect1.Height;
            TextRenderer.DrawText(e.Graphics, ":", e.Font, itemRect1, e.ForeColor, flags); itemRect1.Y += itemRect1.Height;
            TextRenderer.DrawText(e.Graphics, ":", e.Font, itemRect1, e.ForeColor, flags); itemRect1.Y += itemRect1.Height;
            TextRenderer.DrawText(e.Graphics, ":", e.Font, itemRect1, e.ForeColor, flags); itemRect1.Y += itemRect1.Height;

            Rectangle itemRect2 = new Rectangle(textRect.X + 110, textRect.Y, textRect.Width - 110, 20);
            TextRenderer.DrawText(e.Graphics, lib.Name, fontBold, itemRect2, e.ForeColor, flags); itemRect2.Y += itemRect2.Height;
            TextRenderer.DrawText(e.Graphics, lib.Description, e.Font, itemRect2, e.ForeColor, flags); itemRect2.Y += itemRect2.Height;
            TextRenderer.DrawText(e.Graphics, lib.Author, e.Font, itemRect2, e.ForeColor, flags); itemRect2.Y += itemRect2.Height;
            TextRenderer.DrawText(e.Graphics, lib.DateCreated.ToShortDateString(), e.Font, itemRect2, e.ForeColor, flags); itemRect2.Y += itemRect2.Height;
       }
    }
示例#4
0
    protected override void OnDrawItem(DrawItemEventArgs e)
    {
        G = e.Graphics;

        Rect = e.Bounds;

        using (SolidBrush Back = new SolidBrush(Color.FromArgb(34, 34, 33)))
        {
            G.FillRectangle(Back, new Rectangle(e.Bounds.X - 4, e.Bounds.Y - 1, e.Bounds.Width + 4, e.Bounds.Height + 1));
        }

        if (!(e.Index == -1))
        {
            using (Font ItemsFont = new Font("Segoe UI", 9))
            {
                using (Pen Border = new Pen(Color.FromArgb(38, 38, 37)))
                {

                    if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                    {
                        using (SolidBrush HoverItemBrush = new SolidBrush(Color.FromArgb(220, 220, 220)))
                        {
                            using (SolidBrush HoverItemFill = new SolidBrush(Color.FromArgb(38, 38, 37)))
                            {
                                G.FillRectangle(HoverItemFill, new Rectangle(Rect.X - 1, Rect.Y + 2, Rect.Width + 1, Rect.Height - 4));
                                G.DrawString(GetItemText(Items[e.Index]), new Font("Segoe UI", 9), HoverItemBrush, new Point(Rect.X + 5, Rect.Y + 1));
                            }
                        }

                    }
                    else
                    {
                        using (SolidBrush DefaultItemBrush = new SolidBrush(Color.FromArgb(220, 220, 220)))
                        {
                            G.DrawString(GetItemText(Items[e.Index]), new Font("Segoe UI", 9), DefaultItemBrush, new Point(Rect.X + 5, Rect.Y + 1));
                        }

                    }

                }
            }

        }

        base.OnDrawItem(e);
    }
示例#5
0
 private void cboDbType_DrawItem(object sender, DrawItemEventArgs e)
 {
     e.DrawBackground();
     e.DrawFocusRectangle();
     if (e.Index >= 0)
     {
         string s = this.cboDbType.Items[e.Index].ToString();
         if ((((s == "DateTime") || (s == "Currency")) || ((s == "Int32") || (s == "String"))) || (s == "AnsiStringFixedLength"))
         {
             e.Graphics.DrawString(s, e.Font, Brushes.Red, e.Bounds);
         }
         else
         {
             e.Graphics.DrawString(s, e.Font, new SolidBrush(e.ForeColor), e.Bounds);
         }
     }
 }
    protected override void OnDrawItem(DrawItemEventArgs e)
    {
        try
        {

            using (var _textBrush = new SolidBrush(this.ForeColor))
            {
                this.Alignment = Alineacion;

                TabPage _tabPage = this.TabPages[e.Index];
                Rectangle _tabBounds = this.GetTabRect(e.Index);
                Brush _TextBrush;

                if (e.State != DrawItemState.Selected)
                {
                    e.DrawBackground();
                    _TextBrush = new System.Drawing.SolidBrush(e.ForeColor);

                }

                else
                {
                    using (var brush = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, gradient1, gradient2, 90f))
                    {
                        e.Graphics.FillRectangle(brush, e.Bounds);
                        _TextBrush = new SolidBrush(Color.White);
                    }
                }

                Font _TabFont = new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Pixel);

                StringFormat _stringFlags = new StringFormat();
                _stringFlags.Alignment = StringAlignment.Center;
                _stringFlags.LineAlignment = StringAlignment.Center;

                e.Graphics.DrawString(_tabPage.Text, _TabFont, _TextBrush, _tabBounds, new StringFormat(_stringFlags));
            }
        }

        catch { }
    }
示例#7
0
 protected override void OnDrawItem(object sender, DrawItemEventArgs e)
 {
     Brush textBrush; //Brush for the text
     Rectangle rc = e.Bounds;
     rc.X += DRAW_OFFSET;
     //Check if the item's selected
     if (e.State == DrawItemState.Selected)
     {
         e.DrawBackground(Color.DarkKhaki);
         rc.X+=1;
         rc.Y+=1;
     }
     textBrush = new SolidBrush(SystemColors.ControlText);
     //Draw item's text
     e.Graphics.DrawString(this.Items[e.Index].ToString(), e.Font, textBrush,  rc);
     //Draw a 3D line underneath
     e.Graphics.DrawLine(new Pen(Color.White), 0, e.Bounds.Bottom-1, e.Bounds.Width, e.Bounds.Bottom-1);
     e.Graphics.DrawLine(new Pen(Color.Gray), 0, e.Bounds.Bottom, e.Bounds.Width, e.Bounds.Bottom);
     //Call the base's OnDrawEvent
     base.OnDrawItem (sender, e);
 }
示例#8
0
   protected override void OnDrawItem(DrawItemEventArgs itemEventArgs)
   {
      itemEventArgs.DrawBackground();
      itemEventArgs.DrawFocusRectangle();

      ComboBoxExItem item;
      System.Drawing.Size imageSize = m_ImageList.ImageSize;
      System.Drawing.Rectangle bounds = itemEventArgs.Bounds;

      try
      {
         item = (ComboBoxExItem)Items[itemEventArgs.Index];

         if(item.ImageIndex != -1)
         {
            m_ImageList.Draw(itemEventArgs.Graphics,bounds.Left,bounds.Top,item.ImageIndex);

            itemEventArgs.Graphics.DrawString(item.Text,itemEventArgs.Font,new SolidBrush(itemEventArgs.ForeColor),bounds.Left+imageSize.Width,bounds.Top);
         }
         else
         {
            itemEventArgs.Graphics.DrawString(item.Text,itemEventArgs.Font,new SolidBrush(itemEventArgs.ForeColor),bounds.Left,bounds.Top);
         }
      }
      catch
      {
         if(itemEventArgs.Index != -1)
         {
            itemEventArgs.Graphics.DrawString(Items[itemEventArgs.Index].ToString(),itemEventArgs.Font,new SolidBrush(itemEventArgs.ForeColor),bounds.Left,bounds.Top);
         }
         else
         {
            itemEventArgs.Graphics.DrawString(Text,itemEventArgs.Font,new SolidBrush(itemEventArgs.ForeColor),bounds.Left,bounds.Top);
         }
      }
      base.OnDrawItem(itemEventArgs);
   }
示例#9
0
 private void Listbox_BeforeDrawItem(object sender, ListBox.ObjectCollection items, DrawItemEventArgs e)
 {
     if (Items.Count != LastCount)
     {
         listbox.SetScrollInfo();
         LastCount = Items.Count;
         ItemsCountChange?.Invoke(this, null);
     }
 }
示例#10
0
        // 绘制下拉框的内容
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);

            if (DesignMode)
            {
                return;
            }
            Rectangle boundsRect = e.Bounds;//获取绘制项边界的矩形

            e.Graphics.FillRectangle(Brushes.White, e.Bounds);
            if (e.State == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(Brushes.White, e.Bounds);
            }

            //第一行为表头,设置颜色
            if (e.Index == 0)
            {
                for (int i = 0; i < columnNames.Length; i++)
                {
                    SolidBrush brush     = new SolidBrush(Color.FromArgb(127, 128, 0)); //定义画刷
                    Rectangle  rect      = e.Bounds;
                    Rectangle  rectColor = new Rectangle(rect.Location, new Size(rect.Width, rect.Height));
                    e.Graphics.FillRectangle(brush, rectColor);   //填充颜色
                }
            }


            int lastRight = 0;

            using (Pen linePen = new Pen(SystemColors.GrayText))
            {
                using (SolidBrush brush = new SolidBrush(ForeColor))
                {
                    if (columnNames.Length == 0)
                    {
                        e.Graphics.DrawString(Convert.ToString(Items[e.Index]), Font, brush, boundsRect);
                    }
                    else
                    {
                        //循环各列
                        for (int i = 0; i < columnNames.Length; i++)
                        {
                            string item = Convert.ToString(FilterItemOnProperty(Items[e.Index], columnNames[i]));
                            boundsRect.X     = lastRight;                            //列的左边位置
                            boundsRect.Width = (int)columnWidths[i] + columnPadding; //列的宽度
                            lastRight        = boundsRect.Right;

                            if (i == valueMemberColumnIndex)//如果是valuemember
                            {
                                using (Font font = new Font(Font, FontStyle.Bold))
                                {
                                    //绘制项的内容
                                    e.Graphics.DrawString(item, font, brush, boundsRect);
                                }
                            }
                            else
                            {
                                //绘制项的内容
                                e.Graphics.DrawString(item, Font, brush, boundsRect);
                            }

                            //绘制各项间的竖线
                            if (i < columnNames.Length - 1)
                            {
                                e.Graphics.DrawLine(linePen, boundsRect.Right, boundsRect.Top, boundsRect.Right, boundsRect.Bottom);
                            }
                        }
                        e.Graphics.DrawLine(linePen, boundsRect.Right, boundsRect.Top, boundsRect.Right, boundsRect.Bottom);
                    }


                    //绘制各行间横线
                    int hh = 0; //起点高度为0
                    using (SolidBrush brush2 = new SolidBrush(ForeColor))
                    {
                        if (this.Items.Count == 0)
                        {
                            e.Graphics.DrawString(Convert.ToString(Items[e.Index]), Font, brush2, boundsRect);
                        }
                        else
                        {
                            //循环各列
                            for (int i = 0; i < this.Items.Count; i++)
                            {
                                boundsRect.X = 0;
                                int h = (int)ItemHeight;   //第一次绘制的高度
                                hh += h;
                                for (int j = 0; j < columnNames.Length; j++)
                                {
                                    if (i < columnNames.Length - 1)
                                    {
                                        if (i < columnNames.Length - 1)
                                        {
                                            e.Graphics.DrawLine(linePen, boundsRect.Left, hh, boundsRect.Right * 6, hh);
                                        }
                                    }
                                }
                                e.Graphics.DrawLine(linePen, boundsRect.Left, boundsRect.Bottom, boundsRect.Right, boundsRect.Bottom);
                            }
                        }
                    }
                    e.DrawFocusRectangle();
                }
            }
        }
示例#11
0
 private void sListBox1_DrawItem(object sender, DrawItemEventArgs e)
 {
 }
示例#12
0
 // Method:      lst_DrawItem()
 // Description: This method parts item in multiple if their width is bigger than
 //              listbox width
 // Reference:   https://stackoverflow.com/questions/17613613/winforms-dotnet-listbox-items-to-word-wrap-if-content-string-width-is-bigger-tha
 private void lst_DrawItem(object sender, DrawItemEventArgs e)
 {
     e.DrawBackground();
     e.DrawFocusRectangle();
     e.Graphics.DrawString(ChatHistory.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds);
 }
    /// <summary>
    /// Performs custom painting for a list item.
    /// </summary>
    /// <param name="e"></param>
    protected override void OnDrawItem(DrawItemEventArgs e)
    {
        base.OnDrawItem(e);

        if ((e.Index >= 0) && (e.Index < Items.Count))
        {
            // get noteworthy states
            bool comboBoxEdit  = (e.State & DrawItemState.ComboBoxEdit) == DrawItemState.ComboBoxEdit;
            bool selected      = (e.State & DrawItemState.Selected) == DrawItemState.Selected;
            bool noAccelerator = (e.State & DrawItemState.NoAccelerator) == DrawItemState.NoAccelerator;
            bool disabled      = (e.State & DrawItemState.Disabled) == DrawItemState.Disabled;
            bool focus         = (e.State & DrawItemState.Focus) == DrawItemState.Focus;

            // determine grouping
            string groupText;
            bool   isGroupStart = IsGroupStart(e.Index, out groupText) && !comboBoxEdit;
            bool   hasGroup     = (groupText != String.Empty) && !comboBoxEdit;

            // the item text will appear in a different colour, depending on its state
            Color textColor;
            if (disabled)
            {
                textColor = SystemColors.GrayText;
            }
            else if (!comboBoxEdit && selected)
            {
                textColor = SystemColors.HighlightText;
            }
            else
            {
                textColor = ForeColor;
            }

            // items will be indented if they belong to a group
            Rectangle itemBounds = Rectangle.FromLTRB(
                e.Bounds.X + (hasGroup ? 12 : 0),
                e.Bounds.Y + (isGroupStart ? (e.Bounds.Height / 2) : 0),
                e.Bounds.Right,
                e.Bounds.Bottom
                );
            Rectangle groupBounds = new Rectangle(
                e.Bounds.X,
                e.Bounds.Y,
                e.Bounds.Width,
                e.Bounds.Height / 2
                );

            if (isGroupStart && selected)
            {
                // ensure that the group header is never highlighted
                e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
                e.Graphics.FillRectangle(new SolidBrush(BackColor), groupBounds);
            }
            else if (disabled)
            {
                // disabled appearance
                e.Graphics.FillRectangle(Brushes.WhiteSmoke, e.Bounds);
            }
            else if (!comboBoxEdit)
            {
                // use the default background-painting logic
                e.DrawBackground();
            }

            // render group header text
            if (isGroupStart)
            {
                TextRenderer.DrawText(
                    e.Graphics,
                    groupText,
                    _groupFont,
                    groupBounds,
                    ForeColor,
                    _textFormatFlags
                    );
            }

            // render item text
            TextRenderer.DrawText(
                e.Graphics,
                GetItemText(Items[e.Index]),
                Font,
                itemBounds,
                textColor,
                _textFormatFlags
                );

            // paint the focus rectangle if required
            if (focus && !noAccelerator)
            {
                if (isGroupStart && selected)
                {
                    // don't draw the focus rectangle around the group header
                    ControlPaint.DrawFocusRectangle(e.Graphics, Rectangle.FromLTRB(groupBounds.X, itemBounds.Y, itemBounds.Right, itemBounds.Bottom));
                }
                else
                {
                    // use default focus rectangle painting logic
                    e.DrawFocusRectangle();
                }
            }
        }
    }
示例#14
0
	/// <summary>
	/// Performs custom painting for a list item.
	/// </summary>
	/// <param name="e"></param>
	protected override void OnDrawItem(DrawItemEventArgs e) {
		base.OnDrawItem(e);

		if ((e.Index >= 0) && (e.Index < Items.Count)) {
			// get noteworthy states
			bool comboBoxEdit = (e.State & DrawItemState.ComboBoxEdit) == DrawItemState.ComboBoxEdit;
			bool selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected;
			bool noAccelerator = (e.State & DrawItemState.NoAccelerator) == DrawItemState.NoAccelerator;
			bool disabled = (e.State & DrawItemState.Disabled) == DrawItemState.Disabled;
			bool focus = (e.State & DrawItemState.Focus) == DrawItemState.Focus;

			// determine grouping
			string groupText;
			bool isGroupStart = IsGroupStart(e.Index, out groupText) && !comboBoxEdit;
			bool hasGroup = (groupText != String.Empty) && !comboBoxEdit;

			// the item text will appear in a different colour, depending on its state
			Color textColor;
			if (disabled)
				textColor = SystemColors.GrayText;
			else if (!comboBoxEdit && selected)
				textColor = SystemColors.HighlightText;
			else
				textColor = ForeColor;

			// items will be indented if they belong to a group
			Rectangle itemBounds = Rectangle.FromLTRB(
				e.Bounds.X + (hasGroup ? 12 : 0), 
				e.Bounds.Y + (isGroupStart ? (e.Bounds.Height / 2) : 0), 
				e.Bounds.Right, 
				e.Bounds.Bottom
			);
			Rectangle groupBounds = new Rectangle(
				e.Bounds.X, 
				e.Bounds.Y, 
				e.Bounds.Width, 
				e.Bounds.Height / 2
			);

			if (isGroupStart && selected) {
				// ensure that the group header is never highlighted
				e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
				e.Graphics.FillRectangle(new SolidBrush(BackColor), groupBounds);
			}
            else if (disabled) {
                // disabled appearance
                e.Graphics.FillRectangle(Brushes.WhiteSmoke, e.Bounds);
            }
            else if (!comboBoxEdit) {
                // use the default background-painting logic
                e.DrawBackground();
            }

			// render group header text
			if (isGroupStart) TextRenderer.DrawText(
				e.Graphics, 
				groupText, 
				_groupFont, 
				groupBounds, 
				ForeColor, 
				_textFormatFlags
			);

			// render item text
			TextRenderer.DrawText(
				e.Graphics, 
				GetItemText(Items[e.Index]), 
				Font, 
				itemBounds, 
				textColor, 
				_textFormatFlags
			);

			// paint the focus rectangle if required
			if (focus && !noAccelerator) {
				if (isGroupStart && selected) {
					// don't draw the focus rectangle around the group header
					ControlPaint.DrawFocusRectangle(e.Graphics, Rectangle.FromLTRB(groupBounds.X, itemBounds.Y, itemBounds.Right, itemBounds.Bottom));
				}
				else {
					// use default focus rectangle painting logic
					e.DrawFocusRectangle();
				}
			}
		}
	}
 private bool DrawItem_Item(DrawItemEventArgs e, WFNew.BaseItemState eBaseItemState, WinForm.IItem item)
 {
     if (item == null)
     {
         return(false);
     }
     //
     if (this.ShowGripRegion)
     {
         #region ShowGripRegionT
         GISShare.Controls.WinForm.WinFormRenderer.WinFormRendererStrategy.OnRenderItem
         (
             new ItemRenderEventArgs
             (
                 e.Graphics,
                 item,
                 this,
                 this.GetItemCheckState(e.Index),
                 eBaseItemState,
                 new Rectangle(e.Bounds.X, e.Bounds.Y, this.LeftGripRegionWidth, e.Bounds.Height),
                 new Rectangle(e.Bounds.X, e.Bounds.Y, this.LeftGripRegionWidth + this.ItemHeight + CTR_IMAGEGRIPSEPARATORWIDTH, e.Bounds.Height),
                 Rectangle.FromLTRB(e.Bounds.Left + this.LeftGripRegionWidth + this.ItemHeight + CTR_IMAGEGRIPSEPARATORWIDTH, e.Bounds.Top, e.Bounds.Right, e.Bounds.Bottom),
                 e.Bounds
             )
         );
         //
         int       iH        = (int)e.Graphics.MeasureString(item.Text, e.Font).Height;// (int)(e.Graphics.MeasureString(item.Text, item.Font).Height + 1);
         Rectangle rectangle = new Rectangle
                               (
             e.Bounds.Left + this.LeftGripRegionWidth + this.ItemHeight + CTR_IMAGEGRIPSEPARATORWIDTH + this.ITSpace,
             (e.Bounds.Top + e.Bounds.Bottom - iH) / 2 + 2,
             e.Bounds.Width - this.LeftGripRegionWidth - this.ItemHeight - CTR_IMAGEGRIPSEPARATORWIDTH - this.ITSpace,
             iH
                               );
         GISShare.Controls.WinForm.WinFormRenderer.WinFormRendererStrategy.OnRenderText
         (
             new GISShare.Controls.WinForm.TextRenderEventArgs(e.Graphics, this, this.Enabled, false, item.Text, e.ForeColor, e.Font, rectangle)
         );
         #endregion
     }
     else
     {
         #region ShowGripRegionF
         GISShare.Controls.WinForm.WinFormRenderer.WinFormRendererStrategy.OnRenderItem
         (
             new ItemRenderEventArgs
                 (e.Graphics,
                 item,
                 this,
                 this.GetItemCheckState(e.Index),
                 eBaseItemState,
                 new Rectangle(e.Bounds.X, e.Bounds.Y, this.LeftGripRegionWidth, e.Bounds.Height),
                 new Rectangle(e.Bounds.X, e.Bounds.Y, this.LeftGripRegionWidth, e.Bounds.Height),
                 Rectangle.FromLTRB(e.Bounds.Left + this.LeftGripRegionWidth, e.Bounds.Top, e.Bounds.Right, e.Bounds.Bottom),
                 e.Bounds
                 )
         );
         //
         int       iH        = (int)e.Graphics.MeasureString(item.Text, e.Font).Height;// (int)(e.Graphics.MeasureString(item.Text, item.Font).Height + 1);
         Rectangle rectangle = new Rectangle
                               (
             e.Bounds.Left + this.LeftGripRegionWidth,
             (e.Bounds.Top + e.Bounds.Bottom - iH) / 2 + 2,
             e.Bounds.Width - this.LeftGripRegionWidth,
             iH
                               );
         GISShare.Controls.WinForm.WinFormRenderer.WinFormRendererStrategy.OnRenderText
         (
             new GISShare.Controls.WinForm.TextRenderEventArgs(e.Graphics, this, this.Enabled, false, item.Text, e.ForeColor, e.Font, rectangle)
         );
         #endregion
     }
     //
     return(true);
 }
 private void OnDItem(object Sender, DrawItemEventArgs e)
 {
     this.ODrawItem(e);
 }
示例#17
0
 //DrawItem event handler for your ListBox
 private void lst_shell_DrawItem(object sender, DrawItemEventArgs e)
 {
     e.DrawBackground();
     e.Graphics.DrawString(lst_shell.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds);
 }
示例#18
0
        private void LB_DrawItem(object sender, DrawItemEventArgs e)
        {
            bool selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected;

            if (e.Index == -1)
            {
                return;
            }


            object li = FontListbox.Items[e.Index];
            string text = li.ToString();
            Brush  bg, fg;

            if (selected)
            {
                bg = SystemBrushes.Highlight;
                fg = SystemBrushes.HighlightText;
                //fg=Brushes.Black;
            }
            else
            {
                bg = SystemBrushes.Window;
                fg = SystemBrushes.WindowText;
            }

            //e.Graphics.FillRectangle (SystemBrushes.Window,0,e.Bounds.Top,e.Bounds.Width ,FontListbox.ItemHeight);
            if (selected)
            {
                int ofs = 37;
                e.Graphics.FillRectangle(SystemBrushes.Window, new Rectangle(ofs, e.Bounds.Top, e.Bounds.Width - ofs, FontListbox.ItemHeight));
                e.Graphics.FillRectangle(SystemBrushes.Highlight, new Rectangle(ofs + 1, e.Bounds.Top + 1, e.Bounds.Width - ofs - 2, FontListbox.ItemHeight - 2));
                System.Windows.Forms.ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(ofs, e.Bounds.Top, e.Bounds.Width - ofs, FontListbox.ItemHeight));
            }
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, 0, e.Bounds.Top, e.Bounds.Width, FontListbox.ItemHeight);
            }


            e.Graphics.DrawString(text, e.Font, fg, 38, e.Bounds.Top + 4);

            e.Graphics.SetClip(new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4));


            e.Graphics.FillRectangle(SystemBrushes.Highlight, new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4));

            IntPtr  hdc = e.Graphics.GetHdc();
            GDIFont gf  = new GDIFont(text, 9);
            int     a   = 0;
            IntPtr  res = NativeMethods.SelectObject(hdc, gf.hFont);

            NativeMethods.SetTextColor(hdc, ColorTranslator.ToWin32(SystemColors.Window));
            NativeMethods.SetBkMode(hdc, 0);
            NativeMethods.TabbedTextOut(hdc, 3, e.Bounds.Top + 5, "abc", 3, 0, ref a, 0);
            NativeMethods.SelectObject(hdc, res);
            gf.Dispose();
            e.Graphics.ReleaseHdc(hdc);
            e.Graphics.DrawRectangle(Pens.Black, new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4));
            e.Graphics.ResetClip();
        }
示例#19
0
        /// <summary>
        /// Draw a color entry.
        /// </summary>
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            int idx = e.Index;

            // Nothing selected?
            if (idx < 0)
            {
                return;
            }

            object obj = Items[idx];

            if (obj is ColorItem)
            {
                ColorItem item = (ColorItem)obj;

                // Is custom color?
                if (idx == 0)
                {
                    string name;
                    if (_color.IsEmpty)
                    {
                        name = "custom";
                    }
                    else
                    {
                        name = _crm.ToColorName(_color);
                    }

                    item = new ColorItem(_color, name);
                }

                XColor    clr       = item.Color;
                Graphics  gfx       = e.Graphics;
                Rectangle rect      = e.Bounds;
                Brush     textbrush = SystemBrushes.ControlText;
                if ((e.State & DrawItemState.Selected) == 0)
                {
                    gfx.FillRectangle(SystemBrushes.Window, rect);
                    textbrush = SystemBrushes.ControlText;
                }
                else
                {
                    gfx.FillRectangle(SystemBrushes.Highlight, rect);
                    textbrush = SystemBrushes.HighlightText;
                }

                // Draw color box
                if (!clr.IsEmpty)
                {
                    Rectangle box = new Rectangle(rect.X + 3, rect.Y + 1, rect.Height * 2, rect.Height - 3);
                    gfx.FillRectangle(new SolidBrush(clr.ToGdiColor()), box);
                    gfx.DrawRectangle(Pens.Black, box);
                }

                StringFormat format = new StringFormat(StringFormat.GenericDefault);
                format.Alignment     = StringAlignment.Near;
                format.LineAlignment = StringAlignment.Center;
                rect.X += rect.Height * 2 + 3 + 3;
                gfx.DrawString(item.Name, Font, textbrush, rect, format);
            }
        }
示例#20
0
 protected override void OnDrawItem(DrawItemEventArgs e)
 {
     Assert.Fail("OnDrawItem");
 }
示例#21
0
 void test_drawevent(object sender, DrawItemEventArgs e)
 {
     event_reached = true;
 }
示例#22
0
		protected override void OnDrawItem(object sender, DrawItemEventArgs e)
		{
			Brush textBrush; //Brush for the text
			ListItem item; 
   
			Rectangle rc = e.Bounds;
			rc.X += DRAW_OFFSET;


			//Get the ListItem
			if ((e.Index > -1) && (e.Index < itemList.Count))
				item = (ListItem)itemList[e.Index];
			else 
				return;


			//Check if the item is selected
			if (e.State == DrawItemState.Selected)
			{
				//Highlighted
				e.DrawBackground();
				textBrush = new SolidBrush(SystemColors.HighlightText);
			}
			else
			{
				
				//Change the background for every even item
				if ((e.Index % 2) == 0)
				{
					e.DrawBackground(colorEvenItem);
				}
				else
				{
					e.DrawBackground(this.BackColor);
				}
				

				if (this.BackgroundImage != null) // don't do back ground if there is back image
				{
					Rectangle rcImage = Rectangle.Empty;
					if (showLines)
						rcImage = new Rectangle(0, rc.Y + 1,  this.Width, rc.Height - 1);
					else
						rcImage = new Rectangle(0, rc.Y,  this.Width, rc.Height);

					e.Graphics.DrawImage(BackgroundImage, 0, rc.Y + 1, rcImage, GraphicsUnit.Pixel);
				}
						
				textBrush = new SolidBrush(item.ForeColor);
			}
			
			
			//			//Check if the item has a image
			if ((item.ImageIndex > -1) && (imageList != null))
			{
				Image img = imageList.Images[item.ImageIndex];
				if (img != null)
				{
					imageAttr = new ImageAttributes();
					//Set the transparency key
					imageAttr.SetColorKey(BackgroundImageColor(img), BackgroundImageColor(img));
					//Image's rectangle
					Rectangle imgRect = new Rectangle(2, rc.Y + 2, img.Width, img.Height);
					//Draw the image
					e.Graphics.DrawImage(img, imgRect, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imageAttr); 
					//Shift the text to the right
					rc.X+=img.Width + 4;
				}
			}
			
			//Draw item's text
			if (wrapText)
				e.Graphics.DrawString(item.Text, item.Font, textBrush,  rc);
			else
			{
				//center the text vertically
				SizeF size = e.Graphics.MeasureString(item.Text, item.Font);
				Rectangle rcText = new Rectangle(rc.X, rc.Y + (rc.Height - (int)size.Height)/2, rc.Width, (int)size.Height);
				e.Graphics.DrawString(item.Text, item.Font, textBrush,  rcText);
			}

			if (textBrush!=null)
				textBrush.Dispose();
			//Draw the line
			if (showLines)
				e.Graphics.DrawLine(penLine, 0, e.Bounds.Bottom, e.Bounds.Width, e.Bounds.Bottom);
			//Call the base's OnDrawEvent	
			//MessageBox.Show(e.Index.ToString() + " " + item.Text);

			base.OnDrawItem (sender, e);
		}
示例#23
0
		protected override void OnDrawItem(object sender, DrawItemEventArgs e)
		{
			Brush textBrush; //Brush for the text
			SmartListItem item; 
   
			Rectangle rc = e.Bounds;
			int autoNum = (int)rc.Y / rc.Height + 1;

			//int autoNum = e.Index + 1;

			rc.X += DRAW_OFFSET;

			//Get the SmartListItem
			if ((e.Index > -1) && (e.Index < itemList.Count))
				item = (SmartListItem)itemList[e.Index];
			else 
				return;


			//Check if the item is selected
			if (e.State == DrawItemState.Selected)
			{
				//Highlighted
				e.DrawBackground();
				textBrush = new SolidBrush(SystemColors.HighlightText);
			}
			else
			{
				

				if (this.BackgroundImage != null) // don't do background if there is back image
				{
					Rectangle rcImage = Rectangle.Empty;
					if (showLines)
						rcImage = new Rectangle(0, rc.Y + 1,  this.Width, rc.Height - 1);
					else
						rcImage = new Rectangle(0, rc.Y,  this.Width, rc.Height);

					e.Graphics.DrawImage(BackgroundImage, 1, rc.Y + 1, rcImage, GraphicsUnit.Pixel);
				}
				else
				{
					//Change the background for every even item
					if ((e.Index % 2) == 0)
					{
						e.DrawBackground(colorEvenItem);
					}
					else
					{
						e.DrawBackground(this.BackColor);
					}
					
				}
					
				textBrush = new SolidBrush(item.ForeColor);
			}
			
			int numberShift = 0;
			SizeF numSize = SizeF.Empty;

			if (autoNumbering)
			{
				numSize = e.Graphics.MeasureString("22", item.Font);
				numberShift = (int)numSize.Width + 4;

			}
			
			///Check if the item has a image
			if ((item.ImageIndex > -1) && (imageList != null))
			{
				Image img = imageList.Images[item.ImageIndex];
				if (img != null)
				{
					imageAttr = new ImageAttributes();
					//Set the transparency key
					imageAttr.SetColorKey(BackgroundImageColor(img), BackgroundImageColor(img));
					//Image's rectangle
					Rectangle imgRect = Rectangle.Empty;
					
					imgRect = new Rectangle(2 + numberShift, rc.Y + 2, img.Width, img.Height);
					//Draw the image
					e.Graphics.DrawImage(img, imgRect, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imageAttr); 
					//Shift the text to the right
					rc.X+=img.Width + 2;
				}
			}
			//			

			if (autoNumbering)
			{				
				e.Graphics.DrawString(autoNum.ToString(), item.Font, textBrush,  6, rc.Top + (rc.Height - (int)numSize.Height)/2);
				rc.X+=numberShift;
			}
			//Draw item's text
			if (wrapText)
				e.Graphics.DrawString(item.Text, item.Font, textBrush,  rc);
			else
			{
				//center the text vertically
				SizeF size = e.Graphics.MeasureString(item.Text, item.Font);
				Rectangle rcText = Rectangle.Empty;

				
				rcText = new Rectangle(rc.X, rc.Y + (rc.Height - (int)size.Height)/2, rc.Width - rc.X - 3, (int)size.Height);
				
				string itemText = ShortString(item, e, rcText.Width);


				if (selected > 0)
					DrawTextSelected(e.Graphics, item, itemText, textBrush, 0, selected, rcText, e.State); 
				else
					e.Graphics.DrawString(itemText, item.Font, textBrush,  rcText);

			}

			//Draw the line
			if (showLines)
				e.Graphics.DrawLine(penLine, 0, e.Bounds.Bottom, e.Bounds.Width, e.Bounds.Bottom);
		
			textBrush.Dispose();

			//Call the base's OnDrawEvent	
			base.OnDrawItem (sender, e);
		}
 protected virtual bool DrawItemEx(DrawItemEventArgs e, WFNew.BaseItemState eBaseItemState, object item)
 {
     return(false);
 }
		private void PaintItem(Graphics graphics, int Index)
		{
			//			MeasureItemEventArgs measArgs = new MeasureItemEventArgs(graphics, Index, itemHeight);
			//			
			//			//Raise MeasureItemEvent
			//			if (drawMode == DrawMode.OwnerDrawVariable)
			//			{	
			//				OnMeasureItem(this, measArgs);
			//			}
			//			
			//			this.itemHeight = measArgs.ItemHeight;

			//check if it's valid 
			if (BaseItems.Count - 1 < Index)
				return;

			Rectangle itemRect = new Rectangle(0, (Index-topIndex)*this.itemHeight, itemWidth, this.itemHeight);	

			//graphics.Clip = new Region(itemRect);

			DrawItemState state;

			//Set the appropriate selected state
			if (Index ==  selectedIndex)
				state = DrawItemState.Selected;
			else
				state = DrawItemState.None;

			//Prepare Args
			DrawItemEventArgs drawArgs = new DrawItemEventArgs(graphics, this.Font, itemRect, Index, state);
			//Raise drawing event for inheritors
			OnDrawItem(this, drawArgs);
	
		}
示例#26
0
        protected Rectangle GetNoteTextRect(DrawItemEventArgs e, Note note, Font font)
        {
            int noteHeight = e.Graphics.MeasureString(note.Text, font, e.Bounds.Width).ToSize().Height;

            return(new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, noteHeight));
        }
        protected void ODrawItem(DrawItemEventArgs e)
        {
            Rectangle rect = e.Bounds;
            Graphics  g    = e.Graphics;

            //DDL fix
            if (e.Index == -1)
            {
                return;
            }

            //ClearType
            try
            {
                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }

            if (_palette == null)
            {
                EventArgs Ev = new EventArgs();
                ThisGlobalPaletteChanged(this, Ev);
            }

            //set colors
            if (_persistentColors == false)
            {
                //init color values
                if (_useStyledColors == true)
                {
                    _gradientStartColor = Color.FromArgb(255, 246, 215);
                    _gradientEndColor   = Color.FromArgb(255, 213, 77);
                }
                else
                {
                    _gradientStartColor = _palette.ColorTable.StatusStripGradientBegin;
                    _gradientEndColor   = _palette.ColorTable.OverflowButtonGradientEnd;
                }
            }

            //BackColors
            Color gradStartColor = _gradientStartColor;
            Color gradEndColor   = _gradientEndColor;
            Color textColor      = _palette.ColorTable.StatusStripText;

            // Retrieve the item font. If the item font has not been set,
            // use the ComboBox font.
            Font itemFont = e.Font;

            if (itemFont == null)
            {
                itemFont = this.Font;
            }

            // Draw the background of the item.
            e.DrawBackground();

            // Draw each string in the array, using a different size, color,
            // and font for each item.

            string str = (string)this.Items[e.Index];

            if (!Enabled)
            {
                e.Graphics.DrawString(str, itemFont, new SolidBrush(SystemColors.GrayText), e.Bounds);
            }
            else
            {
                e.Graphics.DrawString(str, itemFont, new SolidBrush(this.ForeColor), e.Bounds);
            }

            if ((e.State & DrawItemState.Selected) != 0)
            {
                //DrawingMethods.DrawBlendGradient(e.Graphics, e.Bounds, gradStartColor, gradEndColor, gradMiddleColor, 90F);
                DrawingMethods.DrawGradient(g, e.Bounds, gradStartColor, gradEndColor, 90F, false, Color.White, 0);
                e.Graphics.DrawString(str, itemFont, new SolidBrush(textColor), e.Bounds);
                e.DrawFocusRectangle();
            }

            // Draw the focus rectangle if the mouse hovers over an item.
            e.DrawFocusRectangle();
        }
示例#28
0
        protected Rectangle GetDescriptionRect(DrawItemEventArgs e, Rectangle noteRect, string description, Font font)
        {
            int descriptionHeight = e.Graphics.MeasureString(description, font, e.Bounds.Width).ToSize().Height;

            return(new Rectangle(noteRect.X, noteRect.Bottom, e.Bounds.Width, descriptionHeight));
        }
示例#29
0
 private void LB_FacilityIndex_DrawItem(object sender, DrawItemEventArgs e)
 {
     e.DrawBackground();
     e.Graphics.DrawString(((ListBox)sender).Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), new RectangleF(e.Bounds.X, e.Bounds.Y + (e.Bounds.Height - 12 >> 1), e.Bounds.Width, 12));
     e.DrawFocusRectangle();
 }
示例#30
0
		// This methos will shorten a long string to the desired width and add "..."
		private string ShortString(SmartListItem item, DrawItemEventArgs e, int desWidth)
		{
			SizeF size = e.Graphics.MeasureString(item.Text, e.Font);
			SizeF p_size = e.Graphics.MeasureString("...", e.Font);

			string tempString = item.Text;

			if (size.Width > desWidth)
			{
				//get the new width
				int nWidth = desWidth - (int)p_size.Width;
				//get the desired string
				char[] textChars = item.Text.ToCharArray();
				tempString = "";
				tempString += textChars[0].ToString();
				int nPos = 0;

				for(int i=1;i<textChars.Length;i++)
				{
					SizeF tempSize = e.Graphics.MeasureString(tempString, e.Font);
					if (tempSize.Width >= nWidth)
					{
						nPos = tempString.Length;
						break;
					}
					else
					{
						tempString += textChars[i].ToString();

					}
				}
				tempString += "...";
			}

			return tempString;
		}
示例#31
0
 private void lstHistory_DrawItem(object sender, DrawItemEventArgs e)
 {
     FlatListBox.DrawItemHandler(sender, e);
 }
		/// <summary>
		/// Raises the DrawItem event.  
		/// </summary>
		protected virtual void OnDrawItem(object sender, DrawItemEventArgs e)
		{
			if (this.DrawItem != null)
				this.DrawItem(sender, e);

		}
示例#33
0
        private void tabControlMain_DrawItem(object sender, DrawItemEventArgs e)
        {
            try
            {
                Image     icon      = this.imageList1.Images[0];
                Brush     biaocolor = Brushes.Transparent; //选项卡的背景色
                Graphics  g         = e.Graphics;
                Rectangle r         = MainTabControl.GetTabRect(e.Index);
                if (e.Index == this.MainTabControl.SelectedIndex) //当前选中的Tab页,设置不同的样式以示选中
                {
                    Brush selected_color = Brushes.Wheat;         //选中的项的背景色
                    g.FillRectangle(selected_color, r);           //改变选项卡标签的背景色
                    string title = MainTabControl.TabPages[e.Index].Text + "  ";

                    g.DrawString(title, this.Font, new SolidBrush(Color.Black), new PointF(r.X, r.Y + 6));//PointF选项卡标题的位置

                    r.Offset(r.Width - iconWidth - 3, 2);
                    g.DrawImage(icon, new Point(r.X + 2, r.Y + 2));//选项卡上的图标的位置 fntTab = new System.Drawing.Font(e.Font, FontStyle.Bold);
                }
                else//非选中的
                {
                    g.FillRectangle(biaocolor, r); //改变选项卡标签的背景色
                    string title = this.MainTabControl.TabPages[e.Index].Text + "  ";

                    g.DrawString(title, this.Font, new SolidBrush(Color.Black), new PointF(r.X, r.Y + 6)); //PointF选项卡标题的位置
                    r.Offset(r.Width - iconWidth - 3, 2);
                    g.DrawImage(icon, new Point(r.X + 2, r.Y + 2));                                        //选项卡上的图标的位置
                }
                //Rectangle myTabRect = this.MainTabControl.GetTabRect(e.Index);

                ////先添加TabPage属性
                //e.Graphics.DrawString(this.MainTabControl.TabPages[e.Index].Text
                //, this.Font, SystemBrushes.ControlText, myTabRect.X + 2, myTabRect.Y + 2);

                //myTabRect.Offset(myTabRect.Width - (CLOSE_SIZE + 3), 2);
                //myTabRect.Width = CLOSE_SIZE;
                //myTabRect.Height = CLOSE_SIZE;
                ////再画一个矩形框
                //using (Pen p = new Pen(Color.Red))
                //{

                //    //  e.Graphics.DrawRectangle(p, myTabRect);
                //}


                ////画关闭符号
                //using (Pen objpen = new Pen(Color.DarkGray, 1.0f))
                //{
                //    //"\"线
                //    Point p1 = new Point(myTabRect.X + 3, myTabRect.Y + 3);
                //    Point p2 = new Point(myTabRect.X + myTabRect.Width - 3, myTabRect.Y + myTabRect.Height - 3);
                //    e.Graphics.DrawLine(objpen, p1, p2);

                //    //"/"线
                //    Point p3 = new Point(myTabRect.X + 3, myTabRect.Y + myTabRect.Height - 3);
                //    Point p4 = new Point(myTabRect.X + myTabRect.Width - 3, myTabRect.Y + 3);
                //    e.Graphics.DrawLine(objpen, p3, p4);
                //}

                //e.Graphics.Dispose();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
示例#34
0
文件: Theme.cs 项目: massimoca/Wedit
    protected override void OnDrawItem(DrawItemEventArgs e)
    {
        e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
        {
            e.Graphics.FillRectangle(B1, e.Bounds);
        }
        else
        {
            e.Graphics.FillRectangle(B2, e.Bounds);
        }

        if (!(e.Index == -1))
        {
            e.Graphics.DrawString(GetItemText(Items[e.Index]), e.Font, Brushes.White, e.Bounds);
        }
    }
示例#35
0
	// Raise the "DrawItem" event.
	protected internal virtual void OnDrawItem(DrawItemEventArgs e)
			{
				if(DrawItem != null)
				{
					DrawItem(this, e);
				}
			}