Ejemplo n.º 1
0
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;
            Rectangle r = e.Bounds;
               // Size imageSize = e.DrawFocusRectangle();
            //Font fn = null;
            if (e.Index >= 0)
            {
                //fn = (Font)fontArray[0];
                //string s = "";
                //string s = (string)comboBox1.Items[e.Index];
                StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Near;
                if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect))
                {
                    //����Ŀ����
                    e.Graphics.FillRectangle(new SolidBrush(Color.Red), r);
                    //����ͼ��
                    //imageList1.Draw(e.Graphics, r.Left, r.Top, e.Index);
                    //��ʾ�ַ���
                   // e.Graphics.DrawString(s, fn, new SolidBrush(Color.Black), r.Left + imageSize.Width, r.Top);
                    //��ʾȡ�ý���ʱ�����߿�
                    e.DrawFocusRectangle();
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.LightBlue), r);
                    //imageList1.Draw(e.Graphics, r.Left, r.Top, e.Index);
                    //e.Graphics.DrawString(s, fn, new SolidBrush(Color.Black), r.Left + imageSize.Width, r.Top);
                    e.DrawFocusRectangle();
                }
            }

            //base.OnDrawItem(e);
        }
Ejemplo n.º 2
0
        void ColoredListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) {

            if ( e.Index < 0 || e.Index >= Items.Count )
                return;

            var Item = Items[e.Index] as ColoredItem;

            if ( Item == null || String.IsNullOrWhiteSpace(Item.Text) )
                return;

            e.DrawBackground();

            Color? foreColor = Utilities.GetDimColorFromChar(Item.Color);

            if ( e.State == System.Windows.Forms.DrawItemState.Selected || e.State == System.Windows.Forms.DrawItemState.Checked || e.State == System.Windows.Forms.DrawItemState.Focus ) {
                e.Graphics.DrawString(Item.Text, e.Font, Brushes.Black, e.Bounds);
            }
            else {
                using ( Brush brush = new SolidBrush(foreColor ?? e.ForeColor) )
                    e.Graphics.DrawString(Item.Text, e.Font, brush, e.Bounds);
            }

            e.DrawFocusRectangle();

        }
Ejemplo n.º 3
0
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Index < 0)
                return;

            e.DrawBackground();
            e.DrawFocusRectangle();
            e.Graphics.DrawString(this.Items[e.Index].ToString(), e.Font, new System.Drawing.SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);

            base.OnDrawItem(e);
        }
Ejemplo n.º 4
0
 protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
 {
     e.DrawBackground();
     e.DrawFocusRectangle();
     ImageListBoxItem item;
     Rectangle bounds = e.Bounds;
     if (ImageList == null)
     {
         if (e.Index != -1)
         {
             e.Graphics.DrawString(Items[e.Index].ToString(), e.Font,
                 new SolidBrush(e.ForeColor), bounds.Left, bounds.Top);
         }
         else
         {
             e.Graphics.DrawString(Text, e.Font, new SolidBrush(e.ForeColor),
                 bounds.Left, bounds.Top);
         }
         base.OnDrawItem(e);
         return;
     }
     Size imageSize = _myImageList.ImageSize;
     try
     {
         item = (ImageListBoxItem)Items[e.Index];
         if (item.ImageIndex != -1)
         {
             ImageList.Draw(e.Graphics, bounds.Left, bounds.Top, item.ImageIndex);
             e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor),
                 bounds.Left + imageSize.Width, bounds.Top);
         }
         else
         {
             e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor),
                 bounds.Left, bounds.Top);
         }
     }
     catch
     {
         if (e.Index != -1)
         {
             e.Graphics.DrawString(Items[e.Index].ToString(), e.Font,
                 new SolidBrush(e.ForeColor), bounds.Left, bounds.Top);
         }
         else
         {
             e.Graphics.DrawString(Text, e.Font, new SolidBrush(e.ForeColor),
                 bounds.Left, bounds.Top);
         }
     }
     base.OnDrawItem(e);
 }
Ejemplo n.º 5
0
			protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
			{
				if (! Enabled)
				{
					this.BackColor = System.Drawing.SystemColors.Control;
				}
				else
				{
					this.BackColor = SystemColors.Window;
				}
				e.DrawBackground();
				e.DrawFocusRectangle();

				if (e.Index != -1)
				{
					string itemText = null;
					if (DisplayMember != null && DisplayMember.Length != 0)
					{
						itemText = FilterItemOnProperty(Items[e.Index], DisplayMember).ToString();
					}
					else
					{
						itemText = this.Items[e.Index].ToString();
					}
					Size imageSize = new Size();
					int imgIdx = 0;
					if (mImageList != null && ! (mImageList.Images.Count == 0))
					{
						imageSize = mImageList.ImageSize;
						imgIdx = getImageIndex(e.Index);
					}

					if (ImageIndexes != null && ! (ImageIndexes.Count == 0) && imgIdx != -1)
					{

						this.ImageList.Draw(e.Graphics, e.Bounds.Left + mImagePadding, e.Bounds.Top, imgIdx);
						e.Graphics.DrawString(itemText, e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left + mImagePadding + imageSize.Width + mImagePadding, e.Bounds.Top + mImagePadding);
					}
					else
					{
						e.Graphics.DrawString(itemText, e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left, e.Bounds.Top);
					}
				}
				else
				{
					e.Graphics.DrawString(Text, e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left, e.Bounds.Top);
				}

				base.OnDrawItem(e);
			}
