FillPath() public méthode

public FillPath ( Brush brush, GraphicsPath path ) : void
brush Brush
path System.Drawing.Drawing2D.GraphicsPath
Résultat void
Exemple #1
1
 // paramters:
 //      pen 绘制边框。可以为null,那样就整体一个填充色,没有边框
 //      brush   绘制填充色。可以为null,那样就只有边框
 public static void RoundRectangle(Graphics graphics,
     Pen pen,
     Brush brush,
     float x,
     float y,
     float width,
     float height,
     float radius)
 {
     using (GraphicsPath path = new GraphicsPath())
     {
         path.AddLine(x + radius, y, x + width - (radius * 2), y);
         path.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90);
         path.AddLine(x + width, y + radius, x + width, y + height - (radius * 2));
         path.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); // Corner
         path.AddLine(x + width - (radius * 2), y + height, x + radius, y + height);
         path.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
         path.AddLine(x, y + height - (radius * 2), x, y + radius);
         path.AddArc(x, y, radius * 2, radius * 2, 180, 90);
         path.CloseFigure();
         if (brush != null)
             graphics.FillPath(brush, path);
         if (pen != null)
             graphics.DrawPath(pen, path);
     }
 }
        public static void RenderEllipseGlass(Graphics g, Rectangle ownerRect, GlassPosition position,
            float positionFactor, Color glassColor, int alphaCenter, int alphaSurround)
        {
            if (!(positionFactor > 0 && positionFactor < 1))
                throw new ArgumentException("positionFactor must be between 0 and 1, but not include 0 and 1. ",
                    "positionFactor");

            ownerRect.Height--;
            ownerRect.Width--;

            if (ownerRect.Width < 1 || ownerRect.Height < 1)
                return;

            using (GraphicsPath gp = new GraphicsPath())
            {
                gp.AddEllipse(ownerRect);
                using (PathGradientBrush pb = new PathGradientBrush(gp))
                {
                    pb.CenterPoint = GetEllipseGlassCenterPoint(ownerRect, position, positionFactor);
                    pb.CenterColor = Color.FromArgb(alphaCenter, glassColor);
                    pb.SurroundColors = new Color[] { Color.FromArgb(alphaSurround, glassColor) };
                    using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias))
                    {
                        g.FillPath(pb, gp);
                    }
                }
            }
        }
Exemple #3
1
 public static void FillRoundRectangle(Graphics g, Brush brush, Rectangle rect, int cornerRadius)
 {
     using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
     {
         g.FillPath(brush, path);
     }
 }
        public override bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Point ptDraw,
            System.Drawing.StringFormat strFormat)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddString(strText, fontFamily, (int)fontStyle, fontSize, ptDraw, strFormat);

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                else
                {
                    graphics.FillPath(m_brushText, path);
                }
            }
            return(true);
        }
        public override bool GdiDrawString(
            System.Drawing.Graphics pGraphics,
            LOGFONT pLogFont,
            string pszText,
            System.Drawing.Rectangle rtDraw)
        {
            using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding))
            {
                bool b = GDIPath.GetStringPath(
                    pGraphics,
                    pPath,
                    pszText,
                    pLogFont,
                    rtDraw);

                if (false == b)
                {
                    return(false);
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        pGraphics.FillPath(brush, pPath);
                    }
                }
                else
                {
                    pGraphics.FillPath(m_brushText, pPath);
                }
            }
            return(true);
        }
Exemple #6
0
    private void Render(System.Drawing.Graphics gfx)
    {
        gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

        RectangleF rectOut    = new(RegionOffset / 2, RegionOffset / 2, this.ClientRectangle.Width - RegionOffset, this.ClientRectangle.Height - RegionOffset);
        RectangleF rectIn     = RectangleF.Inflate(rectOut, -_fBorderWidth, -_fBorderWidth);        // Mantains the rectangle's geometric center.
        RectangleF rectRegion = RectangleF.Inflate(rectOut, RegionOffset / 2, RegionOffset / 2);    // Inflates in both + and - directions, hence _fRegionOffset / 2 for a total of _fRegionOffset

        GraphicsPath path = MakeRoundedRect(rectOut, _xRadius, _yRadius);

        gfx.FillPath(new SolidBrush(FillColor), path);

        if (ShowBorder)
        {
            path.AddPath(MakeRoundedRect(rectIn, _xRadius - _fBorderWidth, _yRadius - _fBorderWidth), false);
            gfx.FillPath(new SolidBrush(BorderColor), path);
        }

        this.Region = new Region(MakeRoundedRect(rectRegion, _xRadius + RegionOffset / 2, _yRadius + RegionOffset / 2));

        // Draw text
        if (ShowText)
        {
            DrawText(gfx);
        }
    }
