示例#1
0
        public void AddTextWatermark(string strOraginalPath)
        {
            if (string.IsNullOrEmpty(_strWatermarkText))//如果水印文字为空
            {
                return;
            }

            System.Drawing.Image imgOraginal = System.Drawing.Image.FromFile(strOraginalPath);
            int iWidth  = imgOraginal.Width;
            int iHeight = imgOraginal.Height;

            System.Drawing.Bitmap bitOraginal = new System.Drawing.Bitmap(imgOraginal, iWidth, iHeight);
            imgOraginal.Dispose();

            System.Drawing.Graphics gOraginal = System.Drawing.Graphics.FromImage(bitOraginal);

            System.Drawing.Rectangle    rectTextField = new System.Drawing.Rectangle(10, 10, iWidth - 20, iHeight - 20);
            System.Drawing.StringFormat sf            = GetStringFormat();

            System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(_btWatermarkTransparency /*文字的透明度*/, _fontWatermarkColor));
            gOraginal.DrawString(_strWatermarkText, _fontWatermarkFont, brush, rectTextField, sf);

            sf.Dispose();
            brush.Dispose();

            bitOraginal.Save(strOraginalPath, System.Drawing.Imaging.ImageFormat.Jpeg);

            gOraginal.Dispose();
            bitOraginal.Dispose();
        }
示例#2
0
        //Draw text on the map
        private System.Drawing.Bitmap DrawText(String text, System.Drawing.Font font, System.Drawing.Color textColor, System.Drawing.Color backColor)
        {
            //Create a dummy bitmap to get a graphics object
            System.Drawing.Bitmap   img     = new System.Drawing.Bitmap(1, 1);
            System.Drawing.Graphics drawing = System.Drawing.Graphics.FromImage(img);

            //Measure the string to see how big the image needs to be
            textSize = drawing.MeasureString(text, font);

            //free up the dummy image and old graphics object
            img.Dispose();
            drawing.Dispose();

            //create a new image of the right size
            img     = new System.Drawing.Bitmap((int)textSize.Width, (int)textSize.Height);
            drawing = System.Drawing.Graphics.FromImage(img);

            //paint the background
            drawing.Clear(backColor);

            System.Drawing.SolidBrush textBrush = new System.Drawing.SolidBrush(textColor);
            drawing.DrawString(text, font, textBrush, 0, 0);
            drawing.Save();
            textBrush.Dispose();
            drawing.Dispose();

            return(img);
        }
示例#3
0
        protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel)
        {
            if (channel == GH_CanvasChannel.Objects)
            {
                GH_Capsule capsule = GH_Capsule.CreateCapsule(this.Bounds, GH_Palette.Normal);
                capsule.AddOutputGrip(this.OutputGrip.Y);
                capsule.Render(canvas.Graphics, this.Selected, this.Owner.Locked, this.Owner.Hidden);
                capsule.Dispose();
                int alpha = GH_Canvas.ZoomFadeLow;
                if (alpha > 0)
                {
                    canvas.SetSmartTextRenderingHint();
                    GH_PaletteStyle      style = GH_CapsuleRenderEngine.GetImpliedStyle(GH_Palette.Normal, this);
                    System.Drawing.Color color = System.Drawing.Color.FromArgb(alpha, style.Text);
                    if (this.NameBounds.Width > 0f)
                    {
                        System.Drawing.SolidBrush nameFill = new System.Drawing.SolidBrush(color);
                        graphics.DrawString(this.Owner.NickName, GH_FontServer.Standard, nameFill, this.NameBounds, GH_TextRenderingConstants.CenterCenter);
                        nameFill.Dispose();
                        int x  = System.Convert.ToInt32(this.NameBounds.Right);
                        int y0 = System.Convert.ToInt32(this.NameBounds.Top);
                        int y  = System.Convert.ToInt32(this.NameBounds.Bottom);
                        GH_GraphicsUtil.EtchFadingVertical(graphics, y0, y, x, System.Convert.ToInt32(0.8 * (double)alpha), System.Convert.ToInt32(0.3 * (double)alpha));
                    }

                    // render dropdown only
                    this.RenderDropDown(canvas, graphics, color);
                }
            }
        }
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            var    formGraphics = e.Graphics;
            string drawString1  = "Windows Store Edition";

            System.Drawing.Font       drawFont1  = new System.Drawing.Font("Microsoft Sans Serif", 22, System.Drawing.FontStyle.Bold);
            System.Drawing.SolidBrush drawBrush1 = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            float x1 = 34.0F;
            float y1 = 148.0F;

            System.Drawing.StringFormat drawFormat1 = new System.Drawing.StringFormat();
            formGraphics.DrawString(drawString1, drawFont1, drawBrush1, x1, y1, drawFormat1);

            //377; 171
            string drawString2 = "V22 21-01-2021";

            System.Drawing.Font       drawFont2  = new System.Drawing.Font("Microsoft Sans Serif", 8, System.Drawing.FontStyle.Bold);
            System.Drawing.SolidBrush drawBrush2 = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            float x2 = 358.0F;
            float y2 = 164.0F;

            System.Drawing.StringFormat drawFormat2 = new System.Drawing.StringFormat();
            formGraphics.DrawString(drawString2, drawFont2, drawBrush2, x2, y2, drawFormat2);
            drawFont1.Dispose();
            drawBrush1.Dispose();
            drawFont2.Dispose();
            drawBrush2.Dispose();
            formGraphics.Dispose();
        }
示例#5
0
 public override void Draw(System.Drawing.Graphics g)
 {
     System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(Color);
     System.Drawing.PointF upperLeftPoint = new System.Drawing.PointF((float)(Center.X - RadiusX), (float)(Center.Y - RadiusY));
     System.Drawing.SizeF rectSize = new System.Drawing.SizeF((float)(2 * RadiusX), (float)(2 * RadiusY));
     System.Drawing.RectangleF rect = new System.Drawing.RectangleF(upperLeftPoint, rectSize);
     g.FillEllipse(solidBrush, rect);
     solidBrush.Dispose();
 }