Ejemplo n.º 6
0
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle(); //ListBox lb1 = new ListBox(); lb1.DrawMode = DrawMode.

            CustomListBoxItem item;
            Rectangle bounds = e.Bounds;
            Size imageSize = new Size(0, 0);
            Image ImageAvatar;

            try
            {
                item = (CustomListBoxItem)Items[e.Index];
                if (item.strAvatar != "")
                {
                    // Draw Image
                    ImageAvatar = ImageFromStr(item.strAvatar);
                    e.Graphics.DrawImage(ImageAvatar,
                        bounds.Left, bounds.Top, bounds.Height, bounds.Height);
                }
                // Draw Name
                e.Graphics.DrawString(item.Name,
                    new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Bold,
                        System.Drawing.GraphicsUnit.Point, ((byte)(0)))
                    , new SolidBrush(e.ForeColor),
                    bounds.Left + bounds.Height, bounds.Top);

                // Draw Username
                e.Graphics.DrawString(item.Username,
                    new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Italic,
                        System.Drawing.GraphicsUnit.Point, ((byte)(0)))
                    , new SolidBrush(e.ForeColor),
                    bounds.Left + bounds.Height, bounds.Top + 17);

                // Draw UserGroupName
                e.Graphics.DrawString(item.UserGroupName,
                    new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Italic,
                        System.Drawing.GraphicsUnit.Point, ((byte)(0)))
                    , new SolidBrush(e.ForeColor),
                    bounds.Left + bounds.Height, bounds.Bottom - 20);
            }
            catch
            {
            }
            base.OnDrawItem(e);
        }
Ejemplo n.º 7
0
 private void ChatList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     if (e.Index >= 0)
     {
         string text = ((System.Windows.Forms.ListBox)sender).Items[e.Index].ToString();
         System.Drawing.Color item = ConnectedTradersManager.TraderColor[text].Item1;
         using (System.Drawing.Brush brush = new System.Drawing.SolidBrush((e.BackColor == this.ChatList.BackColor) ? this.ChatList.BackColor : System.Drawing.SystemColors.ControlLight))
         {
             e.Graphics.FillRectangle(brush, e.Bounds);
         }
         using (System.Drawing.Brush brush2 = new System.Drawing.SolidBrush(item))
         {
             e.Graphics.DrawString(text, e.Font, brush2, e.Bounds);
         }
         e.DrawFocusRectangle();
     }
 }
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();
            Rectangle bounds = e.Bounds;

            // no item
            if (e.Index < 0 || e.Index >= Items.Count)
            {
                e.Graphics.DrawString(Text, e.Font, new SolidBrush(e.ForeColor),
                    bounds.Left, bounds.Top);
            }
            else
            {
                int LabelOffset = 0;
                int ImageIndex = -1;
                string ItemText = Items[e.Index].ToString();
                Color ItemColor = Color.FromKnownColor(KnownColor.Transparent);
                bool ItemMark = false;

                if (ImageList != null) LabelOffset = ImageList.ImageSize.Width;

                ImageListBoxItem Item = Items[e.Index] as ImageListBoxItem;
                if (Item != null)
                {
                    ImageIndex = Item.ImageIndex;
                    ItemColor = Item.ForeColor;
                    ItemMark = Item.Mark;
                }

                // draw image, if available
                if(ImageList!=null && ImageIndex>= 0 && ImageIndex < ImageList.Images.Count)
                {
                    ImageList.Draw(e.Graphics, bounds.Left, bounds.Top, ImageIndex);
                }

                // draw label
                Color forecolor = (ItemColor != Color.FromKnownColor(KnownColor.Transparent)) ? ItemColor : e.ForeColor;
                Font font = ItemMark ? new Font(e.Font, FontStyle.Bold) : e.Font;

                e.Graphics.DrawString(ItemText, font, new SolidBrush(forecolor),
                        bounds.Left + LabelOffset, bounds.Top);
            }
            base.OnDrawItem(e);
        }
Ejemplo n.º 9
0
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();
            GListBoxItem item;
            Rectangle bounds = e.Bounds;
            Size imageSize = (_myImageList != null)?_myImageList.ImageSize:new Size(48,48);
            int left = bounds.Left;

            try
            {
                item = (GListBoxItem)Items[e.Index];

                CheckBoxState cbState = this.SelectedItems.Contains(item)?CheckBoxState.CheckedNormal:CheckBoxState.UncheckedNormal;
                CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(left, bounds.Top), cbState);
                left += imageSize.Width;

                if (item.ImageIndex != -1)
                {
                    ImageList.Draw(e.Graphics, left, bounds.Top, item.ImageIndex);
                    left += imageSize.Width;
                }
                e.Graphics.DrawString(item.Label, e.Font, new SolidBrush(e.ForeColor),
                       left, bounds.Top);
            }
            catch
            {
                if (e.Index != -1)
                {
                    if (Items.Count > 0 && Items.Count >= e.Index + 1)
                    {
                        e.Graphics.DrawString(Items[e.Index].ToString(), e.Font,
                            new SolidBrush(e.ForeColor), bounds.Left, bounds.Top);
                    }
                }
                else
                {
                    e.Graphics.DrawString(Text, e.Font, new SolidBrush(e.ForeColor),
                        bounds.Left, bounds.Top);
                }
            }
            base.OnDrawItem(e);
        }
Ejemplo n.º 10
0
        //protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e)
        //{
        //    base.OnMeasureItem(e);
        //    e.ItemHeight = e.ItemHeight - 2;
        //}

        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            base.OnDrawItem(e);
            if (e.Index < 0)
            {
                return;
            }
            float size = this.Font.Size;
            System.Drawing.Font myFont;
            System.Drawing.FontFamily family = this.Font.FontFamily;

            System.Drawing.Color animalColor = this.ForeColor;

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

            // Create a square filled with the animals color. Vary the size
            // of the rectangle based on the length of the animals name.
            //System.Drawing.Rectangle rectangle = new Rectangle(2, e.Bounds.Top + 2,
            //        e.Bounds.Height, e.Bounds.Height - 4);
            //e.Graphics.FillRectangle(new SolidBrush(animalColor), rectangle);

            // Draw each string in the array, using a different size, color,
            // and font for each item.
            myFont = new Font(family, size, FontStyle.Regular);
            
            e.Graphics.DrawString(this.GetItemText(Items[e.Index]), myFont, System.Drawing.Brushes.Black, new PointF(e.Bounds.X + 5, e.Bounds.Y + 2));
            //new RectangleF(e.Bounds.X + e.Bounds.Height, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
            //弹出下拉
            //if (e.State == (System.Windows.Forms.DrawItemState.NoAccelerator | System.Windows.Forms.DrawItemState.NoFocusRect))
            //{
            //    e.Graphics.DrawRectangle(new Pen(_borderColor), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
            //}
            //else//选择时
            //{
            //    e.Graphics.DrawRectangle(new Pen(_borderColor), e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1);
            //}
            // Draw the focus rectangle if the mouse hovers over an item.
            e.DrawFocusRectangle();
        }
