DrawBackground() public méthode

public DrawBackground ( ) : void
Résultat void
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();
            if (e.Index >= 0 && e.Index < Items.Count)
            {
                Device dev = (Device)Items[e.Index];
                Image image = ImageList.Images[dev.ImageKey];
                image = ResizeImage(image, 48, 48);

                Rectangle r = e.Bounds;
                r.Size = image.Size;
                r.X += 2;
                r.Y += (e.Bounds.Height - r.Height) / 2;
                e.Graphics.DrawImageUnscaled(image, r);

                r = e.Bounds;
                r.X += image.Width + 2;
                r.Width -= image.Width + 2;
                using (StringFormat sf = new StringFormat())
                {
                    sf.LineAlignment = StringAlignment.Center;
                    e.Graphics.DrawString(dev.Name, Font, new SolidBrush(ForeColor), r, sf);
                }
            }
            base.OnDrawItem(e);
        }
 protected override void OnDrawItem(DrawItemEventArgs e)
 {
     Graphics g = e.Graphics;
     Color BlockColor = Color.Empty;
     int left = RECTCOLOR_LEFT;
     if (e.State == DrawItemState.Selected || e.State == DrawItemState.None)
         e.DrawBackground();
     if (e.Index == -1)
     {
         BlockColor = SelectedIndex < 0 ? BackColor : DesignerUtility.ColorFromHtml(this.Text, Color.Empty);
     }
     else
         BlockColor = DesignerUtility.ColorFromHtml((string)this.Items[e.Index], Color.Empty);
     // Fill rectangle
     if (BlockColor.IsEmpty && this.Text.StartsWith("="))
     {
         g.DrawString("fx", this.Font, Brushes.Black, e.Bounds);
     }
     else
     {
         g.FillRectangle(new SolidBrush(BlockColor), left, e.Bounds.Top + RECTCOLOR_TOP, RECTCOLOR_WIDTH,
             ItemHeight - 2 * RECTCOLOR_TOP);
     }
     base.OnDrawItem(e);
 }
Exemple #3
0
        private void tabControl1_DrawItem(Object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;
            Brush    _textBrush;

            // Get the item from the collection.
            TabPage _tabPage = tabControl1.TabPages[e.Index];

            // Get the real bounds for the tab rectangle.
            Rectangle _tabBounds = tabControl1.GetTabRect(e.Index);

            if (e.State == DrawItemState.Selected)
            {
                // Draw a different background color, and don't paint a focus rectangle.
                _textBrush = new SolidBrush(Color.Red);
                g.FillRectangle(Brushes.Gray, e.Bounds);
            }
            else
            {
                _textBrush = new System.Drawing.SolidBrush(e.ForeColor);
                e.DrawBackground();
            }

            // Use our own font.
            Font _tabFont = new Font("Arial", (float)10.0, FontStyle.Bold, GraphicsUnit.Pixel);

            // Draw string. Center the text.
            StringFormat _stringFlags = new StringFormat();

            _stringFlags.Alignment     = StringAlignment.Center;
            _stringFlags.LineAlignment = StringAlignment.Center;
            g.DrawString(_tabPage.Text, _tabFont, _textBrush, _tabBounds, new StringFormat(_stringFlags));
        }
Exemple #4
0
        private void myListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            Font  myFont;
            Brush myBrush;
            int   i = e.Index;

            myFont = e.Font;

            try
            {
                if (StringContainsMedia(linkLines[e.Index]))
                {
                    myBrush = Brushes.Green;
                }
                else
                {
                    myBrush = Brushes.Blue;
                }
                e.Graphics.DrawString(listBox1.Items[i].ToString(), myFont, myBrush, e.Bounds, StringFormat.GenericDefault);
            }
            catch
            {
            }
        }
Exemple #5
0
        // Stolen from Microsoft
        private void tcMain_DrawItem(Object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;
            Brush    _textBrush;

            // Get the item from the collection.
            TabPage _tabPage = tcMain.TabPages[e.Index];

            // Get the real bounds for the tab rectangle.
            Rectangle _tabBounds = tcMain.GetTabRect(e.Index);

            if (e.State == DrawItemState.Selected)
            {
                // Selected tab text color
                _textBrush = new SolidBrush(ColorPalette.White);
                // Selected tab background color
                g.FillRectangle(new SolidBrush(ColorPalette.DarkBlue), e.Bounds);
            }
            else
            {
                // Rest of tabs text color
                _textBrush = new SolidBrush(ColorPalette.SemiDarkBlue);
                e.DrawBackground();
            }

            // Use our own font.
            Font _tabFont = new Font("Segoe UI", 16.0f, FontStyle.Bold, GraphicsUnit.Pixel);

            // Draw string. Center the text.
            StringFormat _stringFlags = new StringFormat();

            _stringFlags.Alignment     = StringAlignment.Center;
            _stringFlags.LineAlignment = StringAlignment.Center;
            g.DrawString(_tabPage.Text, _tabFont, _textBrush, _tabBounds, new StringFormat(_stringFlags));
        }
Exemple #6
0
        /// <summary>
        /// For MultiExtended and MultiSimple selection modes we will draw the items ourselves
        /// to keep track of which item has the focus.
        /// </summary>
        /// <param name="sender">The ListBox raising the event.</param>
        /// <param name="e">The DrawItemEventArgs for the current item to draw.</param>
        private void ListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            System.Windows.Forms.ListBox lstBox = (System.Windows.Forms.ListBox)sender;
            e.DrawBackground();
            using (Brush myBrush = new SolidBrush(e.ForeColor))
            {
                if ((e.Index < 0) || (e.Index >= lstBox.Items.Count))
                {
                    return;
                }

                if (selectedIndexList.ContainsKey(lstBox))
                {
                    if ((e.State & DrawItemState.Focus) == DrawItemState.Focus)
                    {
                        selectedIndexList[lstBox] = e.Index;
                    }
                }

                // Draw the current item text based on the current Font and the custom brush settings.
                e.Graphics.DrawString(lstBox.Items[e.Index].ToString(), e.Font, myBrush, e.Bounds, StringFormat.GenericDefault);
                // If the ListBox has focus, draw a focus rectangle around the selected item.
                e.DrawFocusRectangle();
            }
        }
Exemple #7
0
        protected override void OnDrawItem(swf.DrawItemEventArgs e)
        {
            if (e.State.HasFlag(swf.DrawItemState.ComboBoxEdit))
            {
                var bounds = e.Bounds;
                bounds.Inflate(2, 2);
                // only show the background color for the drop down, not for each item
                e.Graphics.FillRectangle(new sd.SolidBrush(BackColor), bounds);
            }
            else
            {
                e.DrawBackground();
            }

            if (e.Index >= 0)
            {
                var item   = Items[e.Index];
                var bounds = e.Bounds;
                var image  = (item as EtoComboBoxItem)?.Image;

                if (image != null)
                {
                    e.Graphics.DrawImage(image.ToSD(new Size(16, 16)), bounds.X, bounds.Y, 16, 16);
                    bounds.X     += 18;
                    bounds.Width -= 18;
                }

                string text = item?.ToString();

                // Determine the forecolor based on whether or not the item is selected
                swf.TextRenderer.DrawText(e.Graphics, text, Font, bounds, ForeColor, swf.TextFormatFlags.Left);
            }

            e.DrawFocusRectangle();
        }