示例#6
0
 public override void Draw(System.Drawing.Graphics g)
 {
     System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(Color);
     System.Drawing.PointF upperLeftPoint = new System.Drawing.PointF((float)(Center.X - Width / 2), (float)(Center.Y - Height / 2));
     System.Drawing.SizeF rectSize = new System.Drawing.SizeF((float)Width, (float)Height);
     System.Drawing.RectangleF rect = new System.Drawing.RectangleF(upperLeftPoint, rectSize);
     g.FillRectangle(solidBrush, rect);
     solidBrush.Dispose();
 }
示例#7
0
 public override void Draw(System.Drawing.Graphics g)
 {
     System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(Color);
     System.Drawing.PointF[] points = new System.Drawing.PointF[3];
     points[0] = new System.Drawing.PointF((float)Vertex1.X, (float)Vertex1.Y);
     points[1] = new System.Drawing.PointF((float)Vertex2.X, (float)Vertex2.Y);
     points[2] = new System.Drawing.PointF((float)Vertex3.X, (float)Vertex3.Y);
     g.FillPolygon(solidBrush, points);
     solidBrush.Dispose();
 }
示例#8
0
 public void draw()
 {
     //if (parent == null)
     //    return;
     System.Drawing.SolidBrush myBrush      = new System.Drawing.SolidBrush((type == CircleType.RED)?System.Drawing.Color.Red : System.Drawing.Color.Yellow);
     System.Drawing.Graphics   formGraphics = parent.CreateGraphics();
     formGraphics.FillEllipse(myBrush, new System.Drawing.Rectangle(x, y, width, height));
     myBrush.Dispose();
     formGraphics.Dispose();
 }
示例#9
0
        public override void Draw(System.Drawing.Graphics drawArea)
        {
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
            drawArea.FillRectangle(myBrush, posX, posY, sides[0], sides[0]);
            myBrush.Dispose();

            System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.LightGreen);
            myPen.Width = 5;
            drawArea.DrawRectangle(myPen, posX, posY, sides[0], sides[0]);
            myPen.Dispose();
        }
示例#10
0
        public void dessiner(Forme f, Control c)
        {
            Carre f1 = (Carre)f;

            System.Drawing.Graphics formGraphics;
            formGraphics = c.CreateGraphics();

            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Fuchsia);
            formGraphics.FillRectangle(myBrush, new System.Drawing.Rectangle(f.getposi().getY(), f.getposi().getX(), f1.getC(), f1.getC()));
            myBrush.Dispose();
        }
示例#11
0
        public override void Draw(System.Drawing.Graphics drawArea)
        {
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow);
            drawArea.FillEllipse(myBrush, posX, posY, radius * 2, radius * 2);
            myBrush.Dispose();

            System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.DarkOrange);
            myPen.Width = 5;
            drawArea.DrawEllipse(myPen, posX, posY, radius * 2, radius * 2);
            myPen.Dispose();
        }
        /* GRAPHICS */

        public System.Drawing.Icon GetIcon(string period, string room)
        {
            try
            {
                //Create bitmap, kind of canvas
                System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(128, 128);

                System.Drawing.Font       drawFont  = new System.Drawing.Font("Calibri", 32, System.Drawing.FontStyle.Bold);
                System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);

                System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
                graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

                graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
                int     pl    = graphics.MeasureString(period.Substring(0, 4), drawFont).ToSize().Width;
                Boolean three = false;
                if (pl > 128)
                {
                    pl    = graphics.MeasureString(period.Substring(0, 3), drawFont).ToSize().Width;
                    three = true;
                }
                int rl = graphics.MeasureString(room, drawFont).ToSize().Width;
                if (!three)
                {
                    graphics.DrawString(period.Substring(0, 4), drawFont, drawBrush, 64 - (pl / 2), 0);
                }
                else
                {
                    graphics.DrawString(period.Substring(0, 3), drawFont, drawBrush, 64 - (pl / 2), 0);
                }
                graphics.DrawString(room, drawFont, drawBrush, 64 - (rl / 2), 64);

                //To Save icon to disk
                //MemoryStream ms = new MemoryStream();
                //bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Icon);

                System.Drawing.Icon createdIcon = System.Drawing.Icon.FromHandle(bitmap.GetHicon());

                drawFont.Dispose();
                drawBrush.Dispose();
                graphics.Dispose();
                bitmap.Dispose();

                return(createdIcon);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Write(e.Message);
            }

            return(System.Drawing.SystemIcons.Error);
        }
        private void DrawRulerLine(System.Drawing.Graphics grap, int x1, int x2, int y1, int y2)
        {
            using (System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.DarkGray))
            {
                using (System.Drawing.Pen pen = new System.Drawing.Pen(brush, (float)0.3))
                {
                    grap.DrawLine(pen, x1, y1, x2, y2);

                    pen.Dispose();

                    brush.Dispose();
                }
            }
        }
示例#14
0
 private void 修改字幕颜色按钮点击事件(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog();
     if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         System.Drawing.SolidBrush sb = new System.Drawing.SolidBrush(colorDialog.Color);
         //SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromArgb(sb.Color.A, sb.Color.R, sb.Color.G, sb.Color.B));
         字幕.字体颜色 = Color.FromArgb(sb.Color.A, sb.Color.R, sb.Color.G, sb.Color.B);
         sb.Dispose();
         //字幕.Foreground = solidColorBrush;
         if (弹幕.FontSize > 50)
         {
             弹幕.FontSize = 1;
         }
         else
         {
             弹幕.FontSize++;
         }
         sb.Dispose();
     }
     colorDialog.Dispose();
     首页焦点.Focus();
 }