Ejemplo n.º 11
0
        private void lstBox_DrawItem(object sender,
              System.Windows.Forms.DrawItemEventArgs e)
        {
            // Перерисовываем фон всех элементов ListBox.
            e.DrawBackground();

            // Создаем объект Brush.
            Brush myBrush = Brushes.Black;

            // Определяем номер текущего элемента
            switch (e.Index)
            {
                case 0:
                    myBrush = Brushes.Red;
                    break;
                case 1:
                    myBrush = Brushes.Green;
                    break;
                case 2:
                    myBrush = Brushes.Blue;
                    break;
                default: myBrush = Brushes.Yellow;
                    break;
            }

            //Если необходимо, закрашиваем фон
            //активного элемента в новый цвет
            //e.Graphics.FillRectangle(myBrush, e.Bounds);

            // Перерисовываем текст текущего элемента
            e.Graphics.DrawString(
                ((ListBox)sender).Items[e.Index].ToString(),
                e.Font, myBrush, e.Bounds,
                StringFormat.GenericDefault);
            e.Graphics.FillRectangle(myBrush, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
            // Если ListBox в фокусе, рисуем прямоугольник
            //вокруг активного элемента.
            e.DrawFocusRectangle();
        }
Ejemplo n.º 12
0
		protected override void OnDrawItem( System.Windows.Forms.DrawItemEventArgs e ) {
			base.OnDrawItem( e );

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

			if( e.Index < 0 )
				return;

			if( this.Items[ e.Index ] is ImageComboItem ) {
				ImageComboItem CurrItem = (ImageComboItem)this.Items[ e.Index ];
				SizeF fontSize = e.Graphics.MeasureString( CurrItem.Text, CurrItem.Font );
				if( CurrItem.Text != string.Empty )
					e.Graphics.DrawString( CurrItem.Text, CurrItem.Font, new SolidBrush( CurrItem.ForeColor ), e.Bounds.Left, e.Bounds.Top + ( mImageList.ImageSize.Height / 2 ) - ( fontSize.Width / 2 ) );
				if( mImageList == null || CurrItem.ImageIndex == -1 )
					return;

				this.ImageList.Draw( e.Graphics, e.Bounds.Left + (int)fontSize.Width, e.Bounds.Top, CurrItem.ImageIndex );
				return;
			}
			e.Graphics.DrawString( this.Items[ e.Index ].ToString(), e.Font, new SolidBrush( e.ForeColor ), e.Bounds.Left, e.Bounds.Top );

		}
Ejemplo n.º 13
0
		protected override void OnDrawItem( System.Windows.Forms.DrawItemEventArgs e ) {
			base.OnDrawItem( e );

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

			if( e.Index < 0 )
				return;

			if( !( this.Items[ e.Index ] is ImageComboItem ) ) {
				e.Graphics.DrawString( Items[ e.Index ].ToString(), e.Font, new SolidBrush( e.ForeColor ), e.Bounds.Left, e.Bounds.Top );
				return;
			}

			ImageComboItem CurrItem = this.Items[ e.Index ] as ImageComboItem;
			SizeF fontSize = e.Graphics.MeasureString( CurrItem.Text, CurrItem.Font );
			SolidBrush brush = new SolidBrush( CurrItem.ForeColor );
			int imageX = e.Bounds.Left;
			if( CurrItem.Text != string.Empty && CurrItem.TextAlign == EImageComboItemTextAlign.Left )
				e.Graphics.DrawString( CurrItem.Text, CurrItem.Font, brush, e.Bounds.Left, e.Bounds.Top + ( mImageList.ImageSize.Height / 2 ) - fontSize.Height / 2 );

			if( mImageList != null && CurrItem.ImageIndex != -1 ) {
				if( CurrItem.TextAlign == EImageComboItemTextAlign.Left )
					imageX += (int)fontSize.Width;

				if( mImagePlace > imageX )
					imageX = mImagePlace;
				ImageList.Draw( e.Graphics, imageX, e.Bounds.Top, CurrItem.ImageIndex );
			}

			if( CurrItem.Text != string.Empty && CurrItem.TextAlign == EImageComboItemTextAlign.Right ) {
				imageX += ImageList.ImageSize.Width + 10;
				e.Graphics.DrawString( CurrItem.Text, CurrItem.Font, brush, imageX, e.Bounds.Top + ( mImageList.ImageSize.Height / 2 ) - fontSize.Height / 2 );
			}

		}
		void ComboBoxDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
		{
			ComboBox comboBox = (ComboBox)sender;
			e.DrawBackground();
			if (e.Index >= 0) {
				FontDescriptor fontDescriptor = (FontDescriptor)comboBox.Items[e.Index];
				Rectangle drawingRect = new Rectangle(e.Bounds.X,
				                                      e.Bounds.Y,
				                                      e.Bounds.Width,
				                                      e.Bounds.Height);
				
				Brush drawItemBrush = SystemBrushes.WindowText;
				if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
					drawItemBrush = SystemBrushes.HighlightText;
				}
				
				e.Graphics.DrawString(fontDescriptor.Name,
				                      fontDescriptor.IsMonospaced ? boldComboBoxFont : comboBox.Font,
				                      drawItemBrush,
				                      drawingRect,
				                      drawStringFormat);
			}
			e.DrawFocusRectangle();
		}
		void ComboBoxDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
		{
			ComboBox comboBox = (ComboBox)sender;
			e.DrawBackground();
			
			if (e.Index >= 0) {
				ComboBoxItem item = (ComboBoxItem)comboBox.Items[e.Index];
				
				e.Graphics.DrawImageUnscaled(ClassBrowserIconService.ImageList.Images[item.IconIndex],
				                             new Point(e.Bounds.X, e.Bounds.Y + (e.Bounds.Height - ClassBrowserIconService.ImageList.ImageSize.Height) / 2));
				Rectangle drawingRect = new Rectangle(e.Bounds.X + ClassBrowserIconService.ImageList.ImageSize.Width,
				                                      e.Bounds.Y,
				                                      e.Bounds.Width - ClassBrowserIconService.ImageList.ImageSize.Width,
				                                      e.Bounds.Height);
				
				Brush drawItemBrush = SystemBrushes.WindowText;
				if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
					drawItemBrush = SystemBrushes.HighlightText;
				}
				if (!item.IsInCurrentPart) {
					drawItemBrush = SystemBrushes.ControlDark;
				} else if (e.State == DrawItemState.ComboBoxEdit && !item.IsInside(textAreaControl.ActiveTextAreaControl.Caret.Line)) {
					drawItemBrush = SystemBrushes.ControlDark;
				}
				e.Graphics.DrawString(item.ToString(),
				                      font,
				                      drawItemBrush,
				                      drawingRect,
				                      drawStringFormat);
			}
			e.DrawFocusRectangle();
		}
 private void drawItem(System.Windows.Forms.DrawItemEventArgs e)
 {
     if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
     {
         e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
         if (this.Focused)
         {
             e.DrawFocusRectangle();
         }
     }
     else
     {
         e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
     }
     ilsIcons.Draw(e.Graphics,
         e.Bounds.Left + 2,
         e.Bounds.Top + 2,
         ilsIcons.ImageSize.Width,
         ilsIcons.ImageSize.Height,
         (int)this.Items[e.Index]);
 }