Exemple #8
0
        private void drawItems(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();

            int i = e.Index;
            if (i != -1)
            {

                Font myFont;
                Brush myBrush;
                string dir = currentDir + "\\" + MovieBox.Items[i];

                string[] content = Directory.GetFiles(dir, "*.nfo", SearchOption.TopDirectoryOnly);
                if (content.Length == 0 && i != 0)
                {
                    myFont = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold);
                    myBrush = Brushes.Red;
                }
                else
                {
                    myFont = e.Font;
                    myBrush = Brushes.Black;
                }

                e.Graphics.DrawString(MovieBox.Items[i].ToString(), myFont, myBrush, e.Bounds, StringFormat.GenericDefault);
            }
        }
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();

            if (e.Index < 0)
                return;

            FontFamily fontFamily = Items[e.Index] as FontFamily;

            if ((e.State & DrawItemState.ComboBoxEdit) != 0)
            {
                Font font = e.Font;
                if (DrawFontInEditBox)
                {
                    if (!fontsInCache)
                    {
                        font = CreateDefaultFont(fontFamily, e.Font.Size);
                        if (font == null)
                            font = e.Font;
                    }
                    else
                    {
                        font = fonts[fontFamily.Name];
                        if (font == null)
                            font = e.Font;
                    }
                }

                e.Graphics.DrawString(fontFamily.Name, font, new SolidBrush(e.ForeColor),
                    e.Bounds.Left, e.Bounds.Top);
            }
            else
            {
                Font font = e.Font;
                if (DrawFont)
                {
                    if (!fontsInCache)
                    {
                        font = CreateDefaultFont(fontFamily, e.Font.Size);
                        if (font == null)
                            font = e.Font;
                    }
                    else
                    {
                        font = fonts[fontFamily.Name];
                        if (font == null)
                            font = e.Font;
                    }
                }

                e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
                e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighSpeed;
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
                e.Graphics.DrawString(fontFamily.Name, font, new SolidBrush(e.ForeColor),
                    e.Bounds.Left, e.Bounds.Top);
            }
        }
Exemple #10
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            e.DrawBackground();

            if (Items.Count <= 0)
            {
                base.OnDrawItem(e);
                return;
            }

            Color color;

            color = ColorGetter == null ? SystemColors.WindowText
                    : ColorGetter(e.Index, Items[e.Index]);

            if(color == SystemColors.WindowText
                && ((e.State & DrawItemState.Selected) == DrawItemState.Selected))
                color = SystemColors.HighlightText;

            using (Brush b = new SolidBrush(color))
            {
                e.Graphics.DrawString(Convert.ToString(Items[e.Index]), e.Font, b, e.Bounds);
            }

            if((e.State & DrawItemState.Focus) == DrawItemState.Focus)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);
            }
        }
Exemple #11
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (e.Index >= 0 && e.Index < Items.Count)
            {
                this.ItemHeight = newItemHeight;
                Window window = Items[e.Index] as Window;
                String title = window.getTitle().Replace("&", "&&");
                String processName = window.getProcessName().Replace("&", "&&");

                e.DrawBackground();

                // Draw icon
                Icon icon = window.getIcon();
                if (icon != null)
                {
                    Image image = (Image)new Bitmap(icon.ToBitmap(), new Size(iconSize, iconSize));
                    e.Graphics.DrawImage(image, iconMargin, e.Bounds.Y + iconMargin);
                }

                // Draw window title
                Rectangle titleRect = e.Bounds;
                titleRect.Height /= 2;
                titleRect.X += iconSize + 3 * iconMargin;
                titleRect.Width -= iconSize + 3 * iconMargin;
                TextRenderer.DrawText(e.Graphics, title, titleFont, titleRect, e.ForeColor, titleFlags);

                // Draw process name title
                Rectangle processRect = titleRect;
                processRect.Y += processRect.Height;
                TextRenderer.DrawText(e.Graphics, processName, processFont, processRect, processColor, processFlags);
                e.DrawFocusRectangle();
            }
        }
        private void settings2_3_booknamefont_DrawItem(object sender, DrawItemEventArgs e)
        {
            Font objFonts = new Font(settings2_3_booknamefont.Items[e.Index].ToString(), 14);
            e.DrawBackground();

            e.Graphics.DrawString(settings2_3_booknamefont.Items[e.Index].ToString(), objFonts, new SolidBrush(e.ForeColor), new Point(e.Bounds.Left, e.Bounds.Top));
        }
Exemple #13
0
 private void comboBoxColor_DrawItem(object sender, DrawItemEventArgs e)
 {
     var box = (ComboBox) sender;
     if ((e.State & DrawItemState.Selected) != DrawItemState.None) {
         e.DrawBackground();
     }
     else {
         e.Graphics.FillRectangle(Brushes.White, e.Bounds);
     }
     if ((e.State & DrawItemState.Focus) != DrawItemState.None) {
         e.DrawFocusRectangle();
     }
     if (e.Index == 0) {
         e.Graphics.DrawString(box.Items[e.Index].ToString(), box.Font, Brushes.Black, e.Bounds);
     }
     else if ((e.Index >= 0) && (e.Index < box.Items.Count)) {
         var bounds = e.Bounds;
         bounds.Inflate(-16, -2);
         var boxItems = box.Items[e.Index] as string;
         if (boxItems == null) {
             return;
         }
         using (var brush = new SolidBrush(Color.FromArgb(int.Parse(boxItems.Substring(1))))) {
             e.Graphics.FillRectangle(brush, bounds);
             e.Graphics.DrawRectangle(Pens.Black, bounds);
         }
     }
 }
Exemple #14
0
        protected override void OnDrawItem( DrawItemEventArgs e )
        {
            if ( Items.Count == 0 )
            {
                base.OnDrawItem( e );
                return;
            }

            if ( Items[ e.Index ] is Friend )
            {
                Friend friendObj = ( Friend )Items[ e.Index ];

                this.DrawMode = DrawMode.OwnerDrawFixed;

                e.DrawBackground();

                e.DrawFocusRectangle();

                EPersonaState state = SteamContext.SteamFriends.GetFriendPersonaState( friendObj.SteamID );

                if ( state == EPersonaState.k_EPersonaStateOffline )
                    e.Graphics.DrawString( friendObj.PersonaName, e.Font, new SolidBrush( Color.Red ), e.Bounds );
                else
                    e.Graphics.DrawString( friendObj.PersonaName, e.Font, new SolidBrush( Color.Green ), e.Bounds );
            }
        }
Exemple #15
0
            protected override void OnDrawItem(swf.DrawItemEventArgs e)
            {
                e.DrawBackground();
                e.DrawFocusRectangle();

                if (e.Index == -1)
                {
                    return;
                }
                using (var foreBrush = new sd.SolidBrush(this.ForeColor))
                {
                    var bounds    = e.Bounds;
                    var item      = Items[e.Index] as IListItem;
                    var imageitem = item as IImageListItem;
                    if (imageitem != null && imageitem.Image != null)
                    {
                        var img = imageitem.Image.Handler as IWindowsImage;
                        if (img != null)
                        {
                            e.Graphics.DrawImage(img.GetImageWithSize(bounds.Height), bounds.Left, bounds.Top, bounds.Height, bounds.Height);
                        }
                        bounds.X += bounds.Height + 2;
                    }
                    var stringSize = e.Graphics.MeasureString(item.Text, e.Font);
                    var adjust     = Math.Max(0, (bounds.Height - stringSize.Height) / 2);
                    e.Graphics.DrawString(item.Text, e.Font, foreBrush, bounds.Left, bounds.Top + adjust);
                }
                base.OnDrawItem(e);
            }
        private void annotationListBox_DrawItem( object sender, DrawItemEventArgs e )
        {
            e.DrawBackground();
            AnnotationListItem item = (AnnotationListItem) annotationListBox.Items[e.Index];
            e.Graphics.DrawString( item.annotation.Point.ToString("f3"),
                annotationListBox.Font,
                new SolidBrush( annotationListBox.ForeColor ),
                new PointF( (float) e.Bounds.X, (float) e.Bounds.Y ) );

            string label;
            if( item.annotation.Label.Contains(" ") )
                label = "\"" + item.annotation.Label + "\"";
            else
                label = item.annotation.Label;
            e.Graphics.DrawString( label,
                annotationListBox.Font,
                new SolidBrush( annotationListBox.ForeColor ),
                new PointF( (float) e.Bounds.X + ( ( e.Bounds.Width / 2 ) - ( e.Bounds.Height * 2 ) ), (float) e.Bounds.Y ) );

            Rectangle colorSampleBox = new Rectangle( e.Bounds.Location, e.Bounds.Size );
            colorSampleBox.X = e.Bounds.Right - e.Bounds.Height * 2;
            colorSampleBox.Location.Offset( -5, 0 );
            e.Graphics.FillRectangle( new SolidBrush( ownerGraphForm.ZedGraphControl.GraphPane.Chart.Fill.Color ), colorSampleBox );
            int middle = colorSampleBox.Y + colorSampleBox.Height / 2;
            e.Graphics.DrawLine( new Pen( item.annotation.Color, item.annotation.Width ), colorSampleBox.Left, middle, colorSampleBox.Right, middle );
            e.DrawFocusRectangle();
        }