示例#15
0
        private void DrawString()
        {
            WriteableBitmap writeableBmp = BitmapFactory.New(512, 512);

            WriteableBitmapExtensions.
                System.Drawing.Graphics formGraphics = this.CreateGraphics();
            string drawString = "Sample Text";
            System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
            System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            float x = 150.0f;
            float y = 50.0f;
            formGraphics.DrawString(drawString, drawFont, drawBrush, x, y);
            drawFont.Dispose();
            drawBrush.Dispose();
            formGraphics.Dispose();
        }
示例#16
0
        private void DrawString()
        {
            WriteableBitmap writeableBmp = BitmapFactory.New(512, 512);

            WriteableBitmapExtensions.
            System.Drawing.Graphics formGraphics = this.CreateGraphics();
            string drawString = "Sample Text";

            System.Drawing.Font       drawFont  = new System.Drawing.Font("Arial", 16);
            System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            float x = 150.0f;
            float y = 50.0f;

            formGraphics.DrawString(drawString, drawFont, drawBrush, x, y);
            drawFont.Dispose();
            drawBrush.Dispose();
            formGraphics.Dispose();
        }
示例#17
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            foreach (Control control in this.Controls)
            {
                if (control is CheckBox)
                {
                    CheckBox checkBox = control as CheckBox;
                    System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(checkBox.ForeColor);
                    System.Drawing.Graphics   formGraphics;
                    formGraphics = this.CreateGraphics();
                    formGraphics.FillRectangle(myBrush, new System.Drawing.Rectangle(checkBox.Left + 20, checkBox.Top, 60, checkBox.Height));
                    myBrush.Dispose();
                    formGraphics.Dispose();
                }
            }
        }
示例#18
0
        // implement Draw() (step 5)
        public void Draw(System.Drawing.Graphics image)
        {
            System.Drawing.Brush brush = new System.Drawing.SolidBrush(color);
            System.Drawing.Pen   pen   = new System.Drawing.Pen(color);

            // Determine if circle, since use [upperLeft, width, height, !vertices] only
            if (name.Equals("Circle"))
            {
                image.DrawEllipse(pen, UpperLeft.X, UpperLeft.Y, Height, Width);
                image.FillEllipse(brush, new System.Drawing.Rectangle(UpperLeft.X, UpperLeft.Y, Width, Height));
            }
            else
            {
                image.DrawPolygon(pen, Vertices);
                image.FillPolygon(brush, Vertices);
            }

            brush.Dispose();
            pen.Dispose();
        }
