예제 #1
0
        private void settings2_3_authornamefont_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            Font objFonts = new Font(settings2_3_authornamefont.Items[e.Index].ToString(), 14);
            e.DrawBackground();

            e.Graphics.DrawString(settings2_3_authornamefont.Items[e.Index].ToString(), objFonts, new SolidBrush(e.ForeColor), new Point(e.Bounds.Left, e.Bounds.Top));
        }
예제 #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();

        }
예제 #3
0
파일: ComboBoxEx.cs 프로젝트: linyc/CTool
        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);
        }
예제 #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);
 }
예제 #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);
			}
예제 #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);
        }
        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);
        }
예제 #8
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);
        }
예제 #9
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();
        }
예제 #10
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();
        }
예제 #11
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 );

		}
예제 #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 ) ) {
				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 );
			}

		}
예제 #13
0
        private void myListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            //Gestione della grafica della listbox
            //Questo metodo permette di creare il rettangolo grigio attorno al nome dell'esercizio

            e.DrawBackground();
            Font myFont;
            Brush myBrush = Brushes.Black;
            int i = e.Index;
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
                e.Graphics.FillRectangle(Brushes.White, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
                myBrush = new SolidBrush(Color.FromArgb(255, 71, 71, 71));
            }
            myFont = new Font("Arial", 12, FontStyle.Bold);
            Rectangle myRect = e.Bounds;
            e.Graphics.DrawString(Tables[i].exName, myFont, myBrush, myRect, StringFormat.GenericTypographic);
        }
		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();
		}
예제 #15
0
		private void DrawItem(System.Windows.Forms.DrawItemEventArgs e, InterlinLineSpec spec)
		{
			bool selected = ((e.State & DrawItemState.Selected) != 0);
			Brush textBrush = GetBrush(spec, selected);
			try
			{
				Font drawFont = e.Font;
				e.DrawBackground();
				e.Graphics.DrawString(optionsList.Items[e.Index].ToString(), drawFont, textBrush, e.Bounds);
			}
			finally
			{
				if (!selected)
					textBrush.Dispose();
			}
		}
 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();
 }
예제 #17
0
    public void replaceItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
    {
        e.DrawBackground();

        Graphics G = e.Graphics;
        G.SmoothingMode = SmoothingMode.HighQuality;

        Rectangle rect = new Rectangle(e.Bounds.X - 1, e.Bounds.Y - 1, e.Bounds.Width + 1, e.Bounds.Height + 1);

        try
        {
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                G.FillRectangle(new SolidBrush(Color.FromArgb(20, 160, 230)), rect);
                G.DrawString(base.GetItemText(base.Items[e.Index]), Font, Brushes.White, new Rectangle(e.Bounds.X + 6, e.Bounds.Y + 3, e.Bounds.Width, e.Bounds.Height));
                G.DrawRectangle(new Pen(Color.FromArgb(20, 160, 230)), rect);
            }
            else
            {
                G.FillRectangle(Brushes.White, rect);
                G.DrawString(base.GetItemText(base.Items[e.Index]), Font, Brushes.DarkGray, new Rectangle(e.Bounds.X + 6, e.Bounds.Y + 3, e.Bounds.Width, e.Bounds.Height));
                G.DrawRectangle(new Pen(Color.FromArgb(20, 160, 230)), rect);
            }

        }
        catch
        {
        }
    }
예제 #18
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();
		}
예제 #19
0
        private void _toolTip_Draw(object sender, System.Windows.Forms.DrawToolTipEventArgs e)
        {
            System.Windows.Forms.ToolTip tt = (System.Windows.Forms.ToolTip)sender;

            if (e.AssociatedControl == this)
            {
                // draws default background
                e.DrawBackground();

                // draws custom 3D-like border
                e.Graphics.DrawLines(SystemPens.ControlLightLight, new Point[] {
                    new Point (0, e.Bounds.Height - 1),
                    new Point (0, 0),
                    new Point (e.Bounds.Width - 1, 0)
                });
                e.Graphics.DrawLines(SystemPens.ControlDarkDark, new Point[] {
                    new Point (0, e.Bounds.Height - 1),
                    new Point (e.Bounds.Width - 1, e.Bounds.Height - 1),
                    new Point (e.Bounds.Width - 1, 0)
                });

                // sets a font for the tooltip text
                Font font = new Font("Georgia", 10, FontStyle.Bold);

                // draws title
                System.Windows.Forms.TextRenderer.DrawText(e.Graphics, tt.ToolTipTitle, font, new Rectangle(0, 0, e.Bounds.Width, 20), Color.Black);

                //draws line between title and text
                e.Graphics.DrawLine(Pens.Black, 0, 21, e.Bounds.Width, 21);

                // reduces font size and sets flags
                font = new Font("Georgia", 9, FontStyle.Regular);
                System.Windows.Forms.TextFormatFlags flags = System.Windows.Forms.TextFormatFlags.WordBreak |
                    System.Windows.Forms.TextFormatFlags.TextBoxControl |
                    System.Windows.Forms.TextFormatFlags.EndEllipsis;

                // draws custom text (e.ToolTipText = "something")
                TrainingItem item = (TrainingItem)tt.Tag;
                StringBuilder sb = new StringBuilder(spanish ? "Fecha de inicio: " : "Start date: ");
                sb.Append(item.StartDate.ToShortDateString()).Append("\n");
                if (item.Type != TrainingEvent.TrainingSession)
                    sb.Append(spanish ? "Finalización: " : "End date: ").Append(item.EndDate.ToShortDateString()).Append("\n");
                if ((item.Type == TrainingEvent.Microcycle || item.Type == TrainingEvent.Mesocycle) && item.Orientation != null)
                    sb.Append(spanish ? "Orientación: " : "Orientation: ").Append(item.Orientation).Append("\n");
                sb.Append(spanish ? "Objetivo: " : "Objective: ").Append(item.Objective != null ? item.Objective : "N/A");

                System.Windows.Forms.TextRenderer.DrawText(e.Graphics, sb.ToString(), font, new Rectangle(0, 25, e.Bounds.Width, e.Bounds.Height - 25), Color.Black, flags);
            }
        }