Exemple #17
0
		public void Drawitem(object sender, DrawItemEventArgs e)
		{
			if (e.Index < 0)
				return;
			e.DrawBackground();
			e.DrawFocusRectangle();

			e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
			e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
			e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
			e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

			//-- if selected
			if (e.State.ToString().IndexOf("Selected,") >= 0)
			{
				//-- Base
				e.Graphics.FillRectangle(new SolidBrush(_SelectedColor), new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));

				//-- Text
				e.Graphics.DrawString(" " + ListBx.Items[e.Index].ToString(), new Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2);
			}
			else
			{
				//-- Base
				e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(51, 53, 55)), new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));

				//-- Text 
				e.Graphics.DrawString(" " + ListBx.Items[e.Index].ToString(), new Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2);
			}

			e.Graphics.Dispose();
		}
Exemple #18
0
 private void ComboBoxBase_DrawItem(object sender, DrawItemEventArgs e)
 {
     e.DrawBackground();
     if (e.Index >= 0)
     {
         string data;
         Color highlightText;
         if ((e.State & DrawItemState.ComboBoxEdit) == DrawItemState.ComboBoxEdit)
         {
             data = ((ComboExItem) this.dropDownSource[e.Index]).Data;
         }
         else
         {
             ComboExItem item = (ComboExItem) this.dropDownSource[e.Index];
             if ((item.Display != null) && (item.Display.Length > 0))
             {
                 data = item.Data + ":" + item.Display;
             }
             else
             {
                 data = item.Data;
             }
         }
         if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
         {
             highlightText = SystemColors.HighlightText;
         }
         else
         {
             highlightText = e.ForeColor;
         }
         TextRenderer.DrawText(e.Graphics, data, this.Font, new Point(e.Bounds.X, e.Bounds.Y), highlightText);
     }
 }
Exemple #19
0
        private void xxcbDrawItem(object sender, DrawItemEventArgs e)
        {
            //drawItems here
            if (sender == null)
                return;
            if (e.Index < 0)
                return;
            //Get the Combo from the sender object
            ComboBox cbo = (ComboBox)sender;
            //Get the FontFamily from put in constructor
            FontFamily ff = new FontFamily(cbo.Items[e.Index].ToString());
            //Set font style
            FontStyle fs = FontStyle.Regular;
            if (!ff.IsStyleAvailable(fs))
                fs = FontStyle.Italic;
            if (!ff.IsStyleAvailable(fs))
                fs = FontStyle.Bold;
            //Set font for drawing with (wich is the font itself)
            Font font = new Font(ff, 8, fs);

            //draw the background and focus rectangle
            e.DrawBackground();
            e.DrawFocusRectangle();
            //get graphics
            Graphics g = e.Graphics;
            //And draw with whatever font and brush we wish
            g.DrawString(font.Name, font, Brushes.ForestGreen, e.Bounds.X, e.Bounds.Y);

        }
Exemple #20
0
            protected override void OnDrawItem(swf.DrawItemEventArgs e)
            {
                e.DrawBackground();
                e.DrawFocusRectangle();

                if (e.Index == -1)
                {
                    return;
                }
                using (var foreBrush = new sd.SolidBrush(this.ForeColor)) {
                    var bounds    = e.Bounds;
                    var imageitem = Items[e.Index] as IImageListItem;
                    if (imageitem != null)
                    {
                        int offset = bounds.Left;
                        if (imageitem.Image != null)
                        {
                            var img = imageitem.Image.Handler as IWindowsImage;
                            if (img != null)
                            {
                                e.Graphics.DrawImage(img.GetImageWithSize(bounds.Height), bounds.Left, bounds.Top, bounds.Height, bounds.Height);
                            }
                            offset += bounds.Height + 2;
                        }
                        e.Graphics.DrawString(imageitem.Text, e.Font, foreBrush, offset, bounds.Top);
                    }
                    else
                    {
                        var item = Items[e.Index] as IListItem;
                        e.Graphics.DrawString(item.Text, e.Font, foreBrush, bounds.Left, bounds.Top);
                    }
                }
                base.OnDrawItem(e);
            }
Exemple #21
0
            protected override void OnDrawItem(swf.DrawItemEventArgs e)
            {
                e.DrawBackground();
                e.DrawFocusRectangle();

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

                var bounds = e.Bounds;
                var item   = Items[e.Index];
                var text   = handler.Widget.ItemTextBinding?.GetValue(item) ?? string.Empty;
                var image  = handler.Widget.ItemImageBinding?.GetValue(item).ToSD(new Size(bounds.Width, bounds.Height - ItemPadding * 2));

                if (image != null)
                {
                    // just in case, make image fit in our bounds
                    var imageHeight = bounds.Height - ItemPadding * 2;
                    var imageWidth  = imageHeight * image.Width / image.Height;
                    e.Graphics.DrawImage(image, bounds.X + ItemPadding, bounds.Y + ItemPadding, imageWidth, imageHeight);
                    bounds.X += imageWidth + ItemPadding * 2;
                }
                var stringSize = swf.TextRenderer.MeasureText(e.Graphics, text, e.Font);

                bounds.Y += Math.Max(0, (bounds.Height - stringSize.Height) / 2);
                var foreColor = e.State.HasFlag(swf.DrawItemState.Selected) ? sd.SystemColors.HighlightText : ForeColor;

                swf.TextRenderer.DrawText(e.Graphics, text, e.Font, bounds, foreColor, swf.TextFormatFlags.Left);
            }
Exemple #22
0
 private void this_DrawItem(object sender, DrawItemEventArgs e) {
     if (e.Index == -1) return;
     e.DrawBackground();
     if ((e.State & DrawItemState.Selected) != 0) {
         e.Graphics.FillRectangle(_highlightbrush, e.Bounds);
     }
     EXItem item = (EXItem) this.Items[e.Index];
     Rectangle bounds = e.Bounds;
     int x = bounds.X + 2;
     if (item.GetType() == typeof(EXImageItem)) {
         EXImageItem imgitem = (EXImageItem) item;
         if (imgitem.MyImage != null) {
             Image img = imgitem.MyImage;
             int y = bounds.Y + ((int) (bounds.Height / 2)) - ((int) (img.Height / 2)) + 1;
             e.Graphics.DrawImage(img, x, y, img.Width, img.Height);
             x += img.Width + 2;
         }
     } else if (item.GetType() == typeof(EXMultipleImagesItem)) {
         EXMultipleImagesItem imgitem = (EXMultipleImagesItem) item; 
         if (imgitem.MyImages != null) {
             for (int i = 0; i < imgitem.MyImages.Count; i++) {
                 Image img = (Image) imgitem.MyImages[i];
                 int y = bounds.Y + ((int) (bounds.Height / 2)) - ((int) (img.Height / 2)) + 1;
                 e.Graphics.DrawImage(img, x, y, img.Width, img.Height);
                 x += img.Width + 2;
             }
         }
     }
     int fonty = bounds.Y + ((int) (bounds.Height / 2)) - ((int) (e.Font.Height / 2));
     e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor), x, fonty);
     e.DrawFocusRectangle();
 }