示例#19
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (m_DisplayPage.BitsPerPixel == 0)
            {
                // not initialised yet
                e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Control, e.ClipRectangle);
                return;
            }

            System.Drawing.SolidBrush hottrackBrush = new System.Drawing.SolidBrush(GR.Color.Helper.FromARGB(HottrackColor));

            int itemIndex  = m_Offset * m_ItemsPerLine;
            int itemInLine = 0;

            System.Drawing.Rectangle itemRect = new System.Drawing.Rectangle();
            while (itemIndex < Items.Count)
            {
                int xoffset = (itemIndex - m_Offset * m_ItemsPerLine) % m_ItemsPerLine;
                int yoffset = (itemIndex - m_Offset * m_ItemsPerLine) / m_ItemsPerLine;
                itemRect = new System.Drawing.Rectangle(xoffset * m_ItemWidth, yoffset * m_ItemHeight, m_ItemWidth, m_ItemHeight);

                if (DrawItem != null)
                {
                    e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Control, e.ClipRectangle);
                    DrawItemEventArgs args = new DrawItemEventArgs(e.Graphics, Font, itemRect, itemIndex, DrawItemState.Default);
                    DrawItem(this, args);
                }
                else if (Items[itemIndex].Image != null)
                {
                    e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Control, e.ClipRectangle);
                    e.Graphics.DrawImage(Items[itemIndex].Image, itemRect);
                }
                else if (Items[itemIndex].MemoryImage != null)
                {
                    m_DisplayPage.DrawFromMemoryImage(Items[itemIndex].MemoryImage, itemRect.X, itemRect.Y);
                }
                ++itemIndex;
                itemInLine = ((itemInLine + 1) % m_ItemsPerLine);
            }
            if (itemInLine < m_ItemsPerLine)
            {
                // clear rest of display
                m_DisplayPage.Box(itemRect.Right, itemRect.Y, ClientSize.Width - itemRect.Right, m_ItemHeight, 0);
            }
            m_DisplayPage.Box(0, itemRect.Bottom, ClientSize.Width, ClientSize.Height - itemRect.Bottom, 0);

            IntPtr hdcPage = e.Graphics.GetHdc();

            m_DisplayPage.DrawToHDC(hdcPage, ClientRectangle);
            e.Graphics.ReleaseHdc(hdcPage);

            if (m_ItemUnderMouse != -1)
            {
                e.Graphics.FillRectangle(hottrackBrush, ItemRect(m_ItemUnderMouse));
            }
            if (m_SelectedItem != -1)
            {
                if (m_SelectionAnchor != -1)
                {
                    if (m_SelectionIsRange)
                    {
                        int firstItem = m_SelectionAnchor;
                        int lastItem  = m_SelectedItem;
                        if (lastItem < firstItem)
                        {
                            lastItem  = firstItem;
                            firstItem = m_SelectedItem;
                        }
                        for (int i = firstItem; i <= lastItem; ++i)
                        {
                            e.Graphics.FillRectangle(hottrackBrush, ItemRect(i));
                        }
                    }
                    else
                    {
                        int i1 = m_SelectionAnchor;
                        int i2 = m_SelectedItem;
                        if (i2 < i1)
                        {
                            i1 = m_SelectedItem;
                            i2 = m_SelectionAnchor;
                        }

                        int x1 = i1 % m_ItemsPerLine;
                        int x2 = i2 % m_ItemsPerLine;
                        if (x2 < x1)
                        {
                            x1 = x2;
                            x2 = i1 % m_ItemsPerLine;
                        }

                        int y1 = m_SelectionAnchor / m_ItemsPerLine;
                        int y2 = m_SelectedItem / m_ItemsPerLine;
                        if (y2 < y1)
                        {
                            y1 = y2;
                            y2 = m_SelectionAnchor / m_ItemsPerLine;
                        }
                        i1 = y1 * m_ItemsPerLine + x1;
                        i2 = y2 * m_ItemsPerLine + x2;

                        for (int i = i1; i <= i2; ++i)
                        {
                            if ((i % m_ItemsPerLine >= x1) &&
                                (i % m_ItemsPerLine <= x2))
                            {
                                e.Graphics.FillRectangle(hottrackBrush, ItemRect(i));
                            }
                        }
                    }
                }
                else
                {
                    e.Graphics.FillRectangle(hottrackBrush, ItemRect(m_SelectedItem));
                }
            }
            hottrackBrush.Dispose();
        }
        void m_printDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            SelectedMealCollection colData = (SelectedMealCollection)this.FindResource("SelectedMealCollectionData");
            float leftMargin = e.MarginBounds.Left;
            float rightMargin = e.MarginBounds.Right;
            float topMargin = e.MarginBounds.Top;
          
            float yPos = leftMargin;
            float xPos = 0;
            float centrePos = 2 * (rightMargin - leftMargin) / 5;
            float rightPos =  4 * (rightMargin - leftMargin) / 5;
            int count = 0;

            System.Drawing.Font printFont = new System.Drawing.Font("Arial", 10);
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            // Work out the number of lines per page, using the MarginBounds.
            float linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);
            float lineCount = 0;
            foreach (var selectedMeal in colData)
            {
                // calculate the next line position based on the height of the font according to the printing device
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                e.Graphics.DrawString(selectedMeal.Date, printFont, myBrush, xPos, yPos);
                lineCount++;
   
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                e.Graphics.DrawString(selectedMeal.Meal, printFont, myBrush, xPos + 20, yPos);

                lineCount++;

                if (lineCount > linesPerPage) { break; }
            }

            lineCount = 0;
            count = 0;

            SelectedIngredientsCollection ingredientData = (SelectedIngredientsCollection)this.FindResource("SelectedIngredientsCollectionData");

            foreach (SelectedIngredient ingredient in ingredientData)
            {               
                // calculate the next line position based on the height of the font according to the printing device
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                xPos = centrePos;
                if (lineCount > linesPerPage) xPos = rightPos;
                e.Graphics.DrawString(ingredient.Ingredient, printFont, myBrush, xPos, yPos);
                lineCount++;
            }

            // If there are more lines, print another page.
            if (lineCount > linesPerPage)
            {
           //     e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
                myBrush.Dispose();
            }
        }
        public void AddTextWatermark(string strOraginalPath)
        {
            if (string.IsNullOrEmpty(_strWatermarkText))//如果水印文字为空
            {
                return;
            }

            System.Drawing.Image imgOraginal = System.Drawing.Image.FromFile(strOraginalPath);
            int iWidth = imgOraginal.Width;
            int iHeight = imgOraginal.Height;
            System.Drawing.Bitmap bitOraginal = new System.Drawing.Bitmap(imgOraginal, iWidth, iHeight);
            imgOraginal.Dispose();

            System.Drawing.Graphics gOraginal = System.Drawing.Graphics.FromImage(bitOraginal);

            System.Drawing.Rectangle rectTextField = new System.Drawing.Rectangle(10, 10, iWidth - 20, iHeight - 20);
            System.Drawing.StringFormat sf = GetStringFormat();

            System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(_btWatermarkTransparency/*文字的透明度*/, _fontWatermarkColor));
            gOraginal.DrawString(_strWatermarkText, _fontWatermarkFont, brush, rectTextField, sf);

            sf.Dispose();
            brush.Dispose();

            bitOraginal.Save(strOraginalPath, System.Drawing.Imaging.ImageFormat.Jpeg);

            gOraginal.Dispose();
            bitOraginal.Dispose();
        }
示例#22
0
        /// <summary>
        /// Creates a Bitmap containing the ASCII output.
        /// </summary>
        /// <param name="inputW">Width of the input image</param>
        /// <param name="inputH">Height of the input image</param>
        /// <param name="ascii">List of ASCII characters and colors</param>
        /// <param name="fontName">Font name</param>
        /// <param name="fontSize">Font size</param>
        /// <returns>Bitmap</returns>
        static Bitmap FormatOutputBmp(int inputW, int inputH, List <Tuple <char, Color> > ascii, string fontName, int fontSize)
        {
            inputW   = (int)(inputW * scale);
            inputH   = (int)(inputH * scale);
            fontSize = (int)(fontSize * scale * overlap);

            Bitmap     bmp = new PixelSet((uint)inputW, (uint)inputH, 0x11).ToBitmap();
            SolidBrush b   = new SolidBrush(Color.White);
            Graphics   g   = Graphics.FromImage(bmp);

            // Temporarily disable logging to prevent repeats of AsciiFont warnings
            uint lm = logMode;

            logMode = 0;
            AsciiFont outFont = new AsciiFont(fontName, fontSize);

            logMode = lm;

            float lineW    = -1;
            int   numLines = 1;

            for (int i = 0; i < ascii.Count; i++)
            {
                if (ascii[i].Item1 == '\n')
                {
                    if (numLines < 2)
                    {
                        lineW = i;
                    }
                    numLines++;
                }
            }
            if (lineW == -1)
            {
                lineW = ascii.Count;
            }
        #if Windows
            float  padW    = (inputW - (int)(lineW * charWidth * scale)) * 0.25f;
            PointF textPos = new PointF(padW, -1f);
        #elif Linux
            float  padW    = (inputW - (int)(lineW * charWidth * scale)) * 0.5f;
            PointF textPos = new PointF(padW, 0f);
        #endif

            for (int i = 0; i < ascii.Count; i++)
            {
                string str = string.Empty + ascii[i].Item1;
                b.Color = ascii[i].Item2;

                g.DrawString(str, outFont.Font, b, textPos);

                if (str == "\n")
                {
                    textPos.X  = padW;
                    textPos.Y += (int)(charHeight * scale);
                }
                else
                {
                    textPos.X += (int)(charWidth * scale);
                }
            }

            g.Flush();
            b.Dispose();

            return(bmp);
        }