Exemple #7
0
        /// <summary>
        /// Renders a label to the map.
        /// </summary>
        /// <param name="graphics">Graphics reference</param>
        /// <param name="labelPoint">Label placement</param>
        /// <param name="offset">Offset of label in screen coordinates</param>
        /// <param name="font">Font used for rendering</param>
        /// <param name="forecolor">Font forecolor</param>
        /// <param name="backcolor">Background color</param>
        /// <param name="halo">Color of halo</param>
        /// <param name="rotation">Text rotation in degrees</param>
        /// <param name="text">Text to render</param>
        /// <param name="viewport"></param>
        public static void DrawLabel(Graphics graphics, Point labelPoint, Offset offset, Styles.Font font, Styles.Color forecolor, Styles.Brush backcolor, Styles.Pen halo, double rotation, string text, IViewport viewport, StyleContext context)
        {
            SizeF fontSize = graphics.MeasureString(text, font.ToGdi(context)); //Calculate the size of the text
            labelPoint.X += offset.X; labelPoint.Y += offset.Y; //add label offset
            if (Math.Abs(rotation) > Constants.Epsilon && !double.IsNaN(rotation))
            {
                graphics.TranslateTransform((float)labelPoint.X, (float)labelPoint.Y);
                graphics.RotateTransform((float)rotation);
                graphics.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
                if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
                    graphics.FillRectangle(backcolor.ToGdi(context), 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
                var path = new GraphicsPath();
                path.AddString(text, new FontFamily(font.FontFamily), (int)font.ToGdi(context).Style, font.ToGdi(context).Size, new System.Drawing.Point(0, 0), null);
                if (halo != null)
                    graphics.DrawPath(halo.ToGdi(context), path);
                graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
            }
            else
            {
                if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
                    graphics.FillRectangle(backcolor.ToGdi(context), (float)labelPoint.X, (float)labelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);

                var path = new GraphicsPath();

                //Arial hack
                path.AddString(text, new FontFamily("Arial"), (int)font.ToGdi(context).Style, (float)font.Size, new System.Drawing.Point((int)labelPoint.X, (int)labelPoint.Y), null);
                if (halo != null)
                    graphics.DrawPath(halo.ToGdi(context), path);
                graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
            }
        }
        public bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Rectangle rtDraw,
            System.Drawing.StringFormat strFormat)
        {
            GraphicsPath path = new GraphicsPath();

            path.AddString(strText, fontFamily, (int)fontStyle, fontSize, rtDraw, strFormat);

            Pen pen = new Pen(m_clrOutline, m_nThickness);

            pen.LineJoin = LineJoin.Round;
            graphics.DrawPath(pen, path);

            if (m_bClrText)
            {
                SolidBrush brush = new SolidBrush(m_clrText);
                graphics.FillPath(brush, path);
            }
            else
            {
                graphics.FillPath(m_brushText, path);
            }

            return(true);
        }
 public override void DrawTab(Color foreColor, Color backColor, Color highlightColor, Color shadowColor, Color borderColor, bool active, bool mouseOver, DockStyle dock, Graphics graphics, SizeF tabSize)
 {
     RectangleF headerRect = new RectangleF(0, 0, tabSize.Width, tabSize.Height);
     Rectangle header = new Rectangle(0, 0, (int)tabSize.Width, (int)tabSize.Height);
     using (var path = ShapeRender.GetTopRoundRect(0, 0, tabSize.Width, tabSize.Height, 0.5f))
     {
         if (active)
         {
             using (Brush brush = new SolidBrush(foreColor))
             using (Pen pen = new Pen(shadowColor, 0.2f))
             {
                 graphics.FillPath(brush, path);
                 graphics.DrawRectangle(pen, header);
             }
         }
         else
         {
             using (Brush brush = new SolidBrush(backColor))
             using (Pen pen = new Pen(shadowColor))
             {
                 graphics.FillPath(brush, path);
             }
         }
     }
 }
        public static void FillRoundedRectangle(Rectangle rectangle, GlassGradient gradient, bool isSunk, bool isGlass,
                                                Graphics graphics)
        {
            if (rectangle.Width == 0 || rectangle.Height == 0)
                return;

            var path = GetRoundedRectanglePath(rectangle);

            var activeGradient = isSunk
                                     ? new GlassGradient(gradient.Bottom, gradient.Top)
                                     : new GlassGradient(gradient.Top, gradient.Bottom);

            var brush = activeGradient.GetBrush(rectangle);
            graphics.FillPath(brush, path);
            brush.Dispose();

            if (isGlass)
            {
                graphics.SetClip(path);

                var glassRectangle = isSunk
                                         ? new Rectangle(new Point(rectangle.Left, rectangle.Height/2),
                                                         new Size(rectangle.Width, rectangle.Height/2))
                                         : new Rectangle(rectangle.Location,
                                                         new Size(rectangle.Width, rectangle.Height/2));
                var glassPath = GetRoundedRectanglePath(glassRectangle);
                Brush glassBrush = new LinearGradientBrush(glassRectangle, Color.Transparent,
                                                           Color.FromArgb(32, 255, 255, 255), 90.0f);

                graphics.FillPath(glassBrush, glassPath);

                glassBrush.Dispose();
                glassPath.Dispose();
            }
        }
        public override void OnRenderNormalView(System.Drawing.Graphics g, Model.DataModel data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font TextFont, System.Drawing.Font DataFont)
        {
            //utils.drawReportView(g, RePortViewStyle.Arc_angle_rectangle, StartX, StartY, ViewWidth, ViewHeight, linePen.Color, TextBrush, DataBrush, "录像", 130, 200);

            //圆角的弧度
            int       radius       = EViewHeight / 2;
            float     per          = EViewWidth * 1.0f / MaxNum;
            float     realShowData = per * int.Parse(TextAndData[1]);
            Rectangle rect         = new Rectangle(EStartX, EStartY, EViewWidth, 2 * radius);
            Rectangle rectReal     = new Rectangle(EStartX, EStartY, (int)realShowData, 2 * radius);

            //底色
            Brush        selfBrush = new SolidBrush(Color.FromArgb(200, 88, 94, 92));
            GraphicsPath path      = ReportViewUtils.CreateRoundedRectanglePath(rect, radius);

            //绘制底色
            g.FillPath(selfBrush, path);

            //绘制展示色
            path = ReportViewUtils.CreateRoundedRectanglePath(rectReal, radius);
            g.FillPath(lineBrush, path);

            //绘制字体
            ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Left_Left, TextAndData[0], TextFont, TextBrush, EStartX, EStartY - EViewHeight, EViewWidth / 2, EViewHeight, 8);

            //绘制右侧百分比
            float  perNum = int.Parse(TextAndData[1]) * 1.0f / MaxNum * 100;
            string str    = ((int)perNum).ToString();

            ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Right_Right, str + "%", TextFont, TextBrush, EStartX + EViewWidth / 2, EStartY - EViewHeight, EViewWidth / 2, EViewHeight, 8);


            selfBrush.Dispose();
        }
        public override bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Point ptDraw,
            System.Drawing.StringFormat strFormat)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddString(strText, fontFamily, (int)fontStyle, fontSize, ptDraw, strFormat);

                using (Pen pen = new Pen(m_clrOutline, m_nThickness))
                {
                    pen.LineJoin = LineJoin.Round;
                    graphics.DrawPath(pen, path);
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                else
                {
                    graphics.FillPath(m_brushText, path);
                }
            }
            return(true);
        }
            /// <summary>
            /// Initializes a new instance of the <see cref="PixelZoom"/> class.
            /// </summary>
            /// <param name="parent">The parent.</param>
            public PixelZoom(ZeroitEyeDropper parent)
            {
                this.parent          = parent;
                this.ShowInTaskbar   = false;
                this.TopMost         = true;
                this.FormBorderStyle = FormBorderStyle.None;
                this.StartPosition   = FormStartPosition.Manual;
                //We intentionally set the bounds after showing the form.
                //This bypasses a bug in the Form class when setting the
                //bounds internally before calling the Show() method.
                this.Show();
                setBounds();

                //Paint the bounds as a rounded rectangle...
                System.Drawing.Graphics g = this.CreateGraphics();
                g.SmoothingMode = SmoothingMode.AntiAlias;
                GraphicsPath gpArea = this.BuildRoundedRectangle(new Rectangle(shadow, shadow, this.Width - shadow, this.Height - shadow), 20);

                using (SolidBrush sb = new SolidBrush(Color.FromArgb(150, Color.Black)))
                { g.FillPath(sb, gpArea); }
                g.TranslateTransform(-shadow, -shadow);
                g.FillPath(Brushes.WhiteSmoke, gpArea);
                g.DrawPath(Pens.Black, gpArea);
                g.Dispose();
                gpArea.Dispose();
            }
Exemple #14
0
        public override bool GdiDrawString(
            System.Drawing.Graphics pGraphics,
            LOGFONT pLogFont,
            string pszText,
            System.Drawing.Rectangle rtDraw)
        {
            int nOffset = Math.Abs(m_nOffsetX);

            if (Math.Abs(m_nOffsetX) == Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetX);
            }
            else if (Math.Abs(m_nOffsetX) > Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetY);
            }
            else if (Math.Abs(m_nOffsetX) < Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetX);
            }

            for (int i = 0; i < nOffset; ++i)
            {
                using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding))
                {
                    bool b = GDIPath.GetStringPath(
                        pGraphics,
                        pPath,
                        pszText,
                        pLogFont,
                        new Rectangle(rtDraw.X + ((i * (-m_nOffsetX)) / nOffset), rtDraw.Y + ((i * (-m_nOffsetY)) / nOffset),
                                      rtDraw.Width, rtDraw.Height));

                    if (false == b)
                    {
                        return(false);
                    }

                    using (Pen pen = new Pen(m_clrOutline, m_nThickness))
                    {
                        pen.LineJoin = LineJoin.Round;
                        pGraphics.DrawPath(pen, pPath);
                    }

                    if (m_bClrText)
                    {
                        using (SolidBrush brush = new SolidBrush(m_clrText))
                        {
                            pGraphics.FillPath(brush, pPath);
                        }
                    }
                    else
                    {
                        pGraphics.FillPath(m_brushText, pPath);
                    }
                }
            }
            return(true);
        }
Exemple #15
0
        public override bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Rectangle rtDraw,
            System.Drawing.StringFormat strFormat)
        {
            int nOffset = Math.Abs(m_nOffsetX);

            if (Math.Abs(m_nOffsetX) == Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetX);
            }
            else if (Math.Abs(m_nOffsetX) > Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetY);
            }
            else if (Math.Abs(m_nOffsetX) < Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetX);
            }

            for (int i = 0; i < nOffset; ++i)
            {
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddString(strText, fontFamily, (int)fontStyle, fontSize,
                                   new Rectangle(rtDraw.X + ((i * (-m_nOffsetX)) / nOffset), rtDraw.Y + ((i * (-m_nOffsetY)) / nOffset),
                                                 rtDraw.Width, rtDraw.Height),
                                   strFormat);

                    using (Pen pen = new Pen(m_clrOutline, m_nThickness))
                    {
                        pen.LineJoin = LineJoin.Round;
                        graphics.DrawPath(pen, path);
                    }

                    if (m_bClrText)
                    {
                        using (SolidBrush brush = new SolidBrush(m_clrText))
                        {
                            graphics.FillPath(brush, path);
                        }
                    }
                    else
                    {
                        graphics.FillPath(m_brushText, path);
                    }
                }
            }

            return(true);
        }
        public override bool GdiDrawString(
            System.Drawing.Graphics pGraphics,
            LOGFONT pLogFont,
            string pszText,
            System.Drawing.Rectangle rtDraw)
        {
            using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding))
            {
                bool b = GDIPath.GetStringPath(
                    pGraphics,
                    pPath,
                    pszText,
                    pLogFont,
                    rtDraw);

                if (false == b)
                {
                    return(false);
                }

                List <Color> list = new List <Color>();
                if (m_GradientType == GradientType.Sinusoid)
                {
                    CalculateCurvedGradient(m_clrOutline1, m_clrOutline2, m_nThickness, list);
                }
                else
                {
                    CalculateGradient(m_clrOutline1, m_clrOutline2, m_nThickness, list);
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        pGraphics.FillPath(brush, pPath);
                    }
                }
                else
                {
                    pGraphics.FillPath(m_brushText, pPath);
                }

                for (int i = m_nThickness; i >= 1; --i)
                {
                    System.Drawing.Color clr = list[i - 1];
                    using (Pen pen = new Pen(clr, i))
                    {
                        pen.LineJoin = LineJoin.Round;
                        pGraphics.DrawPath(pen, pPath);
                    }
                }
            }
            return(true);
        }