Exemple #23
0
        public void ReplaceItem(System.Object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            Graphics G  = e.Graphics;
            Color    C4 = Color.Empty;

            e.DrawBackground();
            try
            {
                if (e.State == DrawItemState.Selected && e.State == DrawItemState.Focus)
                {
                    G.FillRectangle(ConversionFunctions.ToBrush(50, 80, 120), new Rectangle(e.Bounds.X - 1, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height + 2));
                    G.DrawRectangle(new Pen(ConversionFunctions.ToBrush(180, Color.Black), 1), new Rectangle(e.Bounds.X - 1, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height + 2));
                    C4 = Color.FromArgb(100, 165, 185);
                }
                else
                {
                    G.FillRectangle(ConversionFunctions.ToBrush(62, 60, 58), new Rectangle(e.Bounds.X - 1, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height + 2));
                    C4 = Color.FromArgb(200, 200, 200);
                }

                G.DrawString(base.GetItemText(base.Items[e.Index]), e.Font, ConversionFunctions.ToBrush(C4), e.Bounds, new StringFormat
                {
                    LineAlignment = StringAlignment.Center,
                    Alignment     = StringAlignment.Center
                });
            }
            catch
            {
            }
        }
 protected override void OnDrawItem(DrawItemEventArgs e)
 {
     if (e.Index < 0)
     {
         base.OnDrawItem(e);
     }
     else
     {
         object listItem = this.Items[e.Index];
         ListControlConvertEventArgs args = new ListControlConvertEventArgs(listItem.ToString(), typeof(string), listItem);
         this.OnFormat(args);
         string str = (string) args.Value;
         if (!string.IsNullOrEmpty(str))
         {
             e.DrawBackground();
             TextRenderer.DrawText(e.Graphics, str, e.Font, e.Bounds, e.ForeColor, TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);
             e.DrawFocusRectangle();
         }
         else
         {
             int num = e.Bounds.Top + (e.Bounds.Height / 2);
             e.Graphics.DrawLine(SystemPens.ControlText, e.Bounds.Left, num, e.Bounds.Right, num);
         }
     }
 }
        protected override void OnDrawItem(DrawItemEventArgs ea)
        {
            ea.DrawBackground();
            ea.DrawFocusRectangle();

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

            Rectangle bounds = ea.Bounds;
            var foreBrush = new SolidBrush(ea.ForeColor);
            int textLeftBound = (IconList == null) ? bounds.Left : bounds.Left + IconList.ImageSize.Width;

            var drawObject = Items[ea.Index];
            if (drawObject is ImageComboBoxItem) {
                var drawItem = (ImageComboBoxItem)drawObject;

                if (drawItem.ImageListIndex != -1 && IconList != null) {
                    //ea.Graphics.FillRectangle(Brushes.Gray, bounds.Left, bounds.Top, IconList.ImageSize.Width, IconList.ImageSize.Height);
                    ea.Graphics.DrawImage(IconList.Images[drawItem.ImageListIndex], bounds.Left, bounds.Top);
                }

                ea.Graphics.DrawString(drawItem.Text, ea.Font, foreBrush, textLeftBound, bounds.Top);
            }
            else {
                ea.Graphics.DrawString(drawObject.ToString(), ea.Font, foreBrush, textLeftBound, bounds.Top);
            }

            base.OnDrawItem(ea);
        }
Exemple #26
0
 private void listBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     listBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
     e.DrawBackground();
     System.Drawing.SolidBrush brush = null;
     //如果是RGB颜色,需要在最高位加FF,如: 0xFF102030
     if (e.Index == -1)
     {
         return;
     }                              // 如果listbox里面没有数据,点击会引发异常,如果指为-1,跳出
     if ((listBox.Items[e.Index] as ListBoxItem).LogType == TamPub1.MemoryLog.LogTypeCommon)
     {
         brush = new System.Drawing.SolidBrush(System.Drawing.Color.Aqua);
     }
     else if ((listBox.Items[e.Index] as ListBoxItem).LogType == TamPub1.MemoryLog.LogTypeWarning)
     {
         brush = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow);
     }
     else if ((listBox.Items[e.Index] as ListBoxItem).LogType == TamPub1.MemoryLog.LogTypeError)
     {
         brush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
     }
     e.Graphics.DrawString(listBox.Items[e.Index].ToString(), e.Font, brush, e.Bounds, System.Drawing.StringFormat.GenericDefault);
     e.DrawFocusRectangle();
 }
 public void DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     if (e.Index < 0)
     {
         return;
     }
     e.DrawBackground();
     e.DrawFocusRectangle();
     if (String.Compare(e.State.ToString(), "Selected,") > 0)
     {
         e.Graphics.FillRectangle(Brushes.Black, e.Bounds);
         Rectangle           x2 = new Rectangle(e.Bounds.Location, new Size(e.Bounds.Width - 1, e.Bounds.Height));
         Rectangle           x3 = new Rectangle(x2.Location, new Size(x2.Width, (x2.Height / 2) - 2));
         LinearGradientBrush G1 = new LinearGradientBrush(new Point(x2.X, x2.Y), new Point(x2.X, x2.Y + x2.Height), Color.FromArgb(60, 60, 60), Color.FromArgb(50, 50, 50));
         HatchBrush          H  = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(15, Color.Black), Color.Transparent);
         e.Graphics.FillRectangle(G1, x2);
         G1.Dispose();
         e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(25, Color.White)), x3);
         e.Graphics.FillRectangle(H, x2);
         G1.Dispose();
         e.Graphics.DrawString(" " + LBox.Items[e.Index].ToString(), Font, Brushes.White, e.Bounds.X, e.Bounds.Y + 2);
     }
     else
     {
         e.Graphics.DrawString(" " + LBox.Items[e.Index].ToString(), Font, Brushes.White, e.Bounds.X, e.Bounds.Y + 2);
     }
 }
Exemple #28
0
        private void tabControl1_DrawItem(object sender,
                                          System.Windows.Forms.DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;
            Brush    _TextBrush;

            // Get the item from the collection.
            TabPage _TabPage = tabControl1.TabPages[e.Index];

            // Get the real bounds for the tab rectangle.
            Rectangle _TabBounds = tabControl1.GetTabRect(e.Index);

            if (e.State == DrawItemState.Selected)
            {
                // Draw a different background color, and don't paint a focus rectangle.
                _TextBrush = new SolidBrush(Color.White);
                g.FillRectangle(Brushes.Black, e.Bounds);
            }
            else
            {
                _TextBrush = new System.Drawing.SolidBrush(Color.Black);
                e.DrawBackground();
            }

            // Use our own font. Because we CAN.
            Font _TabFont = new Font("Comic Sans Ms", 14, FontStyle.Bold, GraphicsUnit.Pixel);

            // Draw string. Center the text.
            StringFormat _StringFlags = new StringFormat();

            _StringFlags.Alignment     = StringAlignment.Center;
            _StringFlags.LineAlignment = StringAlignment.Center;
            g.DrawString(_TabPage.Text, _TabFont, _TextBrush,
                         _TabBounds, new StringFormat(_StringFlags));
        }
  protected override void OnDrawItem( DrawItemEventArgs e )
  {
   e.DrawBackground();
   e.DrawFocusRectangle();

   if( e.Index > -1 )
   {
    ComboBoxItem itm = (( ComboBoxItem ) Items[ e.Index ]);
    int x = e.Bounds.Left + ( 16 - itm.Img.Width ) / 2,
        y = ( 15 - itm.Img.Height ) / 2,
        w = itm.Img.Width,
        h = itm.Img.Height;

    x = ( x > 0 ) ? x : 0;
    y = (( y > 0 ) ? y : 0 ) + e.Bounds.Top;
    w = ( w > 15 ) ? 15 : w;
    h = ( h > 15 ) ? 15 : h;

    e.Graphics.DrawImage( itm.Img,
                          new Rectangle( x, y, w, h ),
                          new Rectangle( 0, 0, itm.Img.Width, itm.Img.Height ),
                          GraphicsUnit.Pixel );
    e.Graphics.DrawString( itm.Text,
                           e.Font,
                           new SolidBrush( e.ForeColor ),
                           x + w,
                           e.Bounds.Top + 2 );

   }

   base.OnDrawItem( e );

  }
        public void DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            e.DrawBackground();
            e.DrawFocusRectangle();
            if (String.Compare(e.State.ToString(), "Selected,") > 0)
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(224, 240, 240)), e.Bounds);
                Rectangle           x2 = new Rectangle(e.Bounds.Location, new Size(e.Bounds.Width - 1, e.Bounds.Height));
                Rectangle           x3 = new Rectangle(x2.Location, new Size(x2.Width, (x2.Height / 2) - 2));
                LinearGradientBrush G1 = new LinearGradientBrush(new Point(x2.X, x2.Y), new Point(x2.X, x2.Y + x2.Height), Color.FromArgb(60, 60, 60), Color.FromArgb(50, 50, 50));

                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(28, 126, 236)), x2);
                G1.Dispose();
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(66, 165, 255)), x3);

                e.Graphics.DrawString(" " + LBox.Items[e.Index].ToString(), this.Font, Brushes.Black, e.Bounds.X, e.Bounds.Y + 2);
            }
            else
            {
                e.Graphics.DrawString(" " + LBox.Items[e.Index].ToString(), this.Font, Brushes.Black, e.Bounds.X, e.Bounds.Y + 2);
            }
        }