示例#23
0
        /// <summary>
        /// Draw rich text at specified area.
        /// </summary>
        /// <param name="g">Graphics context.</param>
        /// <param name="bounds">Target area to draw rich text.</param>
        internal void Draw(IGraphics g, Rectangle bounds)
        {
            var measuredSize = UpdateText();

            RGFloat x = bounds.Left + 2;
            RGFloat y = bounds.Top + 2;

            if (!this.Overflow)
            {
                g.PushClip(bounds);
            }

            switch (this.VerticalAlignment)
            {
            default:
            case ReoGridVerAlign.General:
            case ReoGridVerAlign.Bottom:
                y += (bounds.Height - measuredSize.Height) - 6;
                break;

            case ReoGridVerAlign.Middle:
                y += (bounds.Height - measuredSize.Height) / 2 - 2;
                break;

            case ReoGridVerAlign.Top:
                y++;
                break;
            }

            Run lastRun = null;

            RGBrush    lastBrush = null;
            SolidColor lastColor = SolidColor.Transparent;

#if DEBUG1
            g.DrawRectangle(System.Drawing.Pens.DarkRed, x, y, x + measuredSize.Width, y + measuredSize.Height);
#endif // DEBUG

            foreach (var p in this.paragraphs)
            {
                foreach (var l in p.lines)
                {
#if DEBUG
                    //g.DrawRectangle(System.Drawing.Pens.Blue, x, y + l.leftTop.Y, l.Width, l.Height);
#endif // DEBUG

                    foreach (var b in l.boxes)
                    {
                        var r = b.Run;

                        if (lastRun != r)
                        {
                            SolidColor textColor = r.TextColor;

                            if (textColor.IsTransparent)
                            {
                                textColor = this.DefaultTextColor;
                            }

                            if (textColor != lastColor || lastBrush == null)
                            {
                                lastColor = textColor;

#if WINFORM || ANDROID
                                if (lastBrush != null)
                                {
                                    lastBrush.Dispose();
                                }
#endif // WINFORM
                                lastBrush = new RGBrush(lastColor);
                            }

                            lastRun = r;
                        }

#if DEBUG
                        //RGFloat baseLine = l.Top + l.Ascent;
                        //g.DrawLine(System.Drawing.Pens.Blue, b.Left + 1, baseLine, b.Right - 1, baseLine);
#endif // DEBUG

                        if ((r.FontStyles & FontStyles.Underline) == FontStyles.Underline)
                        {
#if WINFORM
                            using (var underlinePen = new RGPen(lastBrush.Color))
#elif WPF
                            var underlinePen = new RGPen(new RGBrush(lastBrush.Color), 1);
#endif // WPF
                            {
                                RGFloat underlineY = l.Height + y + 1;
                                g.PlatformGraphics.DrawLine(underlinePen, new Point(b.leftTop.X + x, underlineY), new Point(b.rightTop.X + x, underlineY));
                            }
                        }

                        var tx = b.leftTop.X + x;
                        var ty = b.leftTop.Y + y;

#if WINFORM || ANDROID
                        g.PlatformGraphics.DrawString(b.Str, b.FontInfo.Font, lastBrush, tx, ty, this.sf);
#elif WPF
                        var gr = new System.Windows.Media.GlyphRun(b.FontInfo.GlyphTypeface, 0, false, r.FontSize * 1.33d,
                                                                   new ushort[] { b.GlyphIndex },
                                                                   new System.Windows.Point(tx, ty),
                                                                   new double[] { b.Width }, null, null, null, null,
                                                                   null, null);

                        g.PlatformGraphics.DrawGlyphRun(lastBrush, gr);
#endif // WPF
                    }
                }

                //y += p.TextSize.Height + this.paragraphSpacing;
            }

            if (!this.Overflow)
            {
                g.PopClip();
            }
        }
示例#24
0
        private SharpDX.Direct2D1.Bitmap DrawString(int width, int height, float fontSize15, float fontSize30)
        {
            //Dont know how to draw this on SharpDx so i'm using system drawing to draw and convet it to SharpDX Bitmap.
            System.Drawing.Graphics gr = System.Drawing.Graphics.FromHwnd(IntPtr.Zero);
            System.Drawing.Bitmap   bm = new System.Drawing.Bitmap(width, height, gr);

            gr.Dispose();
            gr = System.Drawing.Graphics.FromImage(bm);
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();

            var strformat = new System.Drawing.StringFormat
            {
                Alignment     = System.Drawing.StringAlignment.Center,
                LineAlignment = System.Drawing.StringAlignment.Center
            };

            gr.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            gr.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;


            if (PlayerControl.Text_Intro == string.Empty || PlayerControl.Text_Intro == null)
            {
                string b          = "BossDoy KaraokeNow";
                var    stringSize = MeasureString(b, fontSize15);
                path.AddString(b, fontFamily, (int)System.Drawing.FontStyle.Bold, fontSize15, new System.Drawing.Point((bm.Width / 2), (bm.Height / 2) - ((int)stringSize.Height) / 2), strformat);
                path.AddString("Select a song", fontFamily,
                               (int)System.Drawing.FontStyle.Bold, fontSize30, new System.Drawing.Point(bm.Width / 2, (bm.Height / 2) + ((int)stringSize.Height) / 2), strformat);
            }
            else
            {
                string[] intro      = PlayerControl.Text_Intro.Split(new char[] { '@' }, StringSplitOptions.None);
                var      stringSize = MeasureString(intro[0], fontSize15);
                path.AddString(intro[0], fontFamily, (int)System.Drawing.FontStyle.Bold, fontSize15, new System.Drawing.Point((bm.Width / 2), (bm.Height / 2) - ((int)stringSize.Height) / 2), strformat);
                if (intro.Length > 1)
                {
                    path.AddString(intro[1], fontFamily,
                                   (int)System.Drawing.FontStyle.Bold, fontSize30, new System.Drawing.Point(bm.Width / 2, (bm.Height / 2) + ((int)stringSize.Height) / 2), strformat);
                }
                else
                {
                    path.AddString("Select a song", fontFamily,
                                   (int)System.Drawing.FontStyle.Bold, fontSize30, new System.Drawing.Point(bm.Width / 2, (bm.Height / 2) + ((int)stringSize.Height) / 2), strformat);
                }
            }

            System.Drawing.Pen penOut = new System.Drawing.Pen(System.Drawing.Color.FromArgb(32, 117, 81), (fontSize30 / 4));
            penOut.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
            gr.DrawPath(penOut, path);

            System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(234, 137, 6), (fontSize30 / 8));
            pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
            gr.DrawPath(pen, path);
            System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(128, 0, 255));
            gr.FillPath(brush, path);

            path.Dispose();
            penOut.Dispose();
            pen.Dispose();
            brush.Dispose();
            gr.Dispose();

            return(ConvertToSharpDXBitmap(m_D2DContext.d2dContext, bm));
        }