Exemple #17
0
        protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel)
        {
            base.Render(canvas, graphics, channel);

            if (channel == GH_CanvasChannel.Objects)
            {
                Pen spacer = new Pen(ButtonColours.SpacerColour);

                Font font = GH_FontServer.Standard;
                // adjust fontsize to high resolution displays
                font = new Font(font.FontFamily, font.Size / GH_GraphicsUtil.UiScale, FontStyle.Regular);

                Font sml = GH_FontServer.Small;
                // adjust fontsize to high resolution displays
                sml = new Font(sml.FontFamily, sml.Size / GH_GraphicsUtil.UiScale, FontStyle.Regular);

                //Draw divider line
                if (SpacerTxt != "")
                {
                    graphics.DrawString(SpacerTxt, sml, ButtonColours.AnnotationTextDark, SpacerBounds, GH_TextRenderingConstants.CenterCenter);
                    graphics.DrawLine(spacer, SpacerBounds.X, SpacerBounds.Y + SpacerBounds.Height / 2, SpacerBounds.X + (SpacerBounds.Width - GH_FontServer.StringWidth(SpacerTxt, sml)) / 2 - 4, SpacerBounds.Y + SpacerBounds.Height / 2);
                    graphics.DrawLine(spacer, SpacerBounds.X + (SpacerBounds.Width - GH_FontServer.StringWidth(SpacerTxt, sml)) / 2 + GH_FontServer.StringWidth(SpacerTxt, sml) + 4, SpacerBounds.Y + SpacerBounds.Height / 2, SpacerBounds.X + SpacerBounds.Width, SpacerBounds.Y + SpacerBounds.Height / 2);
                }

                // Draw button box
                System.Drawing.Drawing2D.GraphicsPath button = RoundedRect(ButtonBounds, 2);

                Brush normal_colour  = ButtonColours.ButtonColor;
                Brush hover_colour   = ButtonColours.HoverButtonColour;
                Brush clicked_colour = ButtonColours.ClickedButtonColour;

                Brush butCol = (mouseOver) ? hover_colour : normal_colour;
                graphics.FillPath(mouseDown ? clicked_colour : butCol, button);

                // draw button edge
                Color edgeColor = ButtonColours.BorderColour;
                Color edgeHover = ButtonColours.HoverBorderColour;
                Color edgeClick = ButtonColours.ClickedBorderColour;
                Color edgeCol   = (mouseOver) ? edgeHover : edgeColor;
                Pen   pen       = new Pen(mouseDown ? edgeClick : edgeCol)
                {
                    Width = (mouseDown) ? 0.8f : 0.5f
                };
                graphics.DrawPath(pen, button);

                System.Drawing.Drawing2D.GraphicsPath overlay = RoundedRect(ButtonBounds, 2, true);
                graphics.FillPath(new SolidBrush(Color.FromArgb(mouseDown ? 0 : mouseOver ? 40 : 60, 255, 255, 255)), overlay);

                // draw button text
                graphics.DrawString(buttonText, font, ButtonColours.AnnotationTextBright, ButtonBounds, GH_TextRenderingConstants.CenterCenter);
            }
        }
Exemple #18
0
        /// <summary>
        /// 绘制符号
        /// </summary>
        /// <param name="g">作图对象</param>
        /// <param name="X">水平坐标</param>
        /// <param name="Y">垂直坐标</param>
        public void Draw(System.Drawing.Graphics g, float X, float Y)
        {
            ///绘制图片
            if (_symboltype == MedSymbolType.Image)
            {
                if (_image is Bitmap)
                {
                    (_image as Bitmap).MakeTransparent();
                }
                g.DrawImage(_image, new Rectangle((int)(X - _size / 2 - 1), (int)(Y - _size / 2 - 1), (int)_size + 2, (int)_size + 2));
            }
            else if (_symboltype == MedSymbolType.Text)
            {
                if (_text != null)
                {
                    g.DrawString(_text, _font, _pen.Brush, X - g.MeasureString(_text, _font).Width / 2, Y - g.MeasureString(_text, _font).Height / 2);
                }
            }
            ///绘制路径
            else if (_symboltype != MedSymbolType.None)
            {
                Matrix saveMatrix = g.Transform;
                g.TranslateTransform(X, Y);

                ///创建符号路径
                GraphicsPath path = MakePath(g);

                ///填充路径
                if (_brush != null)
                {
                    g.FillPath(_brush, path);
                }

                if (_symboltype == MedSymbolType.Point || _symboltype == MedSymbolType.FillCircle || _symboltype == MedSymbolType.FillMiniCircle)
                {
                    g.FillPath(new SolidBrush(_pen.Color), path);
                }
                else
                {
                    g.DrawPath(_pen, path);
                    if (_symboltype == MedSymbolType.CircleXCrossDot)
                    {
                        g.FillEllipse(Brushes.Black, -1f, 1 - _size / 2, 2f, 2f);
                        g.FillEllipse(Brushes.Black, -1f, _size / 2 - 3, 2f, 2f);
                        g.FillEllipse(Brushes.Black, _size / 2 - 3, -1f, 2f, 2f);
                        g.FillEllipse(Brushes.Black, 1 - _size / 2, -1f, 2f, 2f);
                    }
                }
                g.Transform = saveMatrix;
            }
        }
        public bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Point ptDraw,
            System.Drawing.StringFormat strFormat)
        {
            GraphicsPath path = new GraphicsPath();

            path.AddString(strText, fontFamily, (int)fontStyle, fontSize, ptDraw, strFormat);

            for (int i = 1; i <= m_nThickness; ++i)
            {
                Pen pen = new Pen(m_clrOutline, i);
                pen.LineJoin = LineJoin.Round;
                graphics.DrawPath(pen, path);
            }

            if (m_bOutlinetext == false)
            {
                for (int i = 1; i <= m_nThickness; ++i)
                {
                    if (m_bClrText)
                    {
                        SolidBrush brush = new SolidBrush(m_clrText);
                        graphics.FillPath(brush, path);
                    }
                    else
                    {
                        graphics.FillPath(m_brushText, path);
                    }
                }
            }
            else
            {
                if (m_bClrText)
                {
                    SolidBrush brush = new SolidBrush(m_clrText);
                    graphics.FillPath(brush, path);
                }
                else
                {
                    graphics.FillPath(m_brushText, path);
                }
            }

            return(true);
        }
Exemple #20
0
        public bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Point ptDraw,
            System.Drawing.StringFormat strFormat)
        {
            int nOffset = Math.Abs(m_nOffsetX);

            if (Math.Abs(m_nOffsetX) == Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetX);
            }
            else if (Math.Abs(m_nOffsetX) > Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetY);
            }
            else if (Math.Abs(m_nOffsetX) < Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetX);
            }

            for (int i = 0; i < nOffset; ++i)
            {
                GraphicsPath path = new GraphicsPath();
                path.AddString(strText, fontFamily, (int)fontStyle, fontSize,
                               new Point(ptDraw.X + ((i * (-m_nOffsetX)) / nOffset), ptDraw.Y + ((i * (-m_nOffsetY)) / nOffset)),
                               strFormat);

                Pen pen = new Pen(m_clrOutline, m_nThickness);
                pen.LineJoin = LineJoin.Round;
                graphics.DrawPath(pen, path);

                if (m_bClrText)
                {
                    SolidBrush brush = new SolidBrush(m_clrText);
                    graphics.FillPath(brush, path);
                }
                else
                {
                    graphics.FillPath(m_brushText, path);
                }
            }

            return(true);
        }