Exemple #31
0
        private void tabControl1_DrawItem(Object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            Graphics  g = e.Graphics;
            Brush     _textBrush;
            TabPage   _tabPage   = tabControl1.TabPages[e.Index];
            Rectangle _tabBounds = tabControl1.GetTabRect(e.Index);

            if (e.State == DrawItemState.Selected)
            {
                _textBrush = new SolidBrush(Color.Black);
                g.FillRectangle(Brushes.LightGray, e.Bounds);
            }
            else
            {
                _textBrush = new System.Drawing.SolidBrush(e.ForeColor);
                e.DrawBackground();
            }

            Font         _tabFont     = new Font("Arial", (float)10.0, FontStyle.Bold, GraphicsUnit.Pixel);
            StringFormat _stringFlags = new StringFormat();

            _stringFlags.Alignment     = StringAlignment.Center;
            _stringFlags.LineAlignment = StringAlignment.Center;
            g.DrawString(_tabPage.Text, _tabFont, _textBrush, _tabBounds, new StringFormat(_stringFlags));
        }
Exemple #32
0
 protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
 {
     Skybound.ComponentModel.EnumTypeEditor.EnumValue enumValue = e.Index == -1 ? null : Items[e.Index] as Skybound.ComponentModel.EnumTypeEditor.EnumValue;
     e.DrawBackground();
     System.Drawing.Rectangle rectangle1 = e.Bounds;
     rectangle1.X++;
     rectangle1.Width -= 2;
     if (enumValue.Description.Length > 0)
     {
         rectangle1.Height >>= 1;
     }
     if (enumValue.Image != null)
     {
         e.Graphics.DrawImage(enumValue.Image, rectangle1.X + 3, rectangle1.Y + 2, enumValue.Image.Width, enumValue.Image.Height);
         rectangle1.X     += enumValue.Image.Width + 8;
         rectangle1.Width -= enumValue.Image.Width + 8;
     }
     using (System.Drawing.Font font = new System.Drawing.Font(e.Font, CurrentValue == enumValue.Name ? System.Drawing.FontStyle.Bold : System.Drawing.FontStyle.Regular))
     {
         Skybound.Windows.Forms.TextRenderer.DrawText(e.Graphics, enumValue.Name, font, e.ForeColor, System.Drawing.Color.Transparent, rectangle1, Skybound.Windows.Forms.TextFormatFlags.SingleLine | Skybound.Windows.Forms.TextFormatFlags.VerticalCenter);
     }
     if (enumValue.Description.Length > 0)
     {
         rectangle1.Y += rectangle1.Height;
         Skybound.Windows.Forms.TextRenderer.DrawText(e.Graphics, enumValue.Description, e.Font, System.Windows.Forms.ControlPaint.LightLight(e.ForeColor), System.Drawing.Color.Transparent, rectangle1, Skybound.Windows.Forms.TextFormatFlags.EndEllipsis | Skybound.Windows.Forms.TextFormatFlags.SingleLine | Skybound.Windows.Forms.TextFormatFlags.VerticalCenter);
     }
     System.Drawing.Rectangle rectangle2 = e.Bounds;
     System.Drawing.Rectangle rectangle3 = e.Bounds;
     System.Drawing.Rectangle rectangle4 = e.Bounds;
     System.Drawing.Rectangle rectangle5 = e.Bounds;
     e.Graphics.DrawLine(System.Drawing.SystemPens.Control, rectangle2.X, rectangle3.Bottom - 1, rectangle4.Right - 1, rectangle5.Bottom - 1);
 }
 private void lstFunnel_DrawItem(object sender, DrawItemEventArgs e)
 {
     dontRefresh = true;
     e.DrawBackground();
     FontStyle fs = FontStyle.Regular;
     Brush b = Brushes.Black;
     if (unselectableFunnelLines.Contains(e.Index))
     {
         b = Brushes.Gray;
         fs = FontStyle.Italic;
         if (e.State.HasFlag(DrawItemState.Selected))
         {
             //b = Brushes.White;
             lstFunnel.SelectedIndex = -1;
             lstFunnel.Invalidate();
         }
         e.Graphics.DrawString(lstFunnel.Items[e.Index].ToString(), new Font("Microsoft Sans Serif", 8, fs), b, e.Bounds);
     }
     else
     {
         if (e.State.HasFlag(DrawItemState.Selected)) b = Brushes.White;
         e.Graphics.DrawString(lstFunnel.Items[e.Index].ToString(), new Font("Microsoft Sans Serif", 8, fs), b, e.Bounds);
         e.DrawFocusRectangle();
     }
     dontRefresh = false;
 }
Exemple #34
0
        private void ListBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            if (ListBox1.Items.Count > 0)
            {
                e.DrawBackground();

                if ((e.Index % 2) == 1)
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 255, 255)), e.Bounds);
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(245, 245, 245)), e.Bounds);
                }

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


                using (SolidBrush b = new SolidBrush(e.ForeColor))
                {
                    e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias;
                    e.Graphics.DrawString(ListBox1.GetItemText(ListBox1.Items(e.Index)), e.Font, b, e.Bounds.Left + dpicalc(this, 20), ((e.Bounds.Height - ListBox1.Font.Height) / 2) + e.Bounds.Top);
                }
                e.DrawFocusRectangle();
            }
        }
        private void SecurityCB_DrawItem(object sender, DrawItemEventArgs e)
        {
            // If the index is invalid then simply exit.
            if (e.Index == -1 || e.Index >= SecurityCB.Items.Count)
            {
                return;
            }

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

            // Should we draw the focus rectangle?
            if ((e.State & DrawItemState.Focus) != 0)
            {
                e.DrawFocusRectangle();
            }

            Font f = new Font(e.Font, FontStyle.Regular);
            // Create a new background brush.
            Brush b = new SolidBrush(e.ForeColor);
            // Draw the item.
            Security security = (Security)SecurityCB.Items[e.Index];
            string name = security.ToString();
            SizeF s = e.Graphics.MeasureString(name, f);
            e.Graphics.DrawString(name, f, b, e.Bounds);
        }
Exemple #36
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();
        }