示例#25
0
        override public bool RefreshMap(DrawPhase phase, ICancelTracker cancelTracker)
        {
            base._requestExceptions = null;

            if (_graphics != null && phase == DrawPhase.Graphics)
            {
                return(true);
            }

            this.ZoomTo(m_actMinX, m_actMinY, m_actMaxX, m_actMaxY);

            if (cancelTracker == null)
            {
                cancelTracker = new CancelTracker();
            }

            GeometricTransformer geoTransformer = new GeometricTransformer();

            //geoTransformer.ToSpatialReference = this.SpatialReference;

            if (_image == null)
            {
                _image = new System.Drawing.Bitmap(iWidth, iHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            }

            _graphics = System.Drawing.Graphics.FromImage(_image);
            this.dpi  = _graphics.DpiX * this.ScaleSymbolFactor;

            if (BackgroundColor.A != 0 /* && !Display.MakeTransparent*/)
            {
                using (System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(BackgroundColor))
                {
                    _graphics.FillRectangle(brush, 0, 0, _image.Width, _image.Height);
                    brush.Dispose();
                }
            }

            if (phase == DrawPhase.All || phase == DrawPhase.Geography)
            {
                this.GeometricTransformer = geoTransformer;

                // Thread für MapServer Datasets starten...

                #region WebServiceLayer
                List <IWebServiceLayer> webServices;
                if (this.TOC != null)
                {
                    webServices = ListOperations <IWebServiceLayer> .Swap(this.TOC.VisibleWebServiceLayers);
                }
                else
                {
                    webServices = new List <IWebServiceLayer>();
                    foreach (IDatasetElement layer in this.MapElements)
                    {
                        if (!(layer is IWebServiceLayer))
                        {
                            continue;
                        }
                        if (((ILayer)layer).Visible)
                        {
                            webServices.Add((IWebServiceLayer)layer);
                        }
                    }
                }
                int webServiceOrder = 0, webServiceOrder2 = 1;
                foreach (IWebServiceLayer element in webServices)
                {
                    if (!((ILayer)element).Visible)
                    {
                        continue;
                    }
                    IWebServiceLayer wsLayer = LayerFactory.Create(((IWebServiceLayer)element).WebServiceClass.Clone() as IClass, element as ILayer) as IWebServiceLayer;

                    if (wsLayer == null || wsLayer.WebServiceClass == null)
                    {
                        continue;
                    }
                    wsLayer.WebServiceClass.SpatialReference = this.SpatialReference;

                    List <IWebServiceClass> additionalWebServices = new List <IWebServiceClass>();
                    if (BeforeRenderLayers != null)
                    {
                        List <ILayer> modLayers = new List <ILayer>();
                        foreach (IWebServiceTheme theme in wsLayer.WebServiceClass.Themes)
                        {
                            if (theme is ILayer)
                            {
                                modLayers.Add(theme as ILayer);
                            }
                        }
                        BeforeRenderLayers(this, modLayers);

                        foreach (ILayer additionalLayer in MapServerHelper.FindAdditionalWebServiceLayers(wsLayer.WebServiceClass, modLayers))
                        {
                            IWebServiceClass additionalWebService = MapServerHelper.CloneNonVisibleWebServiceClass(wsLayer.WebServiceClass);
                            MapServerHelper.CopyWebThemeProperties(additionalWebService, additionalLayer);

                            if (MapServerHelper.HasVisibleThemes(additionalWebService))
                            {
                                additionalWebServices.Add(additionalWebService);
                            }
                        }
                    }


                    ServiceRequestThread srt = new ServiceRequestThread(this, wsLayer, webServiceOrder++);
                    srt.finish += new ServiceRequestThread.RequestThreadFinished(MapRequestThread_finished);
                    Thread thread = new Thread(new ThreadStart(srt.ImageRequest));
                    m_imageMerger.max++;
                    thread.Start();


                    foreach (IWebServiceClass additionalWebService in additionalWebServices)
                    {
                        wsLayer = LayerFactory.Create(additionalWebService, element as ILayer) as IWebServiceLayer;
                        if (wsLayer == null || wsLayer.WebServiceClass == null)
                        {
                            continue;
                        }
                        wsLayer.WebServiceClass.SpatialReference = this.SpatialReference;

                        srt         = new ServiceRequestThread(this, wsLayer, (++webServiceOrder2) + webServices.Count);
                        srt.finish += new ServiceRequestThread.RequestThreadFinished(MapRequestThread_finished);
                        thread      = new Thread(new ThreadStart(srt.ImageRequest));
                        m_imageMerger.max++;
                        thread.Start();
                    }
                }
                #endregion

                List <ILayer> layers = new List <ILayer>();
                if (this.TOC != null)
                {
                    if (this.ToString() == "gView.MapServer.Instance.ServiceMap")
                    {
                        layers = ListOperations <ILayer> .Swap(this.TOC.Layers);
                    }
                    else
                    {
                        layers = ListOperations <ILayer> .Swap(this.TOC.VisibleLayers);
                    }
                }
                else
                {
                    layers = new List <ILayer>();
                    foreach (IDatasetElement layer in this.MapElements)
                    {
                        if (!(layer is ILayer))
                        {
                            continue;
                        }
                        if (((ILayer)layer).Visible)
                        {
                            layers.Add((ILayer)layer);
                        }
                    }
                }

                if (BeforeRenderLayers != null)
                {
                    //
                    // Kopie der Original Layer erstellen
                    // ACHTUNG: Renderer werden nicht kopiert!
                    // dürfen in BeforeRenderLayers nicht verändert werden...
                    // Eine zuweisung eines neuen Renderers ist jedoch legitim.
                    //
                    List <ILayer> modLayers = new List <ILayer>();
                    foreach (IDatasetElement element in layers)
                    {
                        if (!(element is ILayer) || element is IWebServiceTheme)
                        {
                            continue;
                        }
                        ILayer layer = (ILayer)element;
                        if (layer.MinimumScale > 1 && layer.MinimumScale > this.mapScale)
                        {
                            continue;
                        }
                        if (layer.MaximumScale > 1 && layer.MaximumScale < this.mapScale)
                        {
                            continue;
                        }

                        modLayers.Add(LayerFactory.Create(layer.Class, layer));
                    }
                    BeforeRenderLayers(this, modLayers);
                    layers = modLayers;
                }
                //layers = ModifyLayerList(layers);
                List <IFeatureLayer> labelLayers = this.OrderedLabelLayers(layers);

                LabelEngine.Init(this.Display, false);
                foreach (IDatasetElement element in layers)
                {
                    if (!cancelTracker.Continue)
                    {
                        break;
                    }

                    if (!(element is ILayer))
                    {
                        continue;
                    }
                    ILayer layer = (ILayer)element;

                    //if (_ceckLayerVisibilityBeforeDrawing)
                    //{
                    //    if (!LayerIsVisible(layer)) continue;
                    //}
                    if (!layer.Visible)
                    {
                        continue;
                    }
                    if (layer.MinimumScale > 1 && layer.MinimumScale > this.mapScale)
                    {
                        continue;
                    }
                    if (layer.MaximumScale > 1 && layer.MaximumScale < this.mapScale)
                    {
                        continue;
                    }
#if (DEBUG)
                    //Logger.LogDebug("Drawing Layer:" + element.Title);
#endif
                    SetGeotransformer((ILayer)element, geoTransformer);

                    if (layer is IFeatureLayer)
                    {
                        IFeatureLayer fLayer = (IFeatureLayer)layer;
                        if (fLayer.FeatureRenderer == null &&
                            (
                                fLayer.LabelRenderer == null ||
                                (fLayer.LabelRenderer != null && fLayer.LabelRenderer.RenderMode != LabelRenderMode.RenderWithFeature)
                            ))
                        {
                            //continue;
                        }
                        else
                        {
                            RenderFeatureLayerThread rlt = new RenderFeatureLayerThread(this, fLayer, cancelTracker, new FeatureCounter());
                            if (fLayer.LabelRenderer != null && fLayer.LabelRenderer.RenderMode == LabelRenderMode.RenderWithFeature)
                            {
                                rlt.UseLabelRenderer = true;
                            }
                            else
                            {
                                rlt.UseLabelRenderer = labelLayers.IndexOf(fLayer) == 0;  // letzten Layer gleich mitlabeln
                            }
                            if (rlt.UseLabelRenderer)
                            {
                                labelLayers.Remove(fLayer);
                            }

                            rlt.Render();
                        }
                        //thread = new Thread(new ThreadStart(rlt.Render));
                        //thread.Start();
                    }
                    if (layer is IRasterLayer && ((IRasterLayer)layer).RasterClass != null)
                    {
                        IRasterLayer rLayer = (IRasterLayer)layer;
                        if (rLayer.RasterClass.Polygon == null)
                        {
                            continue;
                        }

                        IEnvelope dispEnvelope = this.Envelope;
                        if (Display.GeometricTransformer != null)
                        {
                            dispEnvelope = (IEnvelope)((IGeometry)Display.GeometricTransformer.InvTransform2D(dispEnvelope)).Envelope;
                        }

                        if (gView.Framework.SpatialAlgorithms.Algorithm.IntersectBox(rLayer.RasterClass.Polygon, dispEnvelope))
                        {
                            if (rLayer.Class is IParentRasterLayer)
                            {
                                DrawRasterParentLayer((IParentRasterLayer)rLayer.Class, cancelTracker, rLayer);
                            }
                            else
                            {
                                RenderRasterLayerThread rlt = new RenderRasterLayerThread(this, rLayer, rLayer, cancelTracker);
                                rlt.Render();

                                //thread = new Thread(new ThreadStart(rlt.Render));
                                //thread.Start();
                            }
                        }
                    }
                    // Andere Layer (zB IRasterLayer)

#if (DEBUG)
                    //Logger.LogDebug("Finished drawing layer: " + element.Title);
#endif
                }

                // Label Features
                if (labelLayers.Count != 0)
                {
                    foreach (IFeatureLayer fLayer in labelLayers)
                    {
                        this.SetGeotransformer(fLayer, geoTransformer);

                        if (!fLayer.Visible)
                        {
                            continue;
                        }
                        RenderLabelThread rlt = new RenderLabelThread(this, fLayer, cancelTracker);
                        rlt.Render();
                    }
                }

                LabelEngine.Draw(this.Display, cancelTracker);
                LabelEngine.Release();

                if (cancelTracker.Continue)
                {
                    while (m_imageMerger.Count < m_imageMerger.max)
                    {
                        Thread.Sleep(10);
                    }
                }
                if (_drawScaleBar)
                {
                    m_imageMerger.mapScale = this.mapScale;
                    m_imageMerger.dpi      = this.dpi;
                }
#if (DEBUG)
                //Logger.LogDebug("Merge Images");
#endif
                m_imageMerger.Merge(_image, this.Display);
                m_imageMerger.Clear();
#if (DEBUG)
                //Logger.LogDebug("Merge Images Finished");
#endif
            }

            if (phase == DrawPhase.All || phase == DrawPhase.Graphics)
            {
                foreach (IGraphicElement grElement in Display.GraphicsContainer.Elements)
                {
                    grElement.Draw(Display);
                }
            }

            base.AppendExceptionsToImage();

            if (_graphics != null)
            {
                _graphics.Dispose();
            }
            _graphics = null;

            if (geoTransformer != null)
            {
                this.GeometricTransformer = null;
                geoTransformer.Release();
                geoTransformer = null;
            }
            return(true);
        }
        void PrintPage(object sender, PrintPageEventArgs e)
        {
            SelectedMealCollection colData = (SelectedMealCollection)this.FindResource("SelectedMealCollectionData");
            float leftMargin  = e.MarginBounds.Left;
            float rightMargin = e.MarginBounds.Right;
            float topMargin   = e.MarginBounds.Top;

            float yPos      = leftMargin;
            float xPos      = 0;
            float centrePos = 2 * (rightMargin - leftMargin) / 5;
            float rightPos  = 4 * (rightMargin - leftMargin) / 5;
            int   count     = 0;

            System.Drawing.Font       printFont = new System.Drawing.Font("Arial", 10);
            System.Drawing.SolidBrush myBrush   = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            // Work out the number of lines per page, using the MarginBounds.
            float linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);
            float lineCount    = 0;

            foreach (var selectedMeal in colData)
            {
                // calculate the next line position based on the height of the font according to the printing device
                yPos = topMargin + (count++ *printFont.GetHeight(e.Graphics));
                e.Graphics.DrawString(selectedMeal.Date, printFont, myBrush, xPos, yPos);
                lineCount++;

                yPos = topMargin + (count++ *printFont.GetHeight(e.Graphics));

                foreach (string meal in selectedMeal.Meals)
                {
                    e.Graphics.DrawString(meal, printFont, myBrush, xPos + 20, yPos);
                }

                lineCount++;

                if (lineCount > linesPerPage)
                {
                    break;
                }
            }

            lineCount = 0;
            count     = 0;

            SelectedIngredientsCollection ingredientData = (SelectedIngredientsCollection)this.FindResource("SelectedIngredientsCollectionData");

            foreach (SelectedIngredient ingredient in ingredientData)
            {
                // calculate the next line position based on the height of the font according to the printing device
                yPos = topMargin + (count++ *printFont.GetHeight(e.Graphics));
                xPos = centrePos;
                if (lineCount > linesPerPage)
                {
                    xPos = rightPos;
                }
                e.Graphics.DrawString(ingredient.Ingredient, printFont, myBrush, xPos, yPos);
                lineCount++;
            }

            // If there are more lines, print another page.
            if (lineCount > linesPerPage)
            {
                //     e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
                myBrush.Dispose();
            }
        }