Exemple #21
0
        public override bool GdiDrawString(
            System.Drawing.Graphics pGraphics,
            LOGFONT pLogFont,
            string pszText,
            System.Drawing.Rectangle rtDraw)
        {
            using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding))
            {
                bool b = GDIPath.GetStringPath(
                    pGraphics,
                    pPath,
                    pszText,
                    pLogFont,
                    rtDraw);

                if (false == b)
                {
                    return(false);
                }

                for (int i = m_nThickness1; i <= m_nThickness1 + m_nThickness2; ++i)
                {
                    using (Pen pen = new Pen(m_clrOutline2, i))
                    {
                        pen.LineJoin = LineJoin.Round;
                        pGraphics.DrawPath(pen, pPath);
                    }
                }

                using (Pen pen1 = new Pen(m_clrOutline1, m_nThickness1))
                {
                    pen1.LineJoin = LineJoin.Round;
                    pGraphics.DrawPath(pen1, pPath);
                }
                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        pGraphics.FillPath(brush, pPath);
                    }
                }
                else
                {
                    pGraphics.FillPath(m_brushText, pPath);
                }
            }
            return(true);
        }
        public override void DrawYourSelf(Graphics graphics)
        {
            GraphicsPath path = new GraphicsPath();
            path.StartFigure();
            path.AddLine(Location.X, Location.Y + ModelSize.Height / 3, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 3);
            path.CloseFigure();
            path.StartFigure();
            path.AddLine(Location.X, Location.Y + (ModelSize.Height / 3) * 2, Location.X + ModelSize.Width, Location.Y + (ModelSize.Height * 2) / 3);
            path.CloseFigure();
            path.AddEllipse(new RectangleF(Location, ModelSize));
            path.CloseFigure();
            path.Transform(this.TMatrix.TransformationMatrix);

            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }
            graphics.DrawPath(pen, path);
            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
        public void DrawRoundRect(Graphics g, Pen p, float X, float Y, float width, float height, float radius)
        {
            Y+=5;
            X+=5;
            width -= 12;
            height -= 12;
            GraphicsPath gp = new GraphicsPath();
            gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);
            gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);
            gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));
            gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
            gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);
            gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
            gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);
            gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);
            gp.CloseFigure();
            g.FillPath(Brushes.Transparent, gp);
            gp.Dispose();

            gp = new GraphicsPath();
            gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);
            gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);
            gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));
            gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
            gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);
            gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
            gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);
            gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);
            gp.CloseFigure();
            g.DrawPath(p, gp);
            gp.Dispose();
        }
 private void DrawButton(Graphics graphics, ScrollButton scrollButton)
 {
     Rectangle buttonBounds = base.GetButtonBounds(scrollButton);
     if (base.Orientation == Orientation.Horizontal)
     {
         buttonBounds.Inflate(-base.itemStrip.ItemSize.Width / 6, -base.itemStrip.ItemSize.Height / 4);
     }
     else
     {
         buttonBounds.Inflate(-base.itemStrip.ItemSize.Width / 4, -base.itemStrip.ItemSize.Height / 6);
     }
     if (base.ActiveButton == scrollButton)
     {
         buttonBounds.Offset(1, 1);
         Size size = (base.Orientation == Orientation.Horizontal) ? new Size(0, 2) : new Size(2, 0);
         buttonBounds.Inflate(size.Width, size.Height);
         graphics.FillRectangle(SelectionBrush, buttonBounds);
         graphics.DrawRectangle(Pens.Black, buttonBounds);
         buttonBounds.Inflate(-size.Width, -size.Height);
     }
     using (GraphicsPath path = ActivityDesignerPaint.GetScrollIndicatorPath(buttonBounds, scrollButton))
     {
         graphics.FillPath(Brushes.Black, path);
         graphics.DrawPath(Pens.Black, path);
     }
 }
Exemple #25
0
        public static void DrawPolygon(System.Drawing.Graphics g, SqlGeometry geometry, ViewContext context, System.Drawing.Brush brush, System.Drawing.Pen pen)
        {
            if (geometry.STExteriorRing() == null)
            {
                return;
            }

            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

            System.Drawing.PointF[] exterior = new System.Drawing.PointF[(int)geometry.STExteriorRing().STNumPoints()];
            for (int i = 1; i <= (int)geometry.STExteriorRing().STNumPoints(); i++)
            {
                exterior[i - 1] = WorldtoMap((double)geometry.STExteriorRing().STPointN(i).STX, (double)geometry.STExteriorRing().STPointN(i).STY, context);
            }
            gp.AddPolygon(exterior);

            //TODO: Add interior rings

            if (brush != null && brush != System.Drawing.Brushes.Transparent)
            {
                g.FillPath(brush, gp);
            }

            if (pen != null)
            {
                g.DrawPath(pen, gp);
            }
        }
Exemple #26
0
    void DrawNext()
    {
        if (!ImagesLoaded)
        {
            return;
        }

        while (this.numChildren > 0)
        {
            removeChildAt(0);
        }

        graphics.clear();

        int index = _shapeIndex;

        SetTitle(Shapes.Names[index]);

        _shapeIndex++;
        if (_shapeIndex >= Shapes.ShapeCount)
        {
            _shapeIndex = 0;
        }

        var shape = Shapes.GetShape(index);

        if (shape != null)
        {
            var g = new Graphics(this);
            g.FillPath(Brushes.Red, shape);
            g.DrawPath(Pens.Black, shape);
        }

        stage.invalidate();
    }
Exemple #27
0
        public void render(System.Drawing.Graphics g, string text, System.Drawing.Rectangle rect)
        {
            //string text = string.Format("SCORE: {0}", _scoreValue);
            var gp = new System.Drawing.Drawing2D.GraphicsPath();


            System.Drawing.FontFamily family = font;

            if (family == null)
            {
                family = System.Drawing.SystemFonts.DefaultFont.FontFamily;//
            }


            int fontStyle = (int)System.Drawing.FontStyle.Bold;

            gp.AddString(text, family, fontStyle, fontSize, rect, _strFmt);


            if (borderWidth > 0)
            {
                g.DrawPath(new Pen(borderColor, borderWidth), gp);
            }


            var brush = createBrush();

            g.FillPath(brush, gp);
        }
Exemple #28
0
        /// <summary>
        /// 绘制符号
        /// </summary>
        /// <param name="g">作图对象</param>
        /// <param name="X">水平坐标</param>
        /// <param name="Y">垂直坐标</param>
        public void Draw(System.Drawing.Graphics g, float X, float Y)
        {
            ///绘制图片
            if (_symboltype == MedSymbolType.Image)
            {
                g.DrawImage(_image, X - _image.Width / 2, Y - _image.Height / 2);
            }
            ///绘制路径
            else if (_symboltype != MedSymbolType.None)
            {
                Matrix saveMatrix = g.Transform;
                g.TranslateTransform(X, Y);

                ///创建符号路径
                GraphicsPath path = MakePath(g);

                ///填充路径
                if (_brush != null)
                {
                    g.FillPath(_brush, path);
                }

                g.DrawPath(_pen, path);
                g.Transform = saveMatrix;
            }
        }
 protected override void DrawTabCloser(int index, System.Drawing.Graphics graphics)
 {
     if (this._ShowTabCloser)
     {
         Rectangle closerRect = this._TabControl.GetTabCloserRect(index);
         graphics.SmoothingMode = SmoothingMode.AntiAlias;
         if (closerRect.Contains(this._TabControl.MousePosition))
         {
             using (GraphicsPath closerPath = GetCloserButtonPath(closerRect)){
                 graphics.FillPath(Brushes.White, closerPath);
                 using (Pen closerPen = new Pen(this.BorderColor)){
                     graphics.DrawPath(closerPen, closerPath);
                 }
             }
             using (GraphicsPath closerPath = GetCloserPath(closerRect)){
                 using (Pen closerPen = new Pen(this._CloserColorActive)){
                     closerPen.Width = 2;
                     graphics.DrawPath(closerPen, closerPath);
                 }
             }
         }
         else
         {
             using (GraphicsPath closerPath = GetCloserPath(closerRect)){
                 using (Pen closerPen = new Pen(this._CloserColor)){
                     closerPen.Width = 2;
                     graphics.DrawPath(closerPen, closerPath);
                 }
             }
         }
     }
 }
Exemple #30
0
        /// <summary>
        /// 绘制圆角
        /// </summary>
        /// <param name="g"></param>
        /// <param name="p"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="radius"></param>
        public static void DrawRoundRect(Graphics g, Pen p, Brush brush,float X, float Y, float width, float height, float radius)
        {
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

            gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);

            gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);

            gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));

            gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);

            gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);

            gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);

            gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);

            gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);

            gp.CloseFigure();

            g.DrawPath(p, gp);

            g.FillPath(brush, gp);

            gp.Dispose();
        }
Exemple #31
0
        public static void DrawGlass(Rectangle rectangle, Graphics graphics)
        {
            if (rectangle.Width == 0 || rectangle.Height == 0)
                return;

            var clipPath = GetRoundedRectanglePath(rectangle);

            graphics.SetClip(clipPath);

            var glassRectangle = new Rectangle(rectangle.Location, new Size(rectangle.Width, rectangle.Height/2));

            // Apply a glass look
            Brush glassBrush = new LinearGradientBrush(glassRectangle, Color.Transparent,
                                                       Color.FromArgb(32, 255, 255, 255), 90.0f);

            var glassPath = GetRoundedRectanglePath(glassRectangle);

            graphics.FillPath(glassBrush, glassPath);

            glassPath.Dispose();
            glassBrush.Dispose();

            glassRectangle = new Rectangle(0, rectangle.Height - (rectangle.Height/4), rectangle.Width,
                                           rectangle.Height*3);
            glassPath = GetRoundedRectanglePath(glassRectangle);
            glassBrush = new SolidBrush(Color.FromArgb(16, Color.White));

            glassBrush.Dispose();
            glassPath.Dispose();

            graphics.SetClip(rectangle);
            clipPath.Dispose();
        }
        public override void DrawTab(Graphics gr, Rectangle borderrect, int index, bool selected, Color color1, Color color2, Color coloroutline, TabAlignment alignment)
        {
            GraphicsPath border = new GraphicsPath();
            GraphicsPath fill = new GraphicsPath();

            int xfar = borderrect.Right - 1;

            int ybot = (alignment == TabAlignment.Bottom) ? (borderrect.Y) : (borderrect.Bottom - 1);
            int ytop = (alignment == TabAlignment.Bottom) ? (borderrect.Bottom-1-((selected)?0:2)) : (borderrect.Y - ((selected) ? 2 : 0));

            border.AddLine(borderrect.X, ybot, borderrect.X + shift, ytop);
            border.AddLine(borderrect.X + shift, ytop, xfar, ytop);
            border.AddLine(xfar, ytop, xfar + shift, ybot);

            fill.AddLine(borderrect.X, ybot + 1, borderrect.X + shift, ytop);
            fill.AddLine(borderrect.X + shift, ytop, xfar, ytop);
            fill.AddLine(xfar, ytop, xfar + shift, ybot + 1);

            gr.SmoothingMode = SmoothingMode.Default;

            using (Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(borderrect, color1, color2, 90))
                gr.FillPath(b, fill);

            gr.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen p = new Pen(coloroutline, 1.0F))
                gr.DrawPath(p, border);
        }
 public virtual void Draw(Graphics g)
 {
     GraphicsPath usepath = new GraphicsPath();
     usepath.AddString(usecharacter.ToString(), useFont.FontFamily, (int)useFont.Style, useFont.Size, currentposition,StringFormat.GenericDefault);
     g.FillPath(fillbrush, usepath);
     g.DrawPath(strokepen, usepath);
 }