Exemple #37
0
        public void DrawItem_(System.Object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            e.DrawBackground();
            e.DrawFocusRectangle();

            e.Graphics.SmoothingMode     = (SmoothingMode)2;
            e.Graphics.PixelOffsetMode   = (PixelOffsetMode)2;
            e.Graphics.TextRenderingHint = (TextRenderingHint)5;
            e.Graphics.InterpolationMode = (InterpolationMode)7;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                //-- Selected item
                e.Graphics.FillRectangle(new SolidBrush(_HoverColor), e.Bounds);
            }
            else
            {
                //-- Not Selected
                e.Graphics.FillRectangle(new SolidBrush(_BaseColor), e.Bounds);
            }

            //-- Text
            e.Graphics.DrawString(base.GetItemText(base.Items[e.Index]), new Font("Segoe UI", 8), Brushes.White, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height));


            e.Graphics.Dispose();
        }
Exemple #38
0
        /// <summary>
        /// Overrides parent OnDrawItem method to perform custom painting
        /// </summary>
        /// <param name="pe"></param>
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs pe)
        {
            pe.DrawBackground();
            pe.DrawFocusRectangle();
            Rectangle bounds = pe.Bounds;

            // Check whether the index is valid
            if (pe.Index >= 0 && pe.Index < base.Items.Count)
            {
                ImageListBoxItem item = (ImageListBoxItem)base.Items[pe.Index];
                int iOffset           = 0;
                // If the image list is present and the image index is set, draw the image
                if (this.imageList != null)
                {
                    if (item.ImageIndex != -1 && item.ImageIndex < this.imageList.Images.Count)
                    {
                        this.imageList.Draw(pe.Graphics, bounds.Left, bounds.Top, item.ImageIndex);
                    }
                    iOffset += this.imageList.ImageSize.Width;
                }
                // Draw item text
                pe.Graphics.DrawString(item.Text, pe.Font, new SolidBrush(pe.ForeColor),
                                       bounds.Left + iOffset, bounds.Top);
            }
            base.OnDrawItem(pe);
        }
Exemple #39
0
        /// <summary>
        /// Owner drawing listview item.
        /// </summary>
        protected void OnDrawItem( DrawItemEventArgs e, PluginListItem item )
        {
            e.DrawBackground();

            // IsRunnning bitmap
            const int imageWidth = 16+3;
            if(imageList==null)
                imageList = ((PluginDialog)Parent).ImageList;
            if(imageList!=null)
            {
                int imageIndex = item.PluginInfo.IsCurrentlyLoaded ? 0 : 1;
                imageList.Draw(e.Graphics, e.Bounds.Left+2, e.Bounds.Top+1, imageIndex);
            }

            // Name
            Rectangle bounds = Rectangle.FromLTRB(e.Bounds.Left+imageWidth,
                e.Bounds.Top, e.Bounds.Left+Columns[0].Width, e.Bounds.Bottom);
            using(Brush brush = new SolidBrush(e.ForeColor))
                e.Graphics.DrawString(item.Name, e.Font, brush, bounds);

            // Check box (Load at startup)
            bounds = Rectangle.FromLTRB(bounds.Right+1,
                bounds.Top, bounds.Right+Columns[1].Width+1, bounds.Bottom-1);
            ButtonState state = item.PluginInfo.IsLoadedAtStartup ? ButtonState.Checked : ButtonState.Normal;
            ControlPaint.DrawCheckBox(e.Graphics, bounds, state);
        }
Exemple #40
0
 private void showList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     if (e.Index < 0 || e.Index > showList.Items.Count)
     {
         return;
     }
     try {
         showClass sc = (showList.Items[e.Index] as showClass);
         e.DrawBackground();
         Brush  b     = Brushes.Black;
         String title = "";
         if (sc.Lang == "")
         {
             title = sc.Name + " (" + sc.Year.ToString() + ")";
         }
         else
         {
             title = sc.Name + " (" + sc.Year.ToString() + "," + sc.Lang + ")";
         }
         e.Graphics.DrawString(title, e.Font, b, e.Bounds);
         e.DrawFocusRectangle();
     }
     catch (Exception E) {
         Log.Add("DrawItem Error:\n" + E.Message);
     }
 }
Exemple #41
0
        private void ListBox1_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 myBrush = Brushes.Black;

            // Determine the color of the brush to draw each item based
            // on the index of the item to draw.
            switch (e.Index)
            {
            case 0:
                myBrush = Brushes.Red;
                break;

            case 1:
                myBrush = Brushes.Orange;
                break;

            case 2:
                myBrush = Brushes.Purple;
                break;
            }

            // Draw the current item text based on the current Font
            // and the custom brush settings.
            e.Graphics.DrawString(ListBox1.Items[e.Index].ToString(),
                                  e.Font, myBrush, e.Bounds, StringFormat.GenericDefault);
            // If the ListBox has focus, draw a focus rectangle around the selected item.
            e.DrawFocusRectangle();
        }
Exemple #42
0
        protected override void OnDrawItem(WinForms.DrawItemEventArgs e)
        {
            e.DrawBackground();

            var brush = SystemBrushes.Menu;

            if (Gradient)
            {
                brush = new LinearGradientBrush(e.Bounds, Color.SkyBlue,
                                                Color.White, 30.0f);
            }
            e.Graphics.FillRectangle(brush, e.Bounds);

            if (MenuIcon != null)
            {
                var icon_bounds = e.Bounds;
                icon_bounds.Width = e.Bounds.Height;
                e.Graphics.DrawIcon(Program.GetIcon(0), icon_bounds);
            }

            var text_bounds = e.Bounds;

            text_bounds.Width -= e.Bounds.Height;
            text_bounds.X     += e.Bounds.Height;
            e.Graphics.DrawString(Text, TextFont, Brushes.Black, text_bounds);
        }
Exemple #43
0
 public void ReplaceItem(System.Object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     e.DrawBackground();
     try
     {
         if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
         {
             e.Graphics.FillRectangle(new SolidBrush(_highlightColor), e.Bounds);
             LinearGradientBrush gloss = new LinearGradientBrush(e.Bounds, Color.FromArgb(15, Color.White), Color.FromArgb(0, Color.White), 90);
             e.Graphics.FillRectangle(gloss, new Rectangle(new Point(e.Bounds.X, e.Bounds.Y), new Size(e.Bounds.Width, e.Bounds.Height)));
             e.Graphics.DrawRectangle(new Pen(Color.FromArgb(50, Color.Black))
             {
                 DashStyle = DashStyle.Dot
             }, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1));
         }
         else
         {
             e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 255, 255, 255)), e.Bounds);
         }
         using (SolidBrush b = new SolidBrush(Color.Black))
         {
             e.Graphics.DrawString(base.GetItemText(base.Items[e.Index]), e.Font, b, new Rectangle(e.Bounds.X + 2, e.Bounds.Y, e.Bounds.Width - 4, e.Bounds.Height));
         }
     }
     catch
     {
     }
     e.DrawFocusRectangle();
 }
        //cinderellaListBox_DrawItem
        //overrides the default draw item fucntion, inorder to set every other row to be shaded pink, instead of white
        //Input: the lsitbox and row index
        //Output: the row and background have been drawn with the correct colors
        //precondition: the inputed index is correct and valid
        //postcondition: every item has been drawn correctly
        public void cinderellaListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            //sets up the background for the listbox
            e.DrawBackground();
            Graphics g = e.Graphics;
            //gets the index for the row in the listbox
            int thecurrentIndex = e.Index;
            //draws the background snow color
            g.FillRectangle(new SolidBrush(Color.Snow), e.Bounds);
            ListBox otherpaintBox = (ListBox)sender;
            //holds the color to set the highlight to be
            Color otherprettyColor;
            if (thecurrentIndex >= 0 && thecurrentIndex < cinderellaListBox.Items.Count)
            {
                //if the row is even numbered use snow, otherwise use pink
                if (thecurrentIndex % 2 == 0)
                {
                    otherprettyColor = Color.Snow;
                }
                else
                {
                    otherprettyColor = Color.Pink;
                }
                //draws the highlight
                g.FillRectangle(new SolidBrush(otherprettyColor), e.Bounds);

                g.DrawString(otherpaintBox.Items[e.Index].ToString(), e.Font, new SolidBrush(Color.Black), e.Bounds, StringFormat.GenericDefault);
                e.DrawFocusRectangle();
            }
        }