Ejemplo n.º 17
0
 private void comboDocs_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     if (e.Index < 0 || e.Index >= comboDocs.Items.Count)
         return;
     string strName;
     if (e.Index == 0) {
         Document docActive = DocManager.GetActiveDocument(typeof(TemplateDoc));
         if (docActive == null) {
             strName = "None";
         } else {
             strName = "Active (" + docActive.GetName() + ")";
         }
         m_tmpdCurrent = null;
     } else {
         Document doc = (Document)comboDocs.Items[e.Index];
         m_tmpdCurrent = (TemplateDoc)doc;
         strName = doc.GetName();
     }
     e.DrawBackground();
     e.Graphics.DrawString(strName, e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y);
     e.DrawFocusRectangle();
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 
 /// </summary>
 private static void CLDrawListItem(Object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     ICompletionListItem item = completionList.Items[e.Index] as ICompletionListItem;
     e.DrawBackground();
     Color fore = PluginBase.MainForm.GetThemeColor("CompletionList.ForeColor", SystemColors.WindowText);
     Color sel = PluginBase.MainForm.GetThemeColor("CompletionList.SelectedTextColor", SystemColors.HighlightText);
     bool selected = (e.State & DrawItemState.Selected) > 0;
     Brush textBrush = (selected) ? new SolidBrush(sel) : new SolidBrush(fore);
     Brush packageBrush = new SolidBrush(PluginBase.MainForm.GetThemeColor("CompletionList.PackageColor", Color.Gray));
     Rectangle tbounds = new Rectangle(ScaleHelper.Scale(18), e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
     if (item != null)
     {
         Graphics g = e.Graphics;
         float newHeight = e.Bounds.Height - 2;
         g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
         g.DrawImage(item.Icon, 1, e.Bounds.Top + ((e.Bounds.Height - newHeight) / 2), newHeight, newHeight);
         int p = item.Label.LastIndexOf('.');
         if (p > 0 && !selected)
         {
             string package = item.Label.Substring(0, p + 1);
             g.DrawString(package, e.Font, packageBrush, tbounds, StringFormat.GenericDefault);
             int left = tbounds.Left + DrawHelper.MeasureDisplayStringWidth(e.Graphics, package, e.Font) - 2;
             if (left < tbounds.Right) g.DrawString(item.Label.Substring(p + 1), e.Font, textBrush, left, tbounds.Top, StringFormat.GenericDefault);
         }
         else g.DrawString(item.Label, e.Font, textBrush, tbounds, StringFormat.GenericDefault);
     }
     e.DrawFocusRectangle();
     if ((item != null) && ((e.State & DrawItemState.Selected) > 0))
     {
         UITools.Tip.Hide();
         currentItem = item;
         tempoTip.Stop();
         tempoTip.Start();
     }
 }
Ejemplo n.º 19
0
        //вывод элементов в listbox
        private void lbx_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            //MessageBox.Show("lbx");
            ListBox lbx = (ListBox)sender;
            //если в списке нет элементов нечего прорисовывать выходим
            if (lbx.Items.Count == 0 || e.Index < 0)
            {
                return;
            }

            //приводим ткущий рисуемый элемент к t_customer
            t item = (t)lbx.Items[e.Index];

            // Draw the background of the ListBox control for each item.
            e.DrawBackground();
            // Define the default color of the brush as black.
            //Brush text_brush = new System.Drawing.SolidBrush(ColorTranslator.FromHtml("#333"));

            //Brush b1 = new System.Drawing.SolidBrush(ColorTranslator.FromHtml("#0099cc"));

            //Font text_font = e.Font;

            //отрисовываем текущий выделенный элемент
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                //рисуем прямоуголник выделенного элемента (фон)
                e.Graphics.FillRectangle(new System.Drawing.SolidBrush(ColorTranslator.FromHtml("#0099cc")), e.Bounds);
                //text_brush = SystemBrushes.HighlightText;
                //text_brush = new System.Drawing.SolidBrush(ColorTranslator.FromHtml("#9cc"));
                //text_font = new Font(e.Font, FontStyle.Bold);

                //выводим fio клиента в первой строчке
                t_uti.f_draw_text
                (
                    e.Graphics,
                    item["str1"].f_str(),
                    new Font(e.Font, FontStyle.Bold),	//текст делаем жирным
                    new SolidBrush(ColorTranslator.FromHtml("#fff")),	//цвет текста
                    new SolidBrush(ColorTranslator.FromHtml("#333")),	//цвет тени
                    //прямоугольник в который выводится текст
                    new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
                );

                //вывдим телефоны и email во второй строке
                t_uti.f_draw_text
                (
                    e.Graphics,
                    item["str2"].f_str(),
                    e.Font,			//текст оставляем нормальным
                    new SolidBrush(ColorTranslator.FromHtml("#eee")),	//цвет текста
                    new SolidBrush(ColorTranslator.FromHtml("#555")),	//цвет тени
                    //прямоугольник в который выводится текст - смещен на 31 пиксель по вертикали (вывод второй строки)
                    new Rectangle(e.Bounds.X, e.Bounds.Y + lbx_items.ItemHeight/2-2, e.Bounds.Width, e.Bounds.Height)
                );

                //выводим кнопку редактирования на выделенном элементе
                RectangleF rect = e.Bounds;
                fp_actions.Top = Convert.ToInt32(lbx_items.Top + rect.Top + rect.Height / 2 - fp_actions.Height / 2);
                fp_actions.Left = Convert.ToInt32(lbx_items.Left + rect.Right - rect.Height / 2 + fp_actions.Height / 2 - fp_actions.Width);

            }
            else	//отрисовываем не выделенные элементы
            {
                //нечетные строки имеют белый фон
                if (e.Index % 2 == 0)
                {
                    e.Graphics.FillRectangle(new SolidBrush(ColorTranslator.FromHtml("#fff")), e.Bounds);
                }
                else//четные светло серый
                {
                    e.Graphics.FillRectangle(new SolidBrush(ColorTranslator.FromHtml("#eee")), e.Bounds);
                }

                //выводим fio клиента в первой строчке
                t_uti.f_draw_text
                (
                    e.Graphics,
                    item["str1"].f_str(),
                    e.Font,
                    new SolidBrush(ColorTranslator.FromHtml("#333")),	//цвет текста
                    new SolidBrush(ColorTranslator.FromHtml("#fff")),	//цвет тени
                    e.Bounds
                );
                //вывдим телефоны и email во второй строке
                t_uti.f_draw_text
                (
                    e.Graphics,
                    item["str2"].f_str(),
                    e.Font,
                    new SolidBrush(ColorTranslator.FromHtml("#555")),	//цвет текста
                    new SolidBrush(ColorTranslator.FromHtml("#fff")),	//цвет тени
                    new Rectangle(e.Bounds.X, e.Bounds.Y + lbx_items.ItemHeight / 2-2, e.Bounds.Width, e.Bounds.Height)
                );

            }

            // If the ListBox has focus, draw a focus rectangle around the selected item.
            e.DrawFocusRectangle();
            //e.
        }