Exemple #34
0
 private void paint(Graphics g, GraphicsPath path, bool edge, Color edgeColour, int edgeWidth, bool fill, Color fillColour)
 {
     if (edge)
         g.DrawPath(new Pen(edgeColour, edgeWidth), path);
     if (fill)
         g.FillPath(new SolidBrush(fillColour), path);
 }
Exemple #35
0
        public void DrawPointer(System.Drawing.Graphics Graphics)
        {
            Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            GraphicsPath path = new GraphicsPath();
            int          a    = 0;

            if (this.LinearGauge.MinimumValue < 0)
            {
                a = (int)Math.Ceiling((((Math.Abs(this.LinearGauge.MinimumValue) + LinearGauge.Value) / (float)LinearGauge.MajorDifference) * m_minorTicksPixels));
            }
            else
            {
                a = (int)Math.Ceiling((Math.Abs(LinearGauge.Value - this.LinearGauge.MinimumValue) / (float)LinearGauge.MajorDifference) * m_minorTicksPixels);
            }
            int   y = (this.LinearGauge.Height / 2 + LinearGauge.MajorTicksHeight) - LinearGauge.MajorTicksHeight;
            Point pt1, pt2, pt3, pt4, pt5;

            a = a - 35;

            pt1 = new Point(10 + a, y - 30);
            pt2 = new Point(60 + a, y - 30);
            pt3 = new Point(60 + a, y);
            pt4 = new Point(55 + a, y - 8);
            pt5 = new Point(10 + a, y - 8);
            path.AddPolygon(new Point[] { pt1, pt2, pt3, pt4, pt5 });
            Graphics.FillPath((new SolidBrush(ColorTranslator.FromHtml("#ff8860"))), path);
            RectangleF rct   = new RectangleF(a + 12F, y - 30F, 50F, 22F);
            SizeF      strng = Graphics.MeasureString(this.LinearGauge.Value.ToString(), this.LinearGauge.GaugelabelFont);
            PointF     pt    = new PointF(rct.X + rct.Width / 2 - strng.Width / 2, rct.Y + rct.Height / 2 - strng.Height / 2);

            Graphics.DrawString(this.LinearGauge.Value.ToString(), this.LinearGauge.GaugelabelFont, new SolidBrush(Color.White), pt);
        }
Exemple #36
0
        public override void RenderObject(Graphics g, DrawContext dcxt)
        {
            GraphicsPath path = new GraphicsPath();
            foreach (Object ch in pathes)
            {
                if (ch is VectorPathLine)
                {
                    VectorPathLine vpl = (VectorPathLine)ch;
                    path.AddLine(dcxt.X_V2S(vpl.x1), dcxt.Y_V2S(vpl.y1), dcxt.X_V2S(vpl.x2), dcxt.Y_V2S(vpl.y2));
                }
                else if (ch is VectorPathArc)
                {
                    VectorPathArc vpa = (VectorPathArc)ch;
                    path.AddArc(dcxt.X_V2S(vpa.x - vpa.w / 2), dcxt.Y_V2S(vpa.y - vpa.h/2), dcxt.W_V2S(vpa.w), dcxt.H_V2S(vpa.h), vpa.startagl, vpa.sweepagl);
                }
                else if (ch is VectorPathPie)
                {
                    VectorPathPie vpp = (VectorPathPie)ch;
                    path.AddArc(dcxt.X_V2S(vpp.x - vpp.w / 2), dcxt.Y_V2S(vpp.y - vpp.h/2), dcxt.W_V2S(vpp.w), dcxt.H_V2S(vpp.h), vpp.startagl, vpp.sweepagl);
                }
            }

            if (fill)
                g.FillPath(BrushWhenCxt(dcxt).Brush, path);
            else
                g.DrawPath(PenWhenCxt(dcxt).Pen, path);
        }
Exemple #37
0
        public override void Draw(Graphics g)
        {
            System.Drawing.Size st = g.MeasureString(Marker.ToolTipText, Font).ToSize();
             System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Marker.ToolTipPosition.X, Marker.ToolTipPosition.Y - st.Height, st.Width + TextPadding.Width, st.Height + TextPadding.Height);
             rect.Offset(Offset.X, Offset.Y);

             using(GraphicsPath objGP = new GraphicsPath())
             {
            objGP.AddLine(rect.X + 2 * Radius, rect.Y + rect.Height, rect.X + Radius, rect.Y + rect.Height + Radius);
            objGP.AddLine(rect.X + Radius, rect.Y + rect.Height + Radius, rect.X + Radius, rect.Y + rect.Height);

            objGP.AddArc(rect.X, rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 90, 90);
            objGP.AddLine(rect.X, rect.Y + rect.Height - (Radius * 2), rect.X, rect.Y + Radius);
            objGP.AddArc(rect.X, rect.Y, Radius * 2, Radius * 2, 180, 90);
            objGP.AddLine(rect.X + Radius, rect.Y, rect.X + rect.Width - (Radius * 2), rect.Y);
            objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y, Radius * 2, Radius * 2, 270, 90);
            objGP.AddLine(rect.X + rect.Width, rect.Y + Radius, rect.X + rect.Width, rect.Y + rect.Height - (Radius * 2));
            objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 0, 90); // Corner

            objGP.CloseFigure();

            g.FillPath(Fill, objGP);
            g.DrawPath(Stroke, objGP);
             }

            #if !PocketPC
             g.DrawString(Marker.ToolTipText, Font, Brushes.Navy, rect, Format);
            #else
             g.DrawString(ToolTipText, ToolTipFont, TooltipForeground, rect, ToolTipFormat);
            #endif
        }
Exemple #38
0
        public override void DrawTab(Graphics gr, Rectangle borderrect, int index, bool selected, Color color1, Color color2, Color coloroutline)
        {
            int additional = 0;                             // extra depth for fill

            if (selected)
            {
                additional = 1;
                borderrect.Height += borderrect.Y;          // this one uses any height to get it bigger
                borderrect.Y = 0;
            }

            int xfar = borderrect.Right - 1;
            int yfar = borderrect.Bottom - 1;

            GraphicsPath border = new GraphicsPath();
            border.AddLine(borderrect.X, yfar + additional, borderrect.X + shift, borderrect.Y);
            border.AddLine(borderrect.X + shift, borderrect.Y, xfar, borderrect.Y);
            border.AddLine(xfar, borderrect.Y, xfar + shift, yfar + additional);

            GraphicsPath fill = new GraphicsPath();
            fill.AddLine(borderrect.X, yfar + additional + 1, borderrect.X + shift, borderrect.Y);
            fill.AddLine(borderrect.X + shift, borderrect.Y, xfar, borderrect.Y);
            fill.AddLine(xfar, borderrect.Y, xfar + shift, yfar + additional + 1);

            gr.SmoothingMode = SmoothingMode.Default;

            using (Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(borderrect, color1, color2, 90))
                gr.FillPath(b, fill);

            gr.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen p = new Pen(coloroutline, 1.0F))
                gr.DrawPath(p, border);
        }