Exemple #45
0
        void List_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            if (e.Index >= 0)
            {
                Brush myBrush = Brushes.Black;
                var   box     = (ListBox)sender;
                var   fore    = box.ForeColor;

                if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                {
                    fore = SystemColors.HighlightText;
                }
                string text = "";
                if (box.Items[e.Index].GetType() == typeof(PlayListItem))
                {
                    if (((PlayListItem)box.Items[e.Index]).IsActive)
                    {
                        fore = Color.DarkOrange;
                    }
                    text = ((PlayListItem)box.Items[e.Index]).Name;
                }
                TextRenderer.DrawText(e.Graphics, text,
                                      box.Font, e.Bounds, fore);
                e.DrawFocusRectangle();
            }
        }
Exemple #46
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
            {
            }
        }
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.ListBox.DrawItem"/> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.DrawItemEventArgs"/> that contains the event data.</param>
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (DesignMode)
            {
                base.OnDrawItem(e);
                return;
            }

            // Get the selected emitter to draw
            var emitter = (e.Index < 0 || e.Index >= Items.Count ? null : Items[e.Index]) as IParticleEmitter;

            // Let the base implementation handle an invalid item
            if (emitter == null)
            {
                base.OnDrawItem(e);
                return;
            }

            // Draw the item
            e.DrawBackground();

            var txt = string.Format(_displayTextFormat, emitter.GetType().Name, emitter.Name);
            using (var brush = new SolidBrush(e.ForeColor))
            {
                e.Graphics.DrawString(txt, e.Font, brush, e.Bounds);
            }

            e.DrawFocusRectangle();
        }
Exemple #48
0
        void ColorsBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0) return;
            e.DrawBackground();

            Color color = (Color)(sender as ComboBox).Items[e.Index];
            if (color == null) return;

            string name = color.Name;
            if (sender == systemColorsBox)
                name = color.ToKnownColor().ToString();

            Brush bgB = new SolidBrush(color);
            Brush fgB = new SolidBrush(e.ForeColor);
            Pen fgP = new Pen(e.ForeColor);

            Rectangle colorRect = new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2,
                _colorRectWidth, e.Bounds.Height - 4);
            e.Graphics.FillRectangle(bgB, colorRect);
            e.Graphics.DrawRectangle(fgP, colorRect);

            Rectangle nameRect = new Rectangle(colorRect.Right + 2, e.Bounds.Y,
                e.Bounds.Width - colorRect.Width - 4, e.Bounds.Height);
            e.Graphics.DrawString(name, systemColorsBox.Font, fgB, nameRect, _stringFormat);

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.DrawFocusRectangle();
            }
        }
Exemple #49
0
        public void ReplaceItem(System.Object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            Rectangle Rect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width + 1, e.Bounds.Height + 1);

            try
            {
                var _with24 = e.Graphics;
                if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                {
                    _with24.FillRectangle(new SolidBrush(_SqaureColour), Rect);
                    _with24.DrawString(base.GetItemText(base.Items[e.Index]), Font, new SolidBrush(_FontColour), 1, e.Bounds.Top + 2);
                }
                else
                {
                    _with24.FillRectangle(new SolidBrush(_BaseColour), Rect);
                    _with24.DrawString(base.GetItemText(base.Items[e.Index]), Font, new SolidBrush(_FontColour), 1, e.Bounds.Top + 2);
                }
            }
            catch
            {
            }
            e.DrawFocusRectangle();
            Invalidate();
        }
Exemple #50
0
        private void lbxResults_DrawItem(object sender, DrawItemEventArgs e)
        {
            Noun lemma = (Noun)lbxResults.Items[e.Index];
            e.DrawBackground();
            Graphics g = e.Graphics;
            Color bgColor;
            switch(lemma.Gender) {
                case Noun.NounGender.Mannlich: bgColor = Color.SkyBlue; break;
                case Noun.NounGender.Weiblich: bgColor = Color.Pink; break;
                case Noun.NounGender.Neutrum: bgColor = Color.Gold; break;
                default: bgColor = Color.LightGoldenrodYellow; break;
            }
            g.FillRectangle(new SolidBrush(bgColor), e.Bounds);

            float scaleFactor = FindFontScaleHor(g, string.Format("{0} ({1})", lemma.Word, NounGenderConvert.ToString(lemma.Gender)), defaultHeaderFont, e.Bounds.Width);
            Font lemmaHeaderFont = new Font(headerFontFamily, 25 * scaleFactor, FontStyle.Bold, GraphicsUnit.Pixel);
            Font lemmaGenderFont = new Font(headerFontFamily, 15 * scaleFactor, FontStyle.Italic, GraphicsUnit.Pixel);

            int headerHeight = GetFontLineHeight(lemmaHeaderFont);
            Rectangle lemmaRect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, headerHeight);
            lemmaRect.Width = Convert.ToInt32(Math.Ceiling(g.MeasureString(lemma.Word, lemmaHeaderFont).Width));
            g.DrawString(lemma.Word, lemmaHeaderFont, Brushes.LightSlateGray, lemmaRect);

            int genderOffset = GetFontAscent(lemmaHeaderFont) - GetFontAscent(lemmaGenderFont);
            int genderHeight = GetFontLineHeight(lemmaGenderFont);
            Rectangle genderRect = new Rectangle(lemmaRect.Width, e.Bounds.Y + genderOffset, e.Bounds.Width - lemmaRect.Width, genderHeight);
            g.DrawString(string.Format("({0})", NounGenderConvert.ToString(lemma.Gender)), lemmaGenderFont, Brushes.LightSlateGray, genderRect);

            e.DrawFocusRectangle();
        }
        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);
        }
Exemple #52
0
        public void DrawItem_(System.Object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            e.DrawBackground();
            e.DrawFocusRectangle();

            e.Graphics.SmoothingMode     = SmoothingMode.HighQuality;
            e.Graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                //-- Selected item
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(25, 25, 25)), e.Bounds);
            }
            else
            {
                //-- Not Selected
                e.Graphics.FillRectangle(new SolidBrush(_BaseColor), e.Bounds);
            }

            //-- Text
            e.Graphics.DrawString(base.GetItemText(base.Items[e.Index]), new Font("Segoe UI", 8), Brushes.White, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height));


            e.Graphics.Dispose();
        }
Exemple #53
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;
            Rectangle area = e.Bounds;
            Rectangle iconArea = area;
            iconArea.Width = 16;
            if (e.Index >= 0)
            {
                e.DrawBackground();
                Entity ent = (Entity)Items[e.Index];
                int dist = (int)Vector3i.Distance(ent.Pos, PlayerPos);

                // Draw entity icon
                g.DrawImage(ent.Image, iconArea);

                // Entity name
                SizeF entName = g.MeasureString(ent.ToString(), this.Font);
                Rectangle ctxt = area;
                ctxt.X = iconArea.Right + 3;
                ctxt.Width = (int)entName.Width + 1;
                g.DrawString(ent.ToString(), this.Font, new SolidBrush(e.ForeColor), ctxt);

                // Distance.
                string derp = string.Format("({0}m away)", dist);
                SizeF entDist = g.MeasureString(derp, this.Font);
                Rectangle distArea = area;
                distArea.X = ctxt.Right + 3;
                distArea.Width = (int)entDist.Width;
                g.DrawString(derp, this.Font, new SolidBrush(Color.FromArgb(128, e.ForeColor)), distArea);
            }
        }
    // Draw list item
    protected void OnDrawItem(object sender, DrawItemEventArgs e)
    {
      if (e.Index >= 0)
      {
        // Get this color
        ColorInfo color = (ColorInfo)Items[e.Index];

        // Fill background
        e.DrawBackground();

        // Draw color box
        Rectangle rect = new Rectangle();
        rect.X = e.Bounds.X + 2;
        rect.Y = e.Bounds.Y + 2;
        rect.Width = 18;
        rect.Height = e.Bounds.Height - 5;
        e.Graphics.FillRectangle(new SolidBrush(color.Color), rect);
        e.Graphics.DrawRectangle(SystemPens.WindowText, rect);

        // Write color name
        Brush brush;
        if ((e.State & DrawItemState.Selected) != DrawItemState.None)
          brush = SystemBrushes.HighlightText;
        else
          brush = SystemBrushes.WindowText;
        e.Graphics.DrawString(color.Text, Font, brush,
            e.Bounds.X + rect.X + rect.Width + 2,
            e.Bounds.Y + ((e.Bounds.Height - Font.Height) / 2));

        // Draw the focus rectangle if appropriate
        if ((e.State & DrawItemState.NoFocusRect) == DrawItemState.None)
          e.DrawFocusRectangle();
      }
    }