Ejemplo n.º 20
0
        private void FontFamilyComboBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Index != -1)
            {
                string displayText = (string)this.fontFamilyComboBox.Items[e.Index];

                SizeF stringSize = e.Graphics.MeasureString(displayText, arialFontBase);
                int size = (int)stringSize.Width;

                // set up two areas to draw
                const int leftMargin = 3;
                Rectangle bounds = e.Bounds;
                bounds.X += leftMargin;
                bounds.Width -= leftMargin;

                Rectangle r = bounds;

                Rectangle rd = r;
                rd.Width = rd.Left + size;

                Rectangle rt = r;
                r.X = rd.Right;

                using (Font myFont = IndexToFont(e.Index, 10, FontStyle.Regular))
                {
                    StringFormat sf = (StringFormat)StringFormat.GenericTypographic.Clone();
                    sf.LineAlignment = StringAlignment.Center;
                    sf.FormatFlags &= ~StringFormatFlags.LineLimit;
                    sf.FormatFlags |= StringFormatFlags.NoWrap;

                    bool isSymbol = PaintDotNet.SystemLayer.Fonts.IsSymbolFont(myFont);
                    bool isSelected = ((e.State & DrawItemState.Selected) != 0);
                    Brush fillBrush;
                    Brush textBrush;

                    if (isSelected)
                    {
                        fillBrush = highlightBrush;
                        textBrush = highlightTextBrush;
                    }
                    else
                    {
                        fillBrush = windowBrush;
                        textBrush = windowTextBrush;
                    }

                    e.Graphics.FillRectangle(fillBrush, e.Bounds);

                    if (isSymbol)
                    {
                        e.Graphics.DrawString(displayText, arialFontBase, textBrush, bounds, sf);
                        e.Graphics.DrawString(displayText, myFont, textBrush, r, sf);
                    }
                    else
                    {
                        e.Graphics.DrawString(displayText, myFont, textBrush, bounds, sf);
                    }

                    sf.Dispose();
                    sf = null;
                }
            }

            e.DrawFocusRectangle();
        }