Exemple #39
0
 public override void Paint(ProcessOverlay processOverlay, Graphics graphics, Rectangle bounds)
 {
     var font = processOverlay.Font;
     var oldMode = graphics.SmoothingMode;
     graphics.SmoothingMode = SmoothingMode.HighQuality;
     const int spacing = 10;
     using(var path = GraphicsUtility.GetRoundedRectangle(bounds, processOverlay.Rounding))
     {
         using(var brush = new SolidBrush(BackgroundColor))
         {
             graphics.FillPath(brush, path);
         }
         using(var pen = new Pen(BorderColor, 2.0f))
         {
             graphics.DrawPath(pen, path);
         }
     }
     var tw = GitterApplication.TextRenderer.MeasureText(
         graphics, processOverlay.Title, font, bounds.Width, TitleStringFormat).Width;
     DrawIndeterminateProgress(graphics, bounds.X + (bounds.Width - tw) / 2 - 14 - 5, bounds.Y + (bounds.Height - 14) / 2, 14, 14);
     var titleRect = new Rectangle(bounds.X + (bounds.Width - tw) / 2, bounds.Y, bounds.Width - spacing * 2 - 5 - 14, bounds.Height);
     graphics.SmoothingMode = oldMode;
     if(!string.IsNullOrWhiteSpace(processOverlay.Title))
     {
         GitterApplication.TextRenderer.DrawText(
             graphics, processOverlay.Title, font, FontBrush, titleRect, TitleStringFormat);
     }
     if(!string.IsNullOrWhiteSpace(processOverlay.Message))
     {
         GitterApplication.TextRenderer.DrawText(
             graphics, processOverlay.Message, font, FontBrush, bounds, StringFormat);
     }
 }
Exemple #40
0
        static void RenderTo(this GeometryDrawing drawing, d.Graphics graphics, double opacity)
        {
            if (drawing.Geometry == null || drawing.Geometry.IsEmpty())
            {
                return;
            }
            var path  = drawing.Geometry.ToGdiPlus();
            var brush = drawing.Brush;

            if (brush != null)
            {
                if (!Utility.IsZero(opacity - 1))
                {
                    brush          = brush.Clone();
                    brush.Opacity *= opacity;
                }
                graphics.FillPath(brush.ToGdiPlus(drawing.Geometry.Bounds), path);
            }
            var pen = drawing.Pen;

            if (pen != null)
            {
                if (!Utility.IsZero(opacity - 1))
                {
                    pen = pen.Clone();
                    pen.Brush.Opacity *= opacity;
                }
                graphics.DrawPath(pen.ToGdiPlus(drawing.Geometry.GetRenderBounds(pen)), path);
            }
        }
        public override void AnimalionDraw(System.Drawing.Graphics graphics, DetailDataModel data, System.Drawing.Pen pen, System.Drawing.Brush brush, System.Drawing.Font font, object[] args)
        {
            drawFrame(graphics, pen, brush, font);
            if (TextAndData != null)
            {
                Point  p0;
                Point  p1;
                Point  p2;
                Point  p3;
                string str = Index / MaxIndex * 100 + "%";
                if (Index / MaxIndex >= ((int.Parse(TextAndData[1]) * 1.0f) / MaxNum))
                {
                    //Index = int.Parse(TextAndData[1]);
                    str = (int)((int.Parse(TextAndData[1]) * 1.0f) / MaxNum * 100) + "%";
                    //完成任务
                    if (int.Parse(TextAndData[1]) >= MaxNum)
                    {
                        str = "任务完成!";
                        isAutoUpdateData = false;
                    }
                    LocationPointer((int.Parse(TextAndData[1]) * 1.0f) / MaxNum, out p0, out p1, out p2, out p3);
                }
                else
                {
                    LocationPointer(Index / MaxIndex, out p0, out p1, out p2, out p3);
                }
                ReportViewUtils.drawString(graphics, LocationModel.Location_Up_Up, str, font, brush, EStartX, EStartY + EViewHeight - 2 * TextSize, EViewWidth, EViewHeight / 2);

                GraphicsPath path = GraphicalDesignUtils.CreatePath(p0, p1, p2, p3);
                graphics.FillPath(brush, path);
                path.Dispose();
            }
        }
        public static void DrawOuterGlow(Graphics gps, GraphicsPath gp, Rectangle rect, float size,
            Color lightColor,
            Color bodyColor)
        {
            Bitmap bm = new Bitmap(rect.Width / 5, rect.Height / 5);
            Graphics g = Graphics.FromImage(bm);
            Matrix mx = new Matrix(
                1.0f / 5,
                0,
                0,
                1.0f / 5,
                -(1.0f / 5),
                -(1.0f / 5));
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.Transform = mx;
            Pen p = new Pen(lightColor, size);
            g.DrawPath(p, gp);
            //g.FillPath(new SolidBrush(lightColor), gp);
            g.Dispose();
            gps.Transform = new Matrix();

            gps.SmoothingMode = SmoothingMode.AntiAlias;
            gps.InterpolationMode = InterpolationMode.HighQualityBicubic;
            gps.DrawImage(bm, rect, 0, 0, bm.Width, bm.Height, GraphicsUnit.Pixel);
            gps.FillPath(new SolidBrush(bodyColor), gp);
        }
 protected override void DrawTabCloser(int index, System.Drawing.Graphics graphics)
 {
     if (this._ShowTabCloser)
     {
         Rectangle closerRect = this._TabControl.GetTabCloserRect(index);
         graphics.SmoothingMode = SmoothingMode.AntiAlias;
         if (closerRect.Contains(this._TabControl.MousePosition))
         {
             using (GraphicsPath closerPath = GetCloserButtonPath(closerRect)){
                 using (SolidBrush closerBrush = new SolidBrush(Color.FromArgb(193, 53, 53))){
                     graphics.FillPath(closerBrush, closerPath);
                 }
             }
             using (GraphicsPath closerPath = GetCloserPath(closerRect)){
                 using (Pen closerPen = new Pen(this._CloserColorActive)){
                     graphics.DrawPath(closerPen, closerPath);
                 }
             }
         }
         else
         {
             using (GraphicsPath closerPath = GetCloserPath(closerRect)){
                 using (Pen closerPen = new Pen(this._CloserColor)){
                     graphics.DrawPath(closerPen, closerPath);
                 }
             }
         }
     }
 }
Exemple #44
0
        public override void Paint(System.Drawing.Graphics g)
        {
            //base.Paint(g);
            GraphicsPath gp  = new GraphicsPath();
            PointF       pf1 = new PointF(Rectangle.Left + Width / 2, Rectangle.Top);
            PointF       pf2 = new PointF(Rectangle.Left, Rectangle.Bottom);
            PointF       pf3 = new PointF(Rectangle.Right, Rectangle.Bottom);

            PointF[] pfs = new PointF[] { pf1, pf2, pf3 };
            GetTransForm().TransformPoints(pfs);
            gp.AddLines(pfs);
            g.FillPath(new SolidBrush(ShapeColor), gp);

            //显示线路名
            if (ShowLabel)
            {
                Matrix m   = new Matrix();
                int    mod = (int)Angle % 360;
                PointF pf5 = new PointF(Rectangle.Right + 3, Rectangle.Top + Rectangle.Height / 2);
                if (mod == 0 || mod == 180)
                {
                    pf5 = new PointF(Rectangle.Right + 12, Rectangle.Bottom);
                    m.RotateAt(90, pf5);
                }
                GraphicsContainer gc = g.BeginContainer();
                g.Transform = m;
                g.DrawString(this.Text, this.Font, this.TextBrush, pf5);
                g.EndContainer(gc);
            }
        }
Exemple #45
0
        /// <summary>
        /// 设置选项卡头部颜色
        /// </summary>
        /// <param name="graph">The graph.</param>
        /// <param name="index">The index.</param>
        /// <param name="path">The path.</param>
        private void PaintTabBackground(System.Drawing.Graphics graph, int index, System.Drawing.Drawing2D.GraphicsPath path)
        {
            Rectangle rect = this.GetTabRect(index);

            if (rect.Width == 0 || rect.Height == 0)
            {
                return;
            }
            System.Drawing.Brush buttonBrush = new System.Drawing.Drawing2D.LinearGradientBrush(rect, _headerBackColor, _headerBackColor, LinearGradientMode.Vertical);  //非选中时候的 TabPage 页头部背景色
            //graph.FillPath(buttonBrush, path);
            //if (index == this.SelectedIndex)
            //{
            //    buttonBrush = new System.Drawing.SolidBrush(_headSelectedBackColor);
            //    graph.DrawLine(new Pen(_headerBackColor), rect.Right + 2, rect.Bottom, rect.Left + 1, rect.Bottom);
            //}
            buttonBrush.Dispose();
            if (index == this.SelectedIndex)
            {
                using (SolidBrush brush = new SolidBrush(_headSelectedBackColor))
                {
                    // rect.Inflate(1, 1);
                    //graph.FillRectangle(brush, rect);
                    graph.FillPath(brush, path);
                    graph.SmoothingMode = SmoothingMode.AntiAlias;//抗锯齿
                }
            }
            else
            {
            }
        }
        internal override void Draw(Graphics g)
        {
            IsInvalidated = false;

            Rectangle r = GetUnsignedRectangle();

            //Shadow
            GraphicsPath gp = CreatePath(r.X + 5, r.Y + 5, r.Width, r.Height, Radius);
            //g.FillPath(new SolidBrush(Color.FromArgb((int)(255.0f * (50 / 100.0f)), Color.LightGray)), gp);

            g.FillPath(new SolidBrush(Color.LightGray), gp);

            gp.Dispose();

            //Border
            gp = CreatePath(r.X, r.Y, r.Width, r.Height, Radius);

            Pen p = new Pen(borderColor, borderWidth);
            g.DrawPath(p, gp);            
            p.Dispose();

            //Color
            Brush b = this.GetBrush(r);
            g.FillPath(b, gp);
            gp.Dispose();

            b.Dispose();
        }