예제 #20
0
        private void tabButtons_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Index == -1) {
                return;
            }

            // Draw the background of the ListBox control for each item.
            e.DrawBackground();

            // Create a new Brush and initialize to a Black colored brush by default.
            Brush myBrush = Brushes.Black;

            // Determine the color of the brush to draw each item based on the index of the item to draw.
            myBrush = Brushes.White;

            StringFormat textFormat = StringFormat.GenericDefault.Clone() as StringFormat;
            textFormat.Alignment =  StringAlignment.Center;

            SizeF textSize = e.Graphics.MeasureString(tabButtons.Items[e.Index].ToString(), e.Font, new Point(e.Bounds.X, e.Bounds.Y), textFormat);

            Rectangle bounds = e.Bounds;//new Rectangle(e.Bounds.X,e.Bounds.Y,e.Bounds.Width,e.Bounds.Height);
            bounds.Y += bounds.Height;
            bounds.Y -= Convert.ToInt32(textSize.Height);

            e.Graphics.DrawString(tabButtons.Items[e.Index].ToString(), e.Font, myBrush,bounds, textFormat);

            Bitmap img = tabBitmaps[e.Index] as Bitmap;
            Rectangle imgBounds = e.Bounds;

            Point imgPos = new Point(e.Bounds.X, e.Bounds.Y+2);
            imgPos.X += (e.Bounds.Width-img.Width)/2;
            imgPos.Y += ((e.Bounds.Height-Convert.ToInt32(textSize.Height))/2) - ((img.Width)/2);
            e.Graphics.DrawImage(img, imgPos);

            if (e.Index == selectedIndex) {
                Rectangle borderRect = e.Bounds;
                borderRect.Height = borderRect.Height - 1;
                borderRect.Width = borderRect.Width - 1;
                e.Graphics.DrawRectangle(new Pen(SystemColors.ControlDarkDark), borderRect);
            }
        }
예제 #21
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();
     }
 }
예제 #22
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();
        }
예제 #23
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);
            }
        }
예제 #24
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();
		}
		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();
		}
예제 #26
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.
        }
예제 #27
0
        //private void GroupListBox_DrawItem(object sender, DrawItemEventArgs e)
        //{
        //    e.DrawBackground();
        //    e.Graphics.DrawString(GroupListBox_DrawItem.Items[e.Index].ToString(), new FontFamily("Arial"), Brushes.Black, e.Bounds);
        //    e.DrawFocusRectangle();
        //}
        private void myListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            System.Drawing.Font myFont;
            System.Drawing.Brush myBrush;
            int i = e.Index;

            if (e.Index == 3)
            {
                myFont = e.Font;
                myBrush = System.Drawing.Brushes.Black;
            }
            else
            {
                myFont = new System.Drawing.Font("Microsoft Sans Serif", 9.75f, System.Drawing.FontStyle.Bold);
                myBrush = System.Drawing.Brushes.CadetBlue;
            }
            //System.Drawing.PointF p;
            //p.X = e.Bounds.X;
            //p.Y = e.Bounds.Y;
            e.Graphics.DrawString(GroupListBox.Items[i].ToString(), myFont, myBrush, e.Bounds.X, e.Bounds.Y);
            //e.Graphics.DrawString()
            //e.Graphics.DrawString(GroupListBox.Items[i].ToString(), myFont, myBrush, e.Bounds, System.Drawing.StringFormat.GenericDefault);
            //e.Graphics.DrawString(GroupListBox.Items[i].ToString(), myFont, myBrush, e.Bounds, System.Drawing.StringFormat.GenericDefault);
        }
예제 #28
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();
        }
예제 #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();
        }
예제 #30
0
		private void detailList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
		{
			if (e.Index >= 0) 
			{
				e.DrawBackground();
				TestResultItem item = (TestResultItem) detailList.Items[e.Index];
				bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? true : false;
				Brush brush = selected ? SystemBrushes.HighlightText : SystemBrushes.WindowText;
				RectangleF layoutRect = e.Bounds;
				if ( this.WordWrap && layoutRect.Width > detailList.ClientSize.Width )
					layoutRect.Width = detailList.ClientSize.Width;
				e.Graphics.DrawString(item.ToString(),detailList.Font, brush, layoutRect);
				
			}
		}