Ejemplo n.º 21
0
 private void CLDrawListItem(Object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     ICompletionListItem item = completionList.Items[e.Index] as ICompletionListItem;
     e.DrawBackground();
     bool selected = (e.State & DrawItemState.Selected) > 0;
     Brush myBrush = (selected) ? Brushes.White : Brushes.Black;
     Rectangle tbounds = new Rectangle(18, e.Bounds.Top + 1, e.Bounds.Width, e.Bounds.Height);
     if (item != null)
     {
         e.Graphics.DrawImage(item.Icon, 1, e.Bounds.Top + ((e.Bounds.Height - item.Icon.Height) / 2));
         int p = item.Label.LastIndexOf('.');
         if (p > 0)
         {
             string package = item.Label.Substring(0, p + 1);
             e.Graphics.DrawString(package, e.Font, Brushes.Gray, tbounds, StringFormat.GenericDefault);
             SizeF dims = e.Graphics.MeasureString(package, e.Font, tbounds.Width, StringFormat.GenericDefault);
             int left = tbounds.Left + (int)dims.Width + 1;
             if (left < tbounds.Right) e.Graphics.DrawString(item.Label.Substring(p + 1), e.Font, myBrush, left, tbounds.Top, StringFormat.GenericTypographic);
         }
         else e.Graphics.DrawString(item.Label, e.Font, myBrush, tbounds, StringFormat.GenericDefault);
     }
     e.DrawFocusRectangle();
     if ((item != null) && ((e.State & DrawItemState.Selected) > 0))
     {
         UITools.Tip.Hide();
         currentItem = item;
         tempoTip.Stop();
         tempoTip.Start();
     }
 }
Ejemplo n.º 22
0
		static private void CLDrawListItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
		{
			ICompletionListItem item = completionList.Items[e.Index] as ICompletionListItem;
			e.DrawBackground(); // empty background
			// draw text
			Brush myBrush = ((e.State & DrawItemState.Selected) > 0) ? Brushes.White : Brushes.Black;
			Rectangle tbounds = new Rectangle(18, e.Bounds.Top+1, e.Bounds.Width, e.Bounds.Height);
			if (item != null)
			{
				e.Graphics.DrawImage(item.Icon, 1,e.Bounds.Top);
				e.Graphics.DrawString(item.Label, e.Font, myBrush, tbounds, StringFormat.GenericDefault);
			}
			// focus rect
			e.DrawFocusRectangle();
			// InfoTip
			if ((item != null) && ((e.State & DrawItemState.Selected) > 0))
			{
				currentItem = item;
				UpdateTip();
			}
		}
Ejemplo n.º 23
0
        public static void paintComboBoxGroup(
			ComboBox cbo,
			System.Windows.Forms.DrawItemEventArgs e )
        {
            string strText;
            var clr = e.ForeColor;
            var rectText = e.Bounds;
            PlataDM.Grupp grupp = null;

            e.DrawBackground();

            if ( e.Index >= 0 )
                grupp = cbo.Items[e.Index] as PlataDM.Grupp;

            if ( grupp != null )
            {
                if ( (e.State & DrawItemState.ComboBoxEdit) == 0 )
                {
                    if ( grupp.GruppTyp != GruppTyp.GruppNormal )
                        if ( (e.State & DrawItemState.Focus) == 0 )
                            clr = SystemColors.Highlight;
                    rectText = new Rectangle(
                        e.Bounds.Left + e.Bounds.Height, e.Bounds.Top,
                        e.Bounds.Width - e.Bounds.Height, e.Bounds.Height );

                    PlataDM.Util.paintGroupNumberingSymbol(
                        e.Graphics,
                        e.Font,
                        grupp,
                        new Rectangle( e.Bounds.Left + 2, e.Bounds.Top, e.Bounds.Height - 2, e.Bounds.Height - 2 ) );
                }

                var s = string.Empty;
                if ((grupp.Special & TypeOfGroupPhoto.Gruppbild) != 0)
                    s += "G";
                if ((grupp.Special & TypeOfGroupPhoto.Katalog) != 0)
                    s += "K";
                if ((grupp.Special & TypeOfGroupPhoto.SkyddadId) != 0)
                    s += "S";
                if ((grupp.Special & TypeOfGroupPhoto.Spex) != 0)
                    s += "P";
                e.Graphics.DrawString( s, SystemFonts.IconTitleFont, Brushes.White, rectText.X+1, rectText.Y+1 );
                e.Graphics.DrawString( s, SystemFonts.IconTitleFont, Brushes.LightBlue, rectText.X, rectText.Y );
                rectText.Offset( 20, 0 );
                rectText.Width -= 20;

                strText = grupp.Namn;
                if ( grupp.Makulerad )
                    strText = "mak: " + strText;

            }
            else
                strText = "(välj grupp)";

            using ( Brush br = new SolidBrush( clr ) )
                e.Graphics.DrawString( strText, e.Font, br, rectText );
            e.DrawFocusRectangle();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void cboRule_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Index == -1)
            {
                return;
            }

            Signature rule = (Signature)cboRule.Items[e.Index];

            // Determine the forecolor based on whether or not the item is selected
            Brush brush;
            if (rule.Updated == true)
            {
                brush = Brushes.Red;
            }
            else
            {
                brush = Brushes.Black;
            }

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.LightGray), e.Bounds);
            }
            else
            {
                e.Graphics.FillRectangle(new SolidBrush(cboRule.BackColor), e.Bounds);
            }

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            e.Graphics.DrawString(rule.Text, cboRule.Font, brush, e.Bounds.X, e.Bounds.Y);

            e.DrawFocusRectangle();
        }
Ejemplo n.º 25
0
        private void InstalledLB_DrawItem(object sender,
    System.Windows.Forms.DrawItemEventArgs e)
        {
            // Draw the background of the ListBox control for each item.
            e.DrawBackground();

            // Define the default color of the brush as black.
            Brush drawBrush = Brushes.Black;
            Font drawFont = e.Font;

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

            string mod = (string)InstalledLB.Items[e.Index];
            switch(getInstallStatus(mod)) {
                case installStatus.NOT_INSTALLED:
                    drawBrush = Brushes.Gray;
                    break;
                case installStatus.DEPENDENCY_BROKEN:
                    drawBrush = Brushes.Red;
                    break;
                case installStatus.NON_MOD_DIR:
                    drawBrush = Brushes.Purple;
                    break;
                case installStatus.INSTALLABLE_FROM_HERE:
                    drawBrush = Brushes.Green;
                    break;
                case installStatus.OK:
                    drawBrush = Brushes.Black;
                    break;
            }
            if (isCurrentMod(mod)) {
                drawFont = new Font(drawFont, FontStyle.Bold);
            }

            e.Graphics.DrawString(InstalledLB.Items[e.Index].ToString(),
                drawFont, drawBrush, e.Bounds, StringFormat.GenericDefault);
            e.DrawFocusRectangle();
        }