Exemple #47
0
 void paintshit(List<double> datta, int numPoints, double mulX, double mulY, int bw, int bh, Graphics g, LinearGradientBrush grad, Color cbase)
 {
     PointF[] points = new PointF[numPoints];
     lock (datta)
     {
         int s = 0;
         int samples = datta.Count;
         for (; s < (points.Length - 2) - samples; s++)
         {
             points[s + 1] = new PointF((float)(s * mulX), bh);
         }
         int ofs = (points.Length - 2) - samples;
         s = Math.Max(0, samples - (points.Length - 2));
         for (; s < samples; s++)
         {
             points[s + ofs + 1] = new PointF((float)((s + ofs) * mulX),
                 (float)(bh - datta[s] * mulY));
         }
         points[0] = new PointF(0f, bh);
         points[points.Length - 1] = new PointF(bw, bh);
     }
     GraphicsPath gp = new GraphicsPath();
     gp.AddLines(points);
     g.FillPath(grad, gp);
     g.DrawPath(new Pen(cbase, 2f), gp);
 }
Exemple #48
0
 /// <summary>
 /// Fills the interior of a rounded rectangle.
 /// </summary>
 /// <param name="graphics">The graphics to draw on.</param>
 /// <param name="brush">The brush to use to fill the rectangle.</param>
 /// <param name="x">The x-coordinate of the upper-left corner of the rectangle to draw.</param>
 /// <param name="y">The y-coordinate of the upper-left corner of the rectangle to draw.</param>
 /// <param name="width">Width of the rectangle to draw.</param>
 /// <param name="height">Height of the rectangle to draw.</param>
 /// <param name="radius">The radius of rounded corners.</param>
 public static void FillRoundedRectangle(System.Drawing.Graphics graphics, Brush brush, int x, int y, int width, int height, int radius)
 {
     using (GraphicsPath path = GetRoundedRectanglePath(x, y, width, height, radius))
     {
         graphics.FillPath(brush, path);
     }
 }
        public override void DrawYourSelf(Graphics graphics)
        {
            int i = 0;
            Point[] points = new Point[this.pointsList.Count];//(Point[])pointsList.ToArray(typeof(Point));
            foreach(Point _point in this.pointsList)
            {
                points[i] = _point;
                i++;
            }

            GraphicsPath path = new GraphicsPath();
            path.AddPolygon(points);
            path.Transform(this.TMatrix.TransformationMatrix);

            Pen pen = new Pen(this.BorderColor, this.BorderWidth);

            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }

            graphics.DrawPath(pen, path);

            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
Exemple #50
0
        /// <summary>
        /// The graphics device and clip rectangle are in the parent coordinates.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="clipRectangle"></param>
        /// <param name="symbol">The symbol to use for drawing.</param>
        public void Draw(Graphics g, Rectangle clipRectangle, ISymbol symbol)
        {
            Color topLeft;
            Color bottomRight;
            if (_isSelected)
            {
                topLeft = _selectionColor.Darker(.3F);
                bottomRight = _selectionColor.Lighter(.3F);
            }
            else
            {
                topLeft = _backColor.Lighter(.3F);
                bottomRight = _backColor.Darker(.3F);
            }
            LinearGradientBrush b = new LinearGradientBrush(_bounds, topLeft, bottomRight, LinearGradientMode.ForwardDiagonal);
            GraphicsPath gp = new GraphicsPath();
            gp.AddRoundedRectangle(Bounds, _roundingRadius);
            g.FillPath(b, gp);
            gp.Dispose();
            b.Dispose();

            Matrix old = g.Transform;
            Matrix shift = g.Transform;
            shift.Translate(_bounds.Left + _bounds.Width / 2, _bounds.Top + _bounds.Height / 2);
            g.Transform = shift;

            if (symbol != null)
            {
                OnDrawSymbol(g, symbol);
            }

            g.Transform = old;
        }
        public static void DrawPolygon(Graphics graphics, Polygon pol, Brush brush, Pen pen, IViewport viewport)
        {
            if (pol.ExteriorRing == null) return;
            if (pol.ExteriorRing.Vertices.Count <= 2) return;

            //Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
            var gp = new GraphicsPath();

            //Add the exterior polygon
            var points = GeometryRenderer.WorldToScreenGDI(pol.ExteriorRing, viewport);
            if (points.Length > 2)
                gp.AddPolygon(points);
            //Add the interior polygons (holes)
            foreach (LinearRing linearRing in pol.InteriorRings)
            {
                var interiorPoints = GeometryRenderer.WorldToScreenGDI(linearRing, viewport);
                if (interiorPoints.Length > 2)
                    gp.AddPolygon(interiorPoints);
            }

            if (gp.PointCount == 0) return;

            // Only render inside of polygon if the brush isn't null or isn't transparent
            if (brush != null && brush != Brushes.Transparent)
                graphics.FillPath(brush, gp);
            // Create an outline if a pen style is available
            if (pen != null)
                graphics.DrawPath(pen, gp);
        }
Exemple #52
0
        public static void DrawRoundedRectangle(Graphics newGraphics, Color boxColor, Color gradFillColor1, Color gradFillColor2, int xPosition, int yPosition,
                   int height, int width, int cornerRadius)
        {
            using (var boxPen = new Pen(boxColor))
            {
                using (var path = new GraphicsPath())
                {
                    path.AddLine(xPosition + cornerRadius, yPosition, xPosition + width - (cornerRadius * 2), yPosition);
                    path.AddArc(xPosition + width - (cornerRadius * 2), yPosition, cornerRadius * 2, cornerRadius * 2, 270, 90);
                    path.AddLine(xPosition + width, yPosition + cornerRadius, xPosition + width,
                                 yPosition + height - (cornerRadius * 2));
                    path.AddArc(xPosition + width - (cornerRadius * 2), yPosition + height - (cornerRadius * 2), cornerRadius * 2,
                                cornerRadius * 2, 0, 90);
                    path.AddLine(xPosition + width - (cornerRadius * 2), yPosition + height, xPosition + cornerRadius,
                                 yPosition + height);
                    path.AddArc(xPosition, yPosition + height - (cornerRadius * 2), cornerRadius * 2, cornerRadius * 2, 90, 90);
                    path.AddLine(xPosition, yPosition + height - (cornerRadius * 2), xPosition, yPosition + cornerRadius);
                    path.AddArc(xPosition, yPosition, cornerRadius * 2, cornerRadius * 2, 180, 90);
                    path.CloseFigure();
                    newGraphics.DrawPath(boxPen, path);

                    var b = new LinearGradientBrush(new Point(xPosition, yPosition),
                                                    new Point(xPosition + width, yPosition + height), gradFillColor1,
                                                    gradFillColor2);

                    newGraphics.FillPath(b, path);
                }
            }
        }
Exemple #53
0
        /// <summary>
        /// Fill a rounded rectangle to a graphics context.
        /// </summary>
        /// <param name="pGraphics">The graphics context</param>
        /// <param name="pBrush">The brush to fill the rectangle with</param>
        /// <param name="r">The bounding rectangle</param>
        /// <param name="border">The outline (border) color</param>
        /// <param name="radius">The corner radius</param>
        public static void FillRoundRect(System.Drawing.Graphics pGraphics, Brush pBrush, Rectangle r, Color border, int radius)
        {
            int dia = 2 * radius;

            // store old page unit
            GraphicsUnit oldPageUnit = pGraphics.PageUnit;

            // set to pixel mode
            pGraphics.PageUnit = GraphicsUnit.Pixel;

            // define the pen
            Pen pen = new Pen(border, 1);

            // set pen alignment
            pen.Alignment = PenAlignment.Center;

            // get the corner path
            GraphicsPath path = GetRoundRectPath(r, dia);

            // fill
            pGraphics.FillPath(pBrush, path);

            // draw the border last so it will be on top in case the color is different
            pGraphics.DrawPath(pen, path);

            // restore page unit
            pGraphics.PageUnit = oldPageUnit;
        }