Exemple #55
0
        private void OnDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            int       iWidth;
            Graphics  grfx = e.Graphics;
            Rectangle rect;

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

            if (e.Index >= 0)
            {
                rect         = e.Bounds;
                iWidth       = rect.Width;
                rect.X      += 5;
                rect.Y      += 1;
                rect.Height -= 1;
                rect.Width   = _size.Width;
                rect.Height  = _size.Height;
                if (((ImageComboBoxItem)this.Items[e.Index]).Image != null)
                {
                    grfx.DrawImage(((ImageComboBoxItem)this.Items[e.Index]).Image, rect);
                }
                rect.Offset(rect.Width + 5, 0);
                rect.Width = iWidth;
                if (((ImageComboBoxItem)this.Items[e.Index]).Name != null)
                {
                    grfx.DrawString(((ImageComboBoxItem)this.Items[e.Index]).Name, e.Font, Brushes.Black, rect);
                }
            }
        }
Exemple #56
0
        /**
         * Настройка отрисовки стиля вкладок
         */
        private void tabControl_DrawItem(Object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;
            Brush    _textBrush;

            // Получим объект из коллекции
            TabPage _tabPage = tabControl.TabPages[e.Index];

            // Получим параметры ограничивающей рамки.
            Rectangle _tabBounds = tabControl.GetTabRect(e.Index);

            //используем другой шрифт
            Font _tabFont;

            if (e.State == DrawItemState.Selected)
            {
                //Изменим шрифт и закрасим фон
                _tabFont = new Font("Comic Sans MS", 18.0f, FontStyle.Bold, GraphicsUnit.Pixel);
                g.FillRectangle(Brushes.AliceBlue, e.Bounds);
                _textBrush = new System.Drawing.SolidBrush(Color.Blue);
            }
            else
            {
                _tabFont   = new Font("Comic Sans MS", 18.0f, FontStyle.Regular, GraphicsUnit.Pixel);
                _textBrush = new System.Drawing.SolidBrush(e.ForeColor);
                e.DrawBackground();
            }

            // Напечатаем название вкладки по центру
            StringFormat _stringFlags = new StringFormat();

            _stringFlags.Alignment     = StringAlignment.Center;
            _stringFlags.LineAlignment = StringAlignment.Center;
            g.DrawString(_tabPage.Text, _tabFont, _textBrush, _tabBounds, new StringFormat(_stringFlags));
        }
        private void settings4_4_language_DrawItem(object sender, DrawItemEventArgs e)
        {
            Font objFonts = new Font(this.Font.Name, 14, FontStyle.Bold);
            e.DrawBackground();

            e.Graphics.DrawString(settings4_4_language.Items[e.Index].ToString(), objFonts, new SolidBrush(e.ForeColor), new Point(e.Bounds.Left, e.Bounds.Top));
        }
 /// <summary>
 /// Custom Draw Item Handler.
 /// It fires when painting each item in dropdown list. We use item value (text) to create the path to picture in resource and paint it in the list.
 /// </summary>
 /// <param name="e">Arguments from DrawItem Event</param>
 protected override void OnDrawItem(DrawItemEventArgs e)
 {
     // Draw background and focus rectangle, if necessary.
     e.DrawBackground();
     e.DrawFocusRectangle();
     // If something is selected, paint it
     if (e.Index > -1)
     {
         // Get text from current item
         var text     = (string)Items[e.Index];
         // Get resource path to picture
         var resource = string.Format("HSCardGenerator.Resources.Images.Flags.{0}.png", text.ToLower());
         // Read it as stream
         using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
         {
             // And paint it
             e.Graphics.DrawImage(Image.FromStream(stream), new PointF(e.Bounds.X, e.Bounds.Y));
         }
         // Draw text if necessary
         if (showLabels)
         {
             // Same as for OnPaint event
             var txt    = Config.localesFull[(int)Methods.General.getLocaleFromString(text)];
             var limits = e.Graphics.MeasureString(txt, e.Font);
             var top    = (24 - limits.Height) / 2;
             e.Graphics.DrawString(txt, e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left + 24, e.Bounds.Top + top);
         }
         // We need to do this, no wonder why :/
         if ((e.Index == SelectedIndex) && (DroppedDown == false))
         {
             e.DrawFocusRectangle();
         }
     }
 }
Exemple #59
0
        protected override void OnDrawItem( DrawItemEventArgs e )
        {
            base.OnDrawItem( e );

            if ( e.Index != -1 )
            {
                object item = Items[e.Index];
                e.DrawBackground();
                e.DrawFocusRectangle();

                bool separator = item is SeparatorItem;

                Rectangle bounds = e.Bounds;
                bool drawSeparator = separator && ( e.State & DrawItemState.ComboBoxEdit ) != DrawItemState.ComboBoxEdit;
                if ( drawSeparator )
                {
                    bounds.Height -= separatorHeight;
                }

                TextRenderer.DrawText( e.Graphics, GetDisplayText( e.Index ), Font, bounds, e.ForeColor, e.BackColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter );

                if ( drawSeparator )
                {
                    Rectangle sepRect = new Rectangle( e.Bounds.Left, e.Bounds.Bottom - separatorHeight, e.Bounds.Width, separatorHeight );
                    using ( Brush b = new SolidBrush( BackColor ) )
                    {
                        e.Graphics.FillRectangle( b, sepRect );
                    }
                    e.Graphics.DrawLine( SystemPens.ControlText, sepRect.Left + 2, sepRect.Top + 1, sepRect.Right - 2, sepRect.Top + 1 );
                }
            }
        }
Exemple #60
0
        private void lbxPanes_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();

            if (e.Index < 0) return;

            PreferencePaneListItem itemToDraw = (PreferencePaneListItem)lbxPanes.Items[e.Index];
            Brush textBrush = null;
            Font textFont = null;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.HighlightText));
                textFont = new Font(e.Font, FontStyle.Bold);
            }
            else
            {
                textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.ControlText));
                textFont = new Font(e.Font, FontStyle.Regular);
            }

            SizeF stringSize = e.Graphics.MeasureString(itemToDraw.Name, textFont);
            float stringX = e.Bounds.Left + 4 + itemToDraw.Icon.Width;
            float stringY = e.Bounds.Top + 2 + ((itemToDraw.Icon.Height / 2) - (stringSize.Height / 2));

            e.Graphics.DrawImage(itemToDraw.Icon, e.Bounds.Left + 2, e.Bounds.Top + 2);
            e.Graphics.DrawString(itemToDraw.Name, textFont, textBrush, stringX, stringY);

            e.DrawFocusRectangle();

            textFont.Dispose();
            textBrush.Dispose();
            textFont = null;
            textBrush = null;
        }