Ejemplo n.º 26
0
		private void DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) {
			e.DrawBackground();
			pen.Color = colorLabel.BackColor;
			Graphics g = e.Graphics;
		string style = (string)lineStyle.Items[e.Index];
			for (DashStyle s = DashStyle.Solid; s < DashStyle.Custom; s++) {
				if (style == s.ToString()) pen.DashStyle = s;
			}
			g.DrawLine(pen, e.Bounds.X, e.Bounds.Y + e.Bounds.Height/2, e.Bounds.X + e.Bounds.Width,
				e.Bounds.Y + e.Bounds.Height/2);
			e.DrawFocusRectangle();
		}
Ejemplo n.º 27
0
		private void DrawCombo(object sender, System.Windows.Forms.DrawItemEventArgs e)
		{
			
			Graphics g = e.Graphics;
			Rectangle rd = e.Bounds;			
			
			int rr = this.cColor.R;
			int gg = this.cColor.G;
			int bb = this.cColor.B;
			Color cll = Color.White;
			Color cl = Color.FromArgb(rr+(255-rr)*2/3,gg+(255-gg)*2/3,bb+(255-bb)*2/3);
			Color cc = Color.FromArgb(rr+(255-rr)*1/3,gg+(255-gg)*1/3,bb+(255-bb)*1/3);
			Color cd = Color.FromArgb(rr,gg,bb);
			Color cdd = Color.FromArgb(rr*2/3,gg*2/3,bb*2/3);
			
			LinearGradientBrush br = new LinearGradientBrush(new Rectangle(e.Bounds.Left-1,e.Bounds.Top-1,e.Bounds.Width+4,e.Bounds.Height+4),cd,cll,65f); 

			if ( e.Index >= 0 ) 
			{
				//				Console.WriteLine(e.State.ToString());
				if ( e.State == ( DrawItemState.NoAccelerator | DrawItemState.NoFocusRect))
				{
					e.Graphics.FillRectangle(new SolidBrush(Color.White) , rd);
					e.DrawFocusRectangle();
				}
				else
				{
					if(this.app == ControlView.Skinned)
					{
						e.Graphics.FillRectangle(br , rd);
						br = new LinearGradientBrush(e.Bounds,cc,cll,65f); 
						rd.Width=e.Bounds.Width-2;
						rd.Height=e.Bounds.Height-2;
						rd.X=e.Bounds.X+1;
						rd.Y=e.Bounds.Y+1;
						e.Graphics.FillRectangle(br , rd);
						e.DrawFocusRectangle();
					}
					else
					{
						e.Graphics.FillRectangle(new SolidBrush(SystemColors.Highlight) , rd);
						e.DrawFocusRectangle();
					}
				}
			}			

			rd.Width = 20;
			rd.Height = this.ItemHeight-5;
			rd.X = 4;
			rd.Y += 1;

			if (e.Index >= 0 && e.Index<141 ) 
			{
				g.FillRectangle(new SolidBrush(c[e.Index]),rd);
				g.DrawRectangle(new Pen(Color.Black),rd);
				if(e.State == ( DrawItemState.NoAccelerator | DrawItemState.NoFocusRect) || this.app == ControlView.Skinned)
					g.DrawString(c[e.Index].Name,this.Font,new SolidBrush(Color.Black),rd.Width+5,rd.Top-1);
				else
					g.DrawString(c[e.Index].Name,this.Font,new SolidBrush(SystemColors.HighlightText),rd.Width+5,rd.Top-1);
			}
			else if (e.Index == 141) 
			{
				g.FillRectangle(new SolidBrush(otherCol),rd);
				g.DrawRectangle(new Pen(Color.Black),rd);
				if(e.State == ( DrawItemState.NoAccelerator | DrawItemState.NoFocusRect) || this.app == ControlView.Skinned)
					g.DrawString("Other",this.Font,new SolidBrush(Color.Black),rd.Width+5,rd.Top-1);
				else
					g.DrawString("Other",this.Font,new SolidBrush(SystemColors.HighlightText),rd.Width+5,rd.Top-1);
			}
			if(this.app == ControlView.Skinned)
			{
				Graphics gr = this.CreateGraphics();
				gr.DrawRectangle(new Pen(cd),0,0,this.Width-1,this.Height-1);
				gr.DrawRectangle(new Pen(cl),1,1,this.Width-3,this.Height-3);
				gr.FillRectangle(new SolidBrush(cll),this.Width-this.Height+1,2,this.Height-3,this.Height-4);

				br = new LinearGradientBrush(new Rectangle(this.Width-this.Height+1,2,this.Height,this.Height),cl,cd,45f); 
				gr.FillRectangle(br,this.Width-this.Height+2,3,this.Height-5,this.Height-6);

				br = new LinearGradientBrush(new Rectangle(this.Width-this.Height+1,2,this.Height,this.Height),cll,cc,45f); 
				gr.FillRectangle(br,this.Width-this.Height+3,4,this.Height-7,this.Height-8);

				gr.FillRectangle(new SolidBrush(cll),this.Width-this.Height+2,3,1,1);
				gr.FillRectangle(new SolidBrush(cll),this.Width-this.Height+2,3+this.Height-7,1,1);
				gr.FillRectangle(new SolidBrush(cll),this.Width-this.Height+2+this.Height-6,3,1,1);
				gr.FillRectangle(new SolidBrush(cl),this.Width-this.Height+2+this.Height-6,3+this.Height-7,1,1);
			
				gr.DrawLine(new Pen(cd,1),(this.Width-this.Height/2)-4,this.Height/2-1,(this.Width-this.Height/2)-1,this.Height/2+2);
				gr.DrawLine(new Pen(cd,1),(this.Width-this.Height/2)-1,this.Height/2+2,(this.Width-this.Height/2)+2,this.Height/2-1);
				gr.DrawLine(new Pen(cc,1),(this.Width-this.Height/2)-4,this.Height/2-0,(this.Width-this.Height/2)-1,this.Height/2+3);
				gr.DrawLine(new Pen(cc,1),(this.Width-this.Height/2)-1,this.Height/2+3,(this.Width-this.Height/2)+2,this.Height/2-0);
				gr.DrawLine(new Pen(cl,1),(this.Width-this.Height/2)-4,this.Height/2+1,(this.Width-this.Height/2)-1,this.Height/2+4);
				gr.DrawLine(new Pen(cl,1),(this.Width-this.Height/2)-1,this.Height/2+4,(this.Width-this.Height/2)+2,this.Height/2+1);
			}

			br.Dispose();
			
			
			//gr.DrawRectangle(new Pen(cd),this.Width-this.Height-2,3,15,this.Height-7);
			//			int i = int.Parse(this.Parent.Text);
			//			this.Parent.Text = (i+1).ToString();
		}