Exemple #54
0
        public static void DrawFocusedItemMark(System.Drawing.Graphics g, float x, float y, bool drawWhiteBounds = false)
        {
            if (focusedItemMark == null)
            {
                var b = FocusedItemMarkBounds;
                focusedItemMark = new GraphicsPath();
                focusedItemMark.AddPolygon(new []
                {
                    new PointF(0, b.Top),
                    new PointF(b.Width - 1, 0),
                    new PointF(0, b.Bottom),
                });
                focusedItemMarkBorder = new GraphicsPath();
                focusedItemMarkBorder.AddPolygon(new[]
                {
                    new PointF(0, b.Top - 1.5f),
                    new PointF(b.Width, 0),
                    new PointF(0, b.Bottom + 1.5f),
                });
            }

            GraphicsState state = g.Save();

            g.TranslateTransform(x, y);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.FillPath(System.Drawing.Brushes.Blue, focusedItemMark);
            if (drawWhiteBounds)
            {
                g.DrawPath(System.Drawing.Pens.White, focusedItemMarkBorder);
            }
            g.Restore(state);
        }
Exemple #55
0
        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            //base.Paint(g, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            Brush textColor = CellFunctions.DrawPlainBackground(this, this.Enabled, cellBounds, g, this.RowIndex, this.Selected, _parent.GridColor);

            //float y = (cellBounds.Height - textSize.Height) / 2 + cellBounds.Y;
            SizeF textSize = g.MeasureString(this.Value as String, _parent.Font);

            if ((textSize.Width + 13) > cellBounds.Width)
            {
                g.DrawString(this.Value as String, _parent.Font, textColor, new RectangleF(new PointF(cellBounds.X + 3.0f, cellBounds.Y), new SizeF(cellBounds.Width - 13, cellBounds.Height)));
            }
            else
            {
                float y = CellFunctions.TextCenterYInRact(cellBounds, g, _parent.Font);
                g.DrawString(this.Value as String, _parent.Font, textColor, new PointF(cellBounds.X + 3.0f, y));
            }
            float margin     = (cellBounds.Height - 10) / 2;
            float pathTop    = cellBounds.Y + margin; //path의 height를 10으로 한다.
            float PathBottom = cellBounds.Y + cellBounds.Height - margin;

            g.FillPath(Brushes.Gainsboro, new GraphicsPath(
                           new PointF[] {
                new PointF(cellBounds.Right - 10, pathTop),
                new PointF(cellBounds.Right - 10, PathBottom),
                new PointF(cellBounds.Right - 3, (pathTop + PathBottom) / 2)
            },
                           new byte[] {
                (byte)PathPointType.Start, (byte)PathPointType.Line, (byte)PathPointType.Line
            }, FillMode.Winding));
        }
        //------ End Constructors -----//
        public override void Paint(Graphics g, System.Drawing.Drawing2D.GraphicsPath gp, bool isSelected)
        {
            if (isSelected)
            {
                SolidBrush br = new SolidBrush(selectedBack);
                Pen pen = new Pen(selectedLine);
                g.FillPath(br, gp);
                g.DrawPath(pen, gp);
                br.Dispose();
                pen.Dispose();
            }
            else  //is not selected
            {
                if (_PaintBack)
                {
                    SolidBrush br = new SolidBrush(_BackColor);
                    g.FillPath(br,gp);
                    br.Dispose();
                }

                if (_PaintLine)
                {
                    Pen pen = new Pen(_LineColor);
                    g.DrawPath(pen, gp);
                    pen.Dispose();
                }
            }
        }
 /// <summary>
 /// Instructs the drawing code to fill the specified path with the specified pattern
 /// </summary>
 /// <param name="g">The System.Drawing.Graphics device to draw to</param>
 /// <param name="gp">The System.Drawing.Drawing2D.GraphicsPath to fill</param>
 public override void FillPath(Graphics g, GraphicsPath gp)
 {
     System.Drawing.Drawing2D.HatchBrush hb = new HatchBrush(_hatchStyle, _foreColor, _backColor);
     g.FillPath(hb, gp);
     hb.Dispose();
     base.FillPath(g, gp);
 }
Exemple #58
0
        public void Gen(List<BiliInterfaceInfo> infos)
        {
            Log.Info("【主榜】开始生成" + infos.Count + "个图片");

            for (int i = 0; i < infos.Count; i++)
            {
                image = Properties.Resources.zhubang;
                g = Graphics.FromImage(image);
                g.SmoothingMode = SmoothingMode.AntiAlias;

                ////
                Log.Info("正在生成 - " + infos[i].AVNUM);

                g.DrawString(infos[i].title, f, b, 350, 1000);
                g.DrawString(infos[i].AVNUM, f, b, 375, 900);
                g.DrawString(infos[i].created_at.Substring(0, infos[i].created_at.IndexOf(" ")), f, b, 900, 900);
                g.DrawString("UP:" + infos[i].author, f, b, 330, 800);

                Pen pp = new Pen(Color.Yellow, 3.5f);
                GraphicsPath pth = new GraphicsPath();
                pth.AddString(infos[i].Fpaiming.ToString("D2"), new FontFamily("微软雅黑"), (int)FontStyle.Bold, 180, new Point(1750, 0), sf);
                g.FillPath(new SolidBrush(Color.White), pth);
                g.DrawPath(pp, pth);

                AddKongxin(infos[i].Fdefen.ToString(), 160, 960, 70);
                AddKongxin(infos[i].play.ToString(), 1625, 500, 70);
                AddKongxin(infos[i].review.ToString(), 1820, 330, 50);
                AddKongxin(infos[i].coins.ToString(), 1810, 710, 50);
                AddKongxin(infos[i].favorites.ToString(), 1600, 825, 60);

                /*
                g.DrawString(infos[i].Fpaiming.ToString(), new Font("微软雅黑", 60, FontStyle.Bold), b, 110, nn - 30);

                g.DrawString(infos[i].AVNUM.Substring(2), f, b, 725, nn);
                g.DrawString(infos[i].Fdefen.ToString(), f, b, 1160, nn);
                if (infos[i].author.Length <= 6)
                {
                    g.DrawString(infos[i].author, f, b, new RectangleF(1518, nn, 320, 320));
                    //g.DrawString(infos[i].up, f, b, 1518, nn);
                }
                else
                {
                    g.DrawString(infos[i].author, f, b, new RectangleF(1518, nn, 320, 320));
                    //g.DrawString(infos[i].up.Substring(0, 6), f, b, 1518, nn);
                    //g.DrawString(infos[i].up.Substring(6), f, b, 1518, nn + 74);
                }

                g.DrawString(infos[i].created_at, f, b, 880, nn + 148);
                */

                ////

                string url = Environment.CurrentDirectory + @"\pic\Rank" + infos[i].Fpaiming + ".png";
                Log.Info("保存图片 " + url);
                image.Save(url);
            }

            Log.Info("主榜图片批量生成完成");
        }
Exemple #59
0
        /// <summary>
        /// Renders rectangle on canvas.
        /// </summary>
        /// <param name="g">Target graphics to render shape on.</param>
        /// <param name="bounds">Shape bounds.</param>
        public override void Paint(Graphics g, Rectangle bounds)
        {
            if (bounds.Width < 2 || bounds.Height < 2 || g == null || _Fill == null && _Border == null) return;

            GraphicsPath path = null;
            
            if (!_CornerRadius.IsZero)
            {
                path = DisplayHelp.GetRoundedRectanglePath(bounds, _CornerRadius.TopLeft, _CornerRadius.TopRight, 
                    _CornerRadius.BottomRight, _CornerRadius.BottomLeft);
            }

            if (_Fill != null)
            {
                Brush brush = _Fill.CreateBrush(bounds);
                if (brush != null)
                {
                    SmoothingMode sm = g.SmoothingMode;
                    if (brush is SolidBrush && path==null)
                        g.SmoothingMode = SmoothingMode.None;
                    if (path == null)
                        g.FillRectangle(brush, bounds);
                    else
                        g.FillPath(brush, path);
                    g.SmoothingMode = sm;
                    brush.Dispose();
                }
            }

            if (_Border != null)
            {
                Pen pen = _Border.CreatePen();
                if (pen != null)
                {
                    if (path == null)
                        g.DrawRectangle(pen, bounds);
                    else
                        g.DrawPath(pen, path);

                    pen.Dispose();
                }
            }

            Shape content = this.Content;
            if (content != null)
            {
                Rectangle contentBounds = Border.Deflate(bounds, _Border);
                Region oldClip = null;
                if (path != null && ClipToBounds)
                {
                    oldClip = g.Clip;
                    g.SetClip(path, CombineMode.Intersect);
                }
                content.Paint(g, contentBounds);
                if (oldClip != null) g.Clip = oldClip;
            }

            if (path != null) path.Dispose();
        }
Exemple #60
0
        public void drawMe(Graphics G)
        {
            if (innerBrush != null)
                G.FillPath(innerBrush, Path);

            if (boundPen != null)
                G.DrawPath(boundPen, Path);
        }