示例#27
0
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            int i1 = e.Index;

            if (i1 < 0)
            {
                return;
            }
            if (Items[i1].ToString() == "-----")
            {
                return;
            }
            bool flag = false;

            if (((i1 - 1) > 0) && Items[i1 - 1].ToString() == "-----")
            {
                flag = true;
            }
            if (!Enabled)
            {
                System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.SystemColors.Control);
                e.Graphics.FillRectangle(brush, ClientRectangle);
                brush.Dispose();
            }
            else
            {
                e.DrawBackground();
            }
            System.Drawing.Graphics  graphics   = e.Graphics;
            System.Drawing.Rectangle rectangle1 = e.Bounds;
            System.Drawing.Point     point1     = rectangle1.Location;
            int i2 = point1.Y + _separatorWidth - 8;

            if (flag)
            {
                System.Drawing.Pen pen = new System.Drawing.Pen(_separatorColor, (float)_separatorWidth);
                pen.DashStyle = _separatorStyle;
                System.Drawing.Rectangle rectangle2 = e.Bounds;
                System.Drawing.Point     point2     = rectangle2.Location;
                System.Drawing.Rectangle rectangle3 = e.Bounds;
                System.Drawing.Point     point3     = rectangle3.Location;
                System.Drawing.Rectangle rectangle4 = e.Bounds;
                graphics.DrawLine(pen, point2.X + _separatorMargin, i2, point3.X + rectangle4.Width - _separatorMargin, i2);
                pen.Dispose();
            }
            System.Drawing.Rectangle rectangle5 = e.Bounds;
            System.Drawing.Point     point4     = rectangle5.Location;
            i2 = point4.Y + _separatorWidth;
            string s = Items[i1].ToString();

            if (!System.String.IsNullOrEmpty(DisplayMember))
            {
                System.Reflection.PropertyInfo propertyInfo = Items[i1].GetType().GetProperty(DisplayMember);
                s = propertyInfo.GetValue(Items[i1], null).ToString();
            }
            System.Drawing.Color color = ForeColor;
            if (System.Windows.Forms.DrawItemState.Selected == (System.Windows.Forms.DrawItemState.Selected & e.State))
            {
                color = System.Drawing.SystemColors.HighlightText;
            }
            if (System.Windows.Forms.DrawItemState.Disabled == (System.Windows.Forms.DrawItemState.Disabled & e.State))
            {
                color = System.Drawing.SystemColors.GrayText;
            }
            System.Drawing.Rectangle rectangle6 = e.Bounds;
            System.Windows.Forms.TextRenderer.DrawText(graphics, s, e.Font, rectangle6.Location, color);
            base.OnDrawItem(e);
        }