Ejemplo n.º 28
0
		private void OnDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
		{
			e.DrawBackground();
			e.DrawFocusRectangle();

			Rectangle rect = e.Bounds;
			rect.X += 1;
			rect.Y += 1;
			rect.Height -= 2;
			rect.Width = rect.Height;

			System.Drawing.Brush brush =
				new System.Drawing.SolidBrush(Color.White);
			System.Drawing.Brush fill =
				new System.Drawing.SolidBrush(Color.LightSteelBlue);
			System.Drawing.Pen pen =
				new System.Drawing.Pen(Color.Black, 0);

			e.Graphics.FillRectangle(brush, rect);
			e.Graphics.DrawRectangle(pen, rect);

			System.Drawing.Drawing2D.SmoothingMode mode =
				e.Graphics.SmoothingMode;
			e.Graphics.SmoothingMode =
				System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

			rect.Inflate(-2, -2);
			string shapeId = _list.Items[e.Index].ToString();
			ShapeTemplate shape = ShapeTemplate.FromId(shapeId);
			RectangleF rectf = new RectangleF(
				(float)rect.X, (float)rect.Y,
				(float)rect.Width, (float)rect.Height);
			MindFusion.FlowChartX.ShapeTemplate.PathData data =
				shape.initData(rectf, 0);

			System.Drawing.Drawing2D.GraphicsPath path =
				shape.getPath(data, 0);
			e.Graphics.FillPath(fill, path);
			e.Graphics.DrawPath(pen, path);
			path.Dispose();

			path = shape.getDecorationPath(data, 0);
			if (path != null)
			{
				e.Graphics.DrawPath(pen, path);
				path.Dispose();
			}

			e.Graphics.SmoothingMode = mode;

			pen.Dispose();
			fill.Dispose();
			brush.Dispose();

			// Draw the text;
			rectf.X = rectf.Right + 6;
			rectf.Width = (float)e.Bounds.Width - rectf.X;

			StringFormat format = new StringFormat();
			format.Alignment = StringAlignment.Near;
			format.LineAlignment = StringAlignment.Center;
			System.Drawing.Brush textBrush =
				new System.Drawing.SolidBrush(Color.Black);
			e.Graphics.DrawString(shapeId, Font, textBrush, rectf, format);
			textBrush.Dispose();
			format.Dispose();
		}
Ejemplo n.º 29
0
        private void ListBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            // Draw the background of the ListBox control for each item.
            e.DrawBackground();
            int i = e.Index;
            if (i < 0) return;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                //some code when the item is selected
                //if (i % 2 == 0)
                //{
                    //e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255,204,204)), e.Bounds);
                    //e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(204, 255, 204)), e.Bounds);
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 102, 102)), e.Bounds);
                    //e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 102, 102)),
                    //                            e.Bounds.X,e.Bounds.Y,e.Bounds.Width, e.Bounds.Height+20);
                    //e.Graphics.FillRectangle(new SolidBrush(Color.Blue), e.Bounds);
                    //e.BackColor = Color.Aqua;
                //}
                //else
                //{
                    //e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
                    //e.BackColor = Color.White;
                //}
                    //Brush brush = new Brush();
                StringFormat sf = new StringFormat();
                float[] ts = { 100.0f, 150.0f, 170.0f };
                sf.SetTabStops(0.0f, ts);

                e.Graphics.DrawString(lbxItems.Items[e.Index].ToString(),
                e.Font,  Brushes.White, e.Bounds, sf);
            }
            else
            {
                //some code when the item is unselected
                if (i % 2 == 0)
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(204, 255, 204)), e.Bounds);
                    //e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
                    //e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(204,204, 255)), e.Bounds);
                    //e.BackColor = Color.Aqua;
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
                    //e.BackColor = Color.White;
                }
                e.Graphics.DrawString(lbxItems.Items[e.Index].ToString(),
                e.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
            }

            // If the ListBox has focus, draw a focus rectangle around the selected item.
            e.DrawFocusRectangle();
        }
Ejemplo n.º 30
0
        private void lineStyles_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            if ((e.State & DrawItemState.Focus) != 0)
                e.DrawFocusRectangle();

            if (e.Index >= 0 && e.Index < lineStyles.Items.Count)
            {
                var col = new BindingList<IStroke>();
                col.Add((IStroke) lineStyles.Items[e.Index]);
                FeaturePreviewRender.RenderPreviewLine(e.Graphics, new Rectangle(e.Bounds.Left + 1, e.Bounds.Top + 1, e.Bounds.Width - 2, e.Bounds.Height - 2), col);
            }
        }