예제 #1
0
파일: DrawHelper.cs 프로젝트: mr-amini/ComU
    public static GraphicsPath CreateRoundRect(float x, float y, float width, float height, float radius)
    {
        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();
        return gp;
    }
예제 #2
0
 public static GraphicsPath RoundRect(Rectangle rect, int Curve)
 {
     GraphicsPath P = new GraphicsPath();
     int ArcRectWidth = Curve * 2;
     P.AddArc(new Rectangle(rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -180, 90);
     P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -90, 90);
     P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 0, 90);
     P.AddArc(new Rectangle(rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 90, 90);
     P.AddLine(new Point(rect.X, rect.Height - ArcRectWidth + rect.Y), new Point(rect.X, Curve + rect.Y));
     return P;
 }
예제 #3
0
 private void DrawBar(Graphics objGraphics, 
         int Value, int BarNumber, string Label)
 {
     int intLeft   = (BarNumber*75)+60;
         int intBottom   = 275;
         int intHeight   = (25*Value);
          //绘制柱面
         objGraphics.FillRectangle(Brushes.Red,intLeft,
            intBottom-intHeight,35,intHeight);
         //使用GraphicsPath方法绘制柱面顶层
         GraphicsPath pthTop = new GraphicsPath();
         pthTop.AddLine(intLeft-1, intBottom-intHeight,
            intLeft+20, intBottom-intHeight-10);
         pthTop.AddLine(intLeft+55,intBottom-
            intHeight-10,intLeft+35,
            intBottom-intHeight);
         objGraphics.FillPath(Brushes.LightSalmon,
            pthTop);
         // 绘制柱面左侧
         GraphicsPath pthRight = new GraphicsPath();
         pthRight.AddLine(intLeft+35,intBottom-
            intHeight,intLeft+55,intBottom-
            intHeight-10);
         pthRight.AddLine(intLeft+55,
            intBottom-15,intLeft+35,intBottom);
         objGraphics.FillPath(Brushes.Firebrick,
            pthRight);
         //绘制标签
         objGraphics.TranslateTransform(intLeft+15,
            intBottom-intHeight - 30);
         objGraphics.RotateTransform(300);
         objGraphics.DrawString(Label,new
            Font("Arial",10,FontStyle.Bold),
            Brushes.Black,0,0);
         objGraphics.ResetTransform();
 }
예제 #4
0
        public override void Paint(Graphics g)
        {
            base.Paint(g);

            if (mCollapsed)
            {
                Rectangle = new RectangleF(Rectangle.X, Rectangle.Y, 200, 50);
            }
            else
            {
                Rectangle = new RectangleF(Rectangle.X, Rectangle.Y, 200, 100);
            }
            DashStyle estiloAnterior = Pen.DashStyle;
            float     anchoAnterior  = Pen.Width;
            Color     colorAnterior  = Pen.Color;

            if (this.IsSelected)
            {
                Pen.DashStyle = DashStyle.Solid;
                Pen.Color     = Color.Orange;
                Pen.Width     = 2;
            }
            else
            {
                Pen.DashStyle = DashStyle.Dash;
            }


            GraphicsPath path = new GraphicsPath();

            path.AddArc(Rectangle.X, Rectangle.Y, 20, 20, -180, 90);
            path.AddLine(Rectangle.X + 10, Rectangle.Y, Rectangle.X + Rectangle.Width - 10, Rectangle.Y);
            path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y, 20, 20, -90, 90);
            path.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + 10, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 10);
            path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y + Rectangle.Height - 20, 20, 20, 0, 90);
            path.AddLine(Rectangle.X + Rectangle.Width - 10, Rectangle.Y + Rectangle.Height, Rectangle.X + 10, Rectangle.Y + Rectangle.Height);
            path.AddArc(Rectangle.X, Rectangle.Y + Rectangle.Height - 20, 20, 20, 90, 90);
            path.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height - 10, Rectangle.X, Rectangle.Y + 10);
            //shadow
            Region darkRegion = new Region(path);

            darkRegion.Translate(5, 5);
            g.FillRegion(new SolidBrush(Color.FromArgb(20, Color.Black)), darkRegion);

            //background
            g.FillPath(new SolidBrush(Color.White), path);

            if (mCollapsed)
            {
                //Pinto el gradiente
                Brush  unBrush   = new LinearGradientBrush(new Point(((int)(Rectangle.X)), ((int)(Rectangle.Y))), new Point(((int)(Rectangle.X + Rectangle.Width)), ((int)(Rectangle.Y))), ShapeColor, Color.White);
                Region unaRegion = new Region(path);
                g.FillRegion(unBrush, unaRegion);
            }
            else
            {
                GraphicsPath gradientPath = new GraphicsPath();
                gradientPath.AddArc(Rectangle.X + 1, Rectangle.Y + 1, 18, 18, -180, 90);
                gradientPath.AddLine(Rectangle.X + 11, Rectangle.Y + 1, Rectangle.X + Rectangle.Width - 11, Rectangle.Y + 1);
                gradientPath.AddArc(Rectangle.X + Rectangle.Width - 19, Rectangle.Y + 1, 18, 18, -90, 90);
                gradientPath.AddLine(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + 50, Rectangle.X + 1, Rectangle.Y + 50);
                //gradient
                Brush  unBrush   = new LinearGradientBrush(new Point(((int)(Rectangle.X)), ((int)(Rectangle.Y))), new Point(((int)(Rectangle.X + Rectangle.Width)), ((int)(Rectangle.Y))), ShapeColor, Color.White);
                Region unaRegion = new Region(gradientPath);
                g.FillRegion(unBrush, unaRegion);
            }

            //the border
            g.DrawPath(Pen, path);

            Pen.DashStyle = estiloAnterior;
            Pen.Width     = anchoAnterior;
            Pen.Color     = colorAnterior;

            switch (mSubType)
            {
            case SubTypes.Task:

                g.DrawImage(new Bitmap(this.GetType(), "Resources.task.ico"), ((int)(Rectangle.X + 5)), ((int)(Rectangle.Y + 5)));
                break;

            case SubTypes.Event:

                g.DrawImage(new Bitmap(this.GetType(), "Resources.event.ico"), ((int)(Rectangle.X + 5)), ((int)(Rectangle.Y + 5)));
                break;
            }

            StringFormat sf = new StringFormat();

            sf.Trimming = StringTrimming.EllipsisCharacter;
            g.DrawString(mTitle, new Font("Verdana", 10, FontStyle.Bold), TextBrush, Rectangle.X + 20, Rectangle.Y + 5);
            g.DrawString(mSubtitle, new Font("Verdana", 8), TextBrush, new RectangleF(Rectangle.X + 5, Rectangle.Y + 22, Rectangle.Width - 10, 28), sf);
            if (mCollapsed)
            {
                g.DrawImage(new Bitmap(this.GetType(), "Resources.down.ico"), ((int)(Rectangle.Right - 20)), ((int)(Rectangle.Y + 5)));
            }
            else
            {
                g.DrawImage(new Bitmap(this.GetType(), "Resources.up.ico"), ((int)(Rectangle.Right - 20)), ((int)(Rectangle.Y + 5)));
                g.DrawString(mObservation, new Font("Verdana", 8), TextBrush, new RectangleF(Rectangle.X + 5, Rectangle.Y + 55, Rectangle.Width - 10, 40), sf);
            }
        }
예제 #5
0
        /// <summary>
        /// Makes a border path for rounded borders.<br/>
        /// To support rounded dotted/dashed borders we need to use arc in the border path.<br/>
        /// Return null if the border is not rounded.<br/>
        /// </summary>
        /// <param name="border">Desired border</param>
        /// <param name="b">Box which the border corresponds</param>
        /// <param name="r">the rectangle the border is enclosing</param>
        /// <returns>Beveled border path, null if there is no rounded corners</returns>
        static GraphicsPath GetRoundedBorderPath(PaintVisitor p, CssSide border, CssBox b, RectangleF r)
        {
            GraphicsPath path = null;

            switch (border)
            {
            case CssSide.Top:
                if (b.ActualCornerNW > 0 || b.ActualCornerNE > 0)
                {
                    path = p.GraphicsPlatform.CreateGraphicsPath();

                    if (b.ActualCornerNW > 0)
                    {
                        path.AddArc(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2, b.ActualCornerNW * 2, b.ActualCornerNW * 2, 180f, 90f);
                    }
                    else
                    {
                        path.AddLine(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2, r.Left + b.ActualBorderLeftWidth, r.Top + b.ActualBorderTopWidth / 2);
                    }

                    if (b.ActualCornerNE > 0)
                    {
                        path.AddArc(r.Right - b.ActualCornerNE * 2 - b.ActualBorderRightWidth / 2, r.Top + b.ActualBorderTopWidth / 2, b.ActualCornerNE * 2, b.ActualCornerNE * 2, 270f, 90f);
                    }
                    else
                    {
                        path.AddLine(r.Right - b.ActualCornerNE * 2 - b.ActualBorderRightWidth, r.Top + b.ActualBorderTopWidth / 2, r.Right - b.ActualBorderRightWidth / 2, r.Top + b.ActualBorderTopWidth / 2);
                    }
                }
                break;

            case CssSide.Bottom:
                if (b.ActualCornerSW > 0 || b.ActualCornerSE > 0)
                {
                    path = p.GraphicsPlatform.CreateGraphicsPath();
                    if (b.ActualCornerSE > 0)
                    {
                        path.AddArc(r.Right - b.ActualCornerNE * 2 - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualCornerSE * 2 - b.ActualBorderBottomWidth / 2, b.ActualCornerSE * 2, b.ActualCornerSE * 2, 0f, 90f);
                    }
                    else
                    {
                        path.AddLine(r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2, r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2 - .1f);
                    }

                    if (b.ActualCornerSW > 0)
                    {
                        path.AddArc(r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualCornerSW * 2 - b.ActualBorderBottomWidth / 2, b.ActualCornerSW * 2, b.ActualCornerSW * 2, 90f, 90f);
                    }
                    else
                    {
                        path.AddLine(r.Left + b.ActualBorderLeftWidth / 2 + .1f, r.Bottom - b.ActualBorderBottomWidth / 2, r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2);
                    }
                }
                break;

            case CssSide.Right:
                if (b.ActualCornerNE > 0 || b.ActualCornerSE > 0)
                {
                    path = p.GraphicsPlatform.CreateGraphicsPath();
                    if (b.ActualCornerNE > 0 && b.BorderTopStyle >= CssBorderStyle.Visible)
                    {
                        path.AddArc(r.Right - b.ActualCornerNE * 2 - b.ActualBorderRightWidth / 2, r.Top + b.ActualBorderTopWidth / 2, b.ActualCornerNE * 2, b.ActualCornerNE * 2, 270f, 90f);
                    }
                    else
                    {
                        path.AddLine(r.Right - b.ActualBorderRightWidth / 2, r.Top + b.ActualCornerNE + b.ActualBorderTopWidth / 2, r.Right - b.ActualBorderRightWidth / 2, r.Top + b.ActualCornerNE + b.ActualBorderTopWidth / 2 + .1f);
                    }

                    if (b.ActualCornerSE > 0 &&
                        b.BorderBottomStyle >= CssBorderStyle.Visible)
                    {
                        path.AddArc(r.Right - b.ActualCornerSE * 2 - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualCornerSE * 2 - b.ActualBorderBottomWidth / 2, b.ActualCornerSE * 2, b.ActualCornerSE * 2, 0f, 90f);
                    }
                    else
                    {
                        path.AddLine(r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualCornerSE - b.ActualBorderBottomWidth / 2 - .1f, r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualCornerSE - b.ActualBorderBottomWidth / 2);
                    }
                }
                break;

            case CssSide.Left:
                if (b.ActualCornerNW > 0 || b.ActualCornerSW > 0)
                {
                    path = p.GraphicsPlatform.CreateGraphicsPath();
                    if (b.ActualCornerSW > 0 && b.BorderTopStyle >= CssBorderStyle.Visible)    //(b.BorderTopStyle == CssConstants.None || b.BorderTopStyle == CssConstants.Hidden))
                    {
                        path.AddArc(r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualCornerSW * 2 - b.ActualBorderBottomWidth / 2, b.ActualCornerSW * 2, b.ActualCornerSW * 2, 90f, 90f);
                    }
                    else
                    {
                        path.AddLine(r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualCornerSW - b.ActualBorderBottomWidth / 2, r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualCornerSW - b.ActualBorderBottomWidth / 2 - .1f);
                    }

                    if (b.ActualCornerNW > 0 &&
                        b.BorderBottomStyle >= CssBorderStyle.Visible)
                    {
                        path.AddArc(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2, b.ActualCornerNW * 2, b.ActualCornerNW * 2, 180f, 90f);
                    }
                    else
                    {
                        path.AddLine(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualCornerNW + b.ActualBorderTopWidth / 2 + .1f, r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualCornerNW + b.ActualBorderTopWidth / 2);
                    }
                }
                break;
            }

            return(path);
        }
예제 #6
0
        public override void AddToPath(GraphicsPath graphicsPath)
        {
            if (this.Start == this.End)
            {
                return;
            }

            if (this.RadiusX == 0.0f && this.RadiusY == 0.0f)
            {
                graphicsPath.AddLine(this.Start, this.End);
                return;
            }

            double sinPhi = Math.Sin(this.Angle * SvgArcSegment.RadiansPerDegree);
            double cosPhi = Math.Cos(this.Angle * SvgArcSegment.RadiansPerDegree);

            double x1dash = cosPhi * (this.Start.X - this.End.X) / 2.0 + sinPhi * (this.Start.Y - this.End.Y) / 2.0;
            double y1dash = -sinPhi * (this.Start.X - this.End.X) / 2.0 + cosPhi * (this.Start.Y - this.End.Y) / 2.0;

            double root;
            double numerator = this.RadiusX * this.RadiusX * this.RadiusY * this.RadiusY - this.RadiusX * this.RadiusX * y1dash * y1dash - this.RadiusY * this.RadiusY * x1dash * x1dash;

            float rx = this.RadiusX;
            float ry = this.RadiusY;

            if (numerator < 0.0)
            {
                float s = (float)Math.Sqrt(1.0 - numerator / (this.RadiusX * this.RadiusX * this.RadiusY * this.RadiusY));

                rx  *= s;
                ry  *= s;
                root = 0.0;
            }
            else
            {
                root = ((this.Size == SvgArcSize.Large && this.Sweep == SvgArcSweep.Positive) || (this.Size == SvgArcSize.Small && this.Sweep == SvgArcSweep.Negative) ? -1.0 : 1.0) * Math.Sqrt(numerator / (this.RadiusX * this.RadiusX * y1dash * y1dash + this.RadiusY * this.RadiusY * x1dash * x1dash));
            }

            double cxdash = root * rx * y1dash / ry;
            double cydash = -root * ry * x1dash / rx;

            double cx = cosPhi * cxdash - sinPhi * cydash + (this.Start.X + this.End.X) / 2.0;
            double cy = sinPhi * cxdash + cosPhi * cydash + (this.Start.Y + this.End.Y) / 2.0;

            double theta1 = SvgArcSegment.CalculateVectorAngle(1.0, 0.0, (x1dash - cxdash) / rx, (y1dash - cydash) / ry);
            double dtheta = SvgArcSegment.CalculateVectorAngle((x1dash - cxdash) / rx, (y1dash - cydash) / ry, (-x1dash - cxdash) / rx, (-y1dash - cydash) / ry);

            if (this.Sweep == SvgArcSweep.Negative && dtheta > 0)
            {
                dtheta -= 2.0 * Math.PI;
            }
            else if (this.Sweep == SvgArcSweep.Positive && dtheta < 0)
            {
                dtheta += 2.0 * Math.PI;
            }

            int    segments = (int)Math.Ceiling((double)Math.Abs(dtheta / (Math.PI / 2.0)));
            double delta    = dtheta / segments;
            double t        = 8.0 / 3.0 * Math.Sin(delta / 4.0) * Math.Sin(delta / 4.0) / Math.Sin(delta / 2.0);

            double startX = this.Start.X;
            double startY = this.Start.Y;

            for (int i = 0; i < segments; ++i)
            {
                double cosTheta1 = Math.Cos(theta1);
                double sinTheta1 = Math.Sin(theta1);
                double theta2    = theta1 + delta;
                double cosTheta2 = Math.Cos(theta2);
                double sinTheta2 = Math.Sin(theta2);

                double endpointX = cosPhi * rx * cosTheta2 - sinPhi * ry * sinTheta2 + cx;
                double endpointY = sinPhi * rx * cosTheta2 + cosPhi * ry * sinTheta2 + cy;

                double dx1 = t * (-cosPhi * rx * sinTheta1 - sinPhi * ry * cosTheta1);
                double dy1 = t * (-sinPhi * rx * sinTheta1 + cosPhi * ry * cosTheta1);

                double dxe = t * (cosPhi * rx * sinTheta2 + sinPhi * ry * cosTheta2);
                double dye = t * (sinPhi * rx * sinTheta2 - cosPhi * ry * cosTheta2);

                graphicsPath.AddBezier((float)startX, (float)startY, (float)(startX + dx1), (float)(startY + dy1),
                                       (float)(endpointX + dxe), (float)(endpointY + dye), (float)endpointX, (float)endpointY);

                theta1 = theta2;
                startX = (float)endpointX;
                startY = (float)endpointY;
            }
        }
예제 #7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics  g      = e.Graphics;
            Rectangle bounds = this.ClientRectangle;

            bounds.Offset(1, 1);
            bounds.Inflate(-2, -2);
            Color startColor = SystemColors.ControlLightLight;
            Color endColor   = SystemColors.Control;

            if (selected)
            {
                startColor = Mix(SystemColors.ControlLightLight, SystemColors.Highlight, 0.1);
                endColor   = Mix(SystemColors.ControlLightLight, SystemColors.Highlight, 0.65);
            }
            Brush gradient = new LinearGradientBrush(bounds,
                                                     startColor,
                                                     endColor,
                                                     LinearGradientMode.ForwardDiagonal);

            GraphicsPath path = new GraphicsPath();

            const int egdeRadius  = 3;
            const int innerMargin = egdeRadius + 2;

            RectangleF arcRect = new RectangleF(bounds.Location, new SizeF(egdeRadius * 2, egdeRadius * 2));

            //top left Arc
            path.AddArc(arcRect, 180, 90);
            path.AddLine(bounds.X + egdeRadius, bounds.Y, bounds.Right - egdeRadius, bounds.Y);
            // top right arc
            arcRect.X = bounds.Right - egdeRadius * 2;
            path.AddArc(arcRect, 270, 90);
            path.AddLine(bounds.Right, bounds.Left + egdeRadius, bounds.Right, bounds.Bottom - egdeRadius);
            // bottom right arc
            arcRect.Y = bounds.Bottom - egdeRadius * 2;
            path.AddArc(arcRect, 0, 90);
            path.AddLine(bounds.X + egdeRadius, bounds.Bottom, bounds.Right - egdeRadius, bounds.Bottom);
            // bottom left arc
            arcRect.X = bounds.Left;
            path.AddArc(arcRect, 90, 90);
            path.AddLine(bounds.X, bounds.Left + egdeRadius, bounds.X, bounds.Bottom - egdeRadius);

            g.FillPath(gradient, path);
            g.DrawPath(SystemPens.ControlText, path);
            path.Dispose();
            gradient.Dispose();
            Brush  textBrush;
            string description = GetText(out textBrush);
            int    titleWidth;

            using (Font boldFont = new Font("Arial", 8, FontStyle.Bold)) {
                g.DrawString(addIn.Name, boldFont, textBrush, innerMargin, innerMargin);
                titleWidth = (int)g.MeasureString(addIn.Name, boldFont).Width + 1;
            }
            if (addIn.Version != null && addIn.Version.ToString() != "0.0.0.0")
            {
                g.DrawString(addIn.Version.ToString(), Font, textBrush, innerMargin + titleWidth + 4, innerMargin);
            }
            RectangleF textBounds = bounds;

            textBounds.Offset(innerMargin, innerMargin);
            textBounds.Inflate(-innerMargin * 2, -innerMargin * 2 + 2);
            if (isExternal)
            {
                textBounds.Height -= pathHeight;
            }
            using (StringFormat sf = new StringFormat(StringFormatFlags.LineLimit)) {
                sf.Trimming = StringTrimming.EllipsisWord;
                g.DrawString(description, Font, textBrush, textBounds, sf);
            }
            if (isExternal)
            {
                textBounds.Y      = textBounds.Bottom + 2;
                textBounds.Height = pathHeight + 2;
                using (Font font = new Font(Font.Name, 7, FontStyle.Italic)) {
                    using (StringFormat sf = new StringFormat(StringFormatFlags.NoWrap)) {
                        sf.Trimming  = StringTrimming.EllipsisPath;
                        sf.Alignment = StringAlignment.Far;
                        g.DrawString(addIn.FileName, font,
                                     selected ? SystemBrushes.HighlightText : SystemBrushes.ControlText,
                                     textBounds, sf);
                    }
                }
            }
        }
예제 #8
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics g = pevent.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            // Create painting objects
            Brush b = new SolidBrush(this.ForeColor);

            // Create Rectangle To Limit brush area.
            Rectangle rect = new Rectangle(0, 0, 150, 150);

            LinearGradientBrush linearBrush =
                new LinearGradientBrush(rect,
                                        Color.FromArgb(20, 20, 20),
                                        this.ForeColor,
                                        225);

            path      = new GraphicsPath();
            innerPath = new GraphicsPath();

            switch (Rotation)
            {
            case 0:
            {
                path.AddArc(0, 0, 270, 270, 180, 90);
                path.AddArc(120, 0, 30, 30, 270, 90);
                path.AddLine(150, 0, 150, 85);
                path.AddArc(100, 100, 100, 100, -90, -90);
                path.AddLine(100, 150, 0, 150);
                path.AddArc(0, 120, 30, 30, 90, 90);

                innerPath.AddArc(10, 10, 250, 250, 180, 90);
                innerPath.AddArc(130, 10, 10, 10, 270, 90);
                innerPath.AddLine(140, 0, 140, 90);
                innerPath.AddArc(90, 90, 100, 100, -90, -90);
                innerPath.AddLine(90, 140, 10, 140);
                innerPath.AddArc(10, 130, 10, 10, 90, 90);
            }
            break;

            case 90:
            {
                path.AddArc(-120, 0, 270, 270, 270, 90);
                path.AddArc(120, 120, 30, 30, 0, 90);
                path.AddLine(135, 150, 50, 150);
                path.AddArc(-50, 100, 100, 100, 0, -90);
                path.AddLine(0, 100, 0, 15);
                path.AddArc(0, 0, 30, 30, 180, 90);

                innerPath.AddArc(-110, 10, 250, 250, 270, 90);
                innerPath.AddArc(130, 130, 10, 10, 0, 90);
                innerPath.AddLine(130, 140, 60, 140);
                innerPath.AddArc(-40, 90, 100, 100, 0, -90);
                innerPath.AddLine(10, 90, 10, 10);
                innerPath.AddArc(10, 10, 10, 10, 180, 90);
            }
            break;

            case 180:
            {
                path.AddArc(-120, -120, 270, 270, 0, 90);
                path.AddArc(0, 120, 30, 30, 90, 90);
                path.AddLine(0, 135, 0, 50);
                path.AddArc(-50, -50, 100, 100, 90, -90);
                path.AddLine(50, 0, 135, 0);
                path.AddArc(120, 0, 30, 30, 270, 90);

                innerPath.AddArc(-110, -110, 250, 250, 0, 90);
                innerPath.AddArc(10, 130, 10, 10, 90, 90);
                innerPath.AddLine(10, 125, 10, 60);
                innerPath.AddArc(-40, -40, 100, 100, 90, -90);
                innerPath.AddLine(60, 10, 135, 10);
                innerPath.AddArc(130, 10, 10, 10, 270, 90);
            }
            break;

            case 270:
            {
                path.AddArc(0, -120, 270, 270, 90, 90);
                path.AddArc(0, 0, 30, 30, 180, 90);
                path.AddLine(15, 0, 100, 0);
                path.AddArc(100, -50, 100, 100, 180, -90);
                path.AddLine(150, 50, 150, 135);
                path.AddArc(120, 120, 30, 30, 0, 90);

                innerPath.AddArc(10, -110, 250, 250, 90, 90);
                innerPath.AddArc(10, 10, 10, 10, 180, 90);
                innerPath.AddLine(5, 10, 60, 10);
                innerPath.AddArc(90, -40, 100, 100, 180, -90);
                innerPath.AddLine(140, 60, 140, 135);
                innerPath.AddArc(130, 130, 10, 10, 0, 90);
            }
            break;
            }

            this.Region = new Region(path);

            PathGradientBrush pgbrush = new PathGradientBrush(innerPath);

            pgbrush.CenterPoint    = new Point(75, 75);
            pgbrush.CenterColor    = Color.White;
            pgbrush.SurroundColors = new Color[] { Color.FromArgb(250, this.ForeColor) };

            if (_clicked == false)
            {
                g.FillPath(linearBrush, path);
                g.FillPath(b, innerPath);
            }
            else
            {
                g.FillPath(linearBrush, path);
                g.FillPath(pgbrush, innerPath);
            }

            // Dispose of painting objects
            b.Dispose();
            pgbrush.Dispose();
            linearBrush.Dispose();
        }
예제 #9
0
파일: Theme.cs 프로젝트: massimoca/Wedit
    private void DrawClose(int x, int y)
    {
        if (ClosePath == null)
        {
            ClosePath = new GraphicsPath();
            ClosePath.AddLine(x + 1, y, x + 3, y);
            ClosePath.AddLine(x + 5, y + 2, x + 7, y);
            ClosePath.AddLine(x + 9, y, x + 10, y + 1);
            ClosePath.AddLine(x + 7, y + 4, x + 7, y + 5);
            ClosePath.AddLine(x + 10, y + 8, x + 9, y + 9);
            ClosePath.AddLine(x + 7, y + 9, x + 5, y + 7);
            ClosePath.AddLine(x + 3, y + 9, x + 1, y + 9);
            ClosePath.AddLine(x + 0, y + 8, x + 3, y + 5);
            ClosePath.AddLine(x + 3, y + 4, x + 0, y + 1);
        }

        G.FillPath(Brushes.White, ClosePath);
        G.DrawPath(Pens.Black, ClosePath);
    }
예제 #10
0
        private GraphicsPath CreateCloseFlagPath(Rectangle rect)
        {
            var tf   = new PointF(rect.X + (rect.Width / 2f), rect.Y + (rect.Height / 2f));
            var path = new GraphicsPath();

            path.AddLine(tf.X, tf.Y - 2f, tf.X - 2f, tf.Y - 4f);
            path.AddLine(tf.X - 2f, tf.Y - 4f, tf.X - 6f, tf.Y - 4f);
            path.AddLine(tf.X - 6f, tf.Y - 4f, tf.X - 2f, tf.Y);
            path.AddLine(tf.X - 2f, tf.Y, tf.X - 6f, tf.Y + 4f);
            path.AddLine(tf.X - 6f, tf.Y + 4f, tf.X - 2f, tf.Y + 4f);
            path.AddLine(tf.X - 2f, tf.Y + 4f, tf.X, tf.Y + 2f);
            path.AddLine(tf.X, tf.Y + 2f, tf.X + 2f, tf.Y + 4f);
            path.AddLine(tf.X + 2f, tf.Y + 4f, tf.X + 6f, tf.Y + 4f);
            path.AddLine(tf.X + 6f, tf.Y + 4f, tf.X + 2f, tf.Y);
            path.AddLine(tf.X + 2f, tf.Y, tf.X + 6f, tf.Y - 4f);
            path.AddLine(tf.X + 6f, tf.Y - 4f, tf.X + 2f, tf.Y - 4f);
            path.CloseFigure();
            return(path);
        }
예제 #11
0
    private GraphicsPath RoundRectangle(Rectangle r, int radius, GroupBoxCorners corners)
    {
        GraphicsPath path = new GraphicsPath();
        if (r.Width <= 0 | r.Height <= 0)
          return path;

        int d = radius * 2;

        int nw = ((corners & GroupBoxCorners.NorthWest) == GroupBoxCorners.NorthWest ? d : 0);
        int ne = ((corners & GroupBoxCorners.NorthEast) == GroupBoxCorners.NorthEast ? d : 0);
        int se = ((corners & GroupBoxCorners.SouthEast) == GroupBoxCorners.SouthEast ? d : 0);
        int sw = ((corners & GroupBoxCorners.SouthWest) == GroupBoxCorners.SouthWest ? d : 0);

        path.AddLine(r.Left + nw, r.Top, r.Right - ne, r.Top);

        if (ne > 0)
        {
          path.AddArc(Rectangle.FromLTRB(r.Right - ne, r.Top, r.Right, r.Top + ne), -90, 90);
        }

        path.AddLine(r.Right, r.Top + ne, r.Right, r.Bottom - se);

        if (se > 0)
        {
          path.AddArc(Rectangle.FromLTRB(r.Right - se, r.Bottom - se, r.Right, r.Bottom), 0, 90);
        }

        path.AddLine(r.Right - se, r.Bottom, r.Left + sw, r.Bottom);

        if (sw > 0)
        {
          path.AddArc(Rectangle.FromLTRB(r.Left, r.Bottom - sw, r.Left + sw, r.Bottom), 90, 90);
        }

        path.AddLine(r.Left, r.Bottom - sw, r.Left, r.Top + nw);

        if (nw > 0)
        {
          path.AddArc(Rectangle.FromLTRB(r.Left, r.Top, r.Left + nw, r.Top + nw), 180, 90);
        }

        path.CloseFigure();
        return path;
    }
예제 #12
0
파일: ImageHelper.cs 프로젝트: sedogo/site
    private static Image MakeRoundedCorners(Image image, int radius)
    {
        Bitmap bmp = new Bitmap(image, image.Width, image.Height);
        using (Graphics g = Graphics.FromImage(bmp))
        {
            Brush brush = new SolidBrush(Color.White);

            for (int i = 0; i < 4; i++)
            {
                Point[] cornerUpLeft = new Point[3];

                cornerUpLeft[0].X = 0;
                cornerUpLeft[0].Y = 0;

                cornerUpLeft[1].X = radius;
                cornerUpLeft[1].Y = 0;

                cornerUpLeft[2].X = 0;
                cornerUpLeft[2].Y = radius;

                GraphicsPath pathCornerUpLeft = new GraphicsPath();

                pathCornerUpLeft.AddArc(cornerUpLeft[0].X, cornerUpLeft[0].Y,
                                        radius, radius, 180, 90);
                pathCornerUpLeft.AddLine(cornerUpLeft[0].X, cornerUpLeft[0].Y,
                                         cornerUpLeft[1].X, cornerUpLeft[1].Y);
                pathCornerUpLeft.AddLine(cornerUpLeft[0].X, cornerUpLeft[0].Y,
                                         cornerUpLeft[2].X, cornerUpLeft[2].Y);

                g.FillPath(brush, pathCornerUpLeft);
                pathCornerUpLeft.Dispose();

                bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
            }

            brush.Dispose();
            g.Dispose();
        }
        return bmp;
    }
예제 #13
0
 public GraphicsPath RoundRect(Rectangle Rectangle, int Curve)
 {
     GraphicsPath P = new GraphicsPath();
     int ArcRectangleWidth = Curve * 2;
     P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
     P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
     P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
     P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
     P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
     return P;
 }
예제 #14
0
        private static void DrawBorders(Graphics graphics, XPanderPanel xpanderPanel)
        {
            if (xpanderPanel.ShowBorder == true)
            {
                using (GraphicsPath graphicsPath = new GraphicsPath())
                {
                    using (Pen borderPen = new Pen(xpanderPanel.PanelColors.BorderColor, Constants.BorderThickness))
                    {
                        Rectangle captionRectangle = xpanderPanel.CaptionRectangle;
                        Rectangle borderRectangle  = captionRectangle;

                        if (xpanderPanel.Expand == true)
                        {
                            borderRectangle = xpanderPanel.ClientRectangle;

                            graphics.DrawLine(
                                borderPen,
                                captionRectangle.Left,
                                captionRectangle.Top + captionRectangle.Height - Constants.BorderThickness,
                                captionRectangle.Left + captionRectangle.Width,
                                captionRectangle.Top + captionRectangle.Height - Constants.BorderThickness);
                        }

                        XPanderPanelList xpanderPanelList = xpanderPanel.Parent as XPanderPanelList;
                        if ((xpanderPanelList != null) && (xpanderPanelList.Dock == DockStyle.Fill))
                        {
                            BSE.Windows.Forms.Panel panel = xpanderPanelList.Parent as BSE.Windows.Forms.Panel;
                            XPanderPanel            parentXPanderPanel = xpanderPanelList.Parent as XPanderPanel;
                            if (((panel != null) && (panel.Padding == new Padding(0))) ||
                                ((parentXPanderPanel != null) && (parentXPanderPanel.Padding == new Padding(0))))
                            {
                                if (xpanderPanel.Top != 0)
                                {
                                    graphicsPath.AddLine(
                                        borderRectangle.Left,
                                        borderRectangle.Top,
                                        borderRectangle.Left + captionRectangle.Width,
                                        borderRectangle.Top);
                                }

                                // Left vertical borderline
                                graphics.DrawLine(borderPen,
                                                  borderRectangle.Left,
                                                  borderRectangle.Top,
                                                  borderRectangle.Left,
                                                  borderRectangle.Top + borderRectangle.Height);

                                // Right vertical borderline
                                graphics.DrawLine(borderPen,
                                                  borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness,
                                                  borderRectangle.Top,
                                                  borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness,
                                                  borderRectangle.Top + borderRectangle.Height);
                            }
                            else
                            {
                                // Upper horizontal borderline only at the top xpanderPanel
                                if (xpanderPanel.Top == 0)
                                {
                                    graphicsPath.AddLine(
                                        borderRectangle.Left,
                                        borderRectangle.Top,
                                        borderRectangle.Left + borderRectangle.Width,
                                        borderRectangle.Top);
                                }

                                // Left vertical borderline
                                graphicsPath.AddLine(
                                    borderRectangle.Left,
                                    borderRectangle.Top,
                                    borderRectangle.Left,
                                    borderRectangle.Top + borderRectangle.Height);

                                //Lower horizontal borderline
                                graphicsPath.AddLine(
                                    borderRectangle.Left,
                                    borderRectangle.Top + borderRectangle.Height - Constants.BorderThickness,
                                    borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness,
                                    borderRectangle.Top + borderRectangle.Height - Constants.BorderThickness);

                                // Right vertical borderline
                                graphicsPath.AddLine(
                                    borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness,
                                    borderRectangle.Top,
                                    borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness,
                                    borderRectangle.Top + borderRectangle.Height);
                            }
                        }
                        else
                        {
                            // Upper horizontal borderline only at the top xpanderPanel
                            if (xpanderPanel.Top == 0)
                            {
                                graphicsPath.AddLine(
                                    borderRectangle.Left,
                                    borderRectangle.Top,
                                    borderRectangle.Left + borderRectangle.Width,
                                    borderRectangle.Top);
                            }

                            // Left vertical borderline
                            graphicsPath.AddLine(
                                borderRectangle.Left,
                                borderRectangle.Top,
                                borderRectangle.Left,
                                borderRectangle.Top + borderRectangle.Height);

                            //Lower horizontal borderline
                            graphicsPath.AddLine(
                                borderRectangle.Left,
                                borderRectangle.Top + borderRectangle.Height - Constants.BorderThickness,
                                borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness,
                                borderRectangle.Top + borderRectangle.Height - Constants.BorderThickness);

                            // Right vertical borderline
                            graphicsPath.AddLine(
                                borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness,
                                borderRectangle.Top,
                                borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness,
                                borderRectangle.Top + borderRectangle.Height);
                        }
                    }
                    using (Pen borderPen = new Pen(xpanderPanel.PanelColors.BorderColor, Constants.BorderThickness))
                    {
                        graphics.DrawPath(borderPen, graphicsPath);
                    }
                }
            }
        }
예제 #15
0
파일: DarkTheme.cs 프로젝트: RedNax67/GoBot
    public static GraphicsPath RoundRect(Rectangle Rect, int Rounding, RoundingStyle Style = RoundingStyle.All)
    {
        GraphicsPath GP = new GraphicsPath();
        int AW = Rounding * 2;

        GP.StartFigure();

        if (Rounding == 0)
        {
            GP.AddRectangle(Rect);
            GP.CloseAllFigures();
            return GP;
        }

        switch (Style)
        {
            case RoundingStyle.All:
                GP.AddArc(new Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90);
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
                GP.AddArc(new Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90);
                break;
            case RoundingStyle.Top:
                GP.AddArc(new Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90);
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
                GP.AddLine(new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
                break;
            case RoundingStyle.Bottom:
                GP.AddLine(new Point(Rect.X, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y));
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
                GP.AddArc(new Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90);
                break;
            case RoundingStyle.Left:
                GP.AddArc(new Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90);
                GP.AddLine(new Point(Rect.X + Rect.Width, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height));
                GP.AddArc(new Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90);
                break;
            case RoundingStyle.Right:
                GP.AddLine(new Point(Rect.X, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y));
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
                break;
            case RoundingStyle.TopRight:
                GP.AddLine(new Point(Rect.X, Rect.Y + 1), new Point(Rect.X, Rect.Y));
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
                GP.AddLine(new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height - 1), new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height));
                GP.AddLine(new Point(Rect.X + 1, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
                break;
            case RoundingStyle.BottomRight:
                GP.AddLine(new Point(Rect.X, Rect.Y + 1), new Point(Rect.X, Rect.Y));
                GP.AddLine(new Point(Rect.X + Rect.Width - 1, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y));
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
                GP.AddLine(new Point(Rect.X + 1, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
                break;
        }

        GP.CloseAllFigures();

        return GP;
    }
예제 #16
0
    /// <summary>
    /// Creates the round rect path.
    /// </summary>
    /// <param name="rect">The rectangle on which graphics path will be spanned.</param>
    /// <param name="size">The size of rounded rectangle edges.</param>
    /// <returns></returns>
    public static GraphicsPath CreateRoundRectPath(Rectangle rect, Size size)
    {
        GraphicsPath gp = new GraphicsPath();
        gp.AddLine(rect.Left + size.Width / 2, rect.Top, rect.Right - size.Width / 2, rect.Top);
        gp.AddArc(rect.Right - size.Width, rect.Top, size.Width, size.Height, 270, 90);

        gp.AddLine(rect.Right, rect.Top + size.Height / 2, rect.Right, rect.Bottom - size.Width / 2);
        gp.AddArc(rect.Right - size.Width, rect.Bottom - size.Height, size.Width, size.Height, 0, 90);

        gp.AddLine(rect.Right - size.Width / 2, rect.Bottom, rect.Left + size.Width / 2, rect.Bottom);
        gp.AddArc(rect.Left, rect.Bottom - size.Height, size.Width, size.Height, 90, 90);

        gp.AddLine(rect.Left, rect.Bottom - size.Height / 2, rect.Left, rect.Top + size.Height / 2);
        gp.AddArc(rect.Left, rect.Top, size.Width, size.Height, 180, 90);
        return gp;
    }
            protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);

                if (IndicatorSizeValue > 0)
                {
                    Region ControlRegion = null;

                    using (GraphicsPath Path = new GraphicsPath())
                    {
                        Rectangle OffsetRectangle = new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height);
                        int IndicatorSizeValue2 = (IndicatorSizeValue * 2);
                        int IndicatorStart = 0;

                        if ((IndicatorAlignmentValue == TabAlignment.Left) || (IndicatorAlignmentValue == TabAlignment.Right))
                        {
                            IndicatorStart = this.Height;
                        }
                        else
                        {
                            IndicatorStart = this.Width;
                        }

                        IndicatorStart -= IndicatorSizeValue2;
                        IndicatorStart = ((IndicatorStart * IndicatorLocationValue) / 100);

                        Path.FillMode = FillMode.Winding;

                        Path.StartFigure();

                        int IndicatorMiddle = (IndicatorStart + IndicatorSizeValue);
                        int IndicatorEnd = (IndicatorStart + IndicatorSizeValue2);

                        if (IndicatorAlignmentValue == TabAlignment.Left)
                        {
                            OffsetRectangle.X += IndicatorSizeValue;
                            OffsetRectangle.Width -= IndicatorSizeValue;

                            Path.AddLine(OffsetRectangle.Left, IndicatorStart, OffsetRectangle.Left, IndicatorEnd);
                            Path.AddLine(OffsetRectangle.Left, IndicatorEnd, OffsetRectangle.Left - IndicatorSizeValue, IndicatorMiddle);
                            Path.AddLine(OffsetRectangle.Left - IndicatorSizeValue, IndicatorMiddle, OffsetRectangle.Left, IndicatorStart);
                        }
                        else if (IndicatorAlignmentValue == TabAlignment.Right)
                        {
                            OffsetRectangle.Width -= IndicatorSizeValue;

                            Path.AddLine(OffsetRectangle.Right, IndicatorStart, OffsetRectangle.Right + IndicatorSizeValue, IndicatorMiddle);
                            Path.AddLine(OffsetRectangle.Right + IndicatorSizeValue, IndicatorMiddle, OffsetRectangle.Right, IndicatorEnd);
                            Path.AddLine(OffsetRectangle.Right, IndicatorEnd, OffsetRectangle.Right, IndicatorStart);
                        }
                        else if (IndicatorAlignmentValue == TabAlignment.Top)
                        {
                            OffsetRectangle.Y += IndicatorSizeValue;
                            OffsetRectangle.Height -= IndicatorSizeValue;

                            Path.AddLine(IndicatorStart, OffsetRectangle.Top, IndicatorMiddle, OffsetRectangle.Top - IndicatorSizeValue);
                            Path.AddLine(IndicatorMiddle, OffsetRectangle.Top - IndicatorSizeValue, IndicatorEnd, OffsetRectangle.Top);
                            Path.AddLine(IndicatorEnd, OffsetRectangle.Top, IndicatorStart, OffsetRectangle.Top);
                        }
                        else if (IndicatorAlignmentValue == TabAlignment.Bottom)
                        {
                            OffsetRectangle.Height -= IndicatorSizeValue;

                            Path.AddLine(IndicatorStart, OffsetRectangle.Bottom, IndicatorEnd, OffsetRectangle.Bottom);
                            Path.AddLine(IndicatorEnd, OffsetRectangle.Bottom, IndicatorMiddle, OffsetRectangle.Bottom + IndicatorSizeValue);
                            Path.AddLine(IndicatorMiddle, OffsetRectangle.Bottom + IndicatorSizeValue, IndicatorStart, OffsetRectangle.Bottom);
                        }

                        Path.CloseFigure();

                        Region TabRegion = new Region(Path);
                        ControlRegion = new Region(OffsetRectangle);

                        ControlRegion.Union(TabRegion);

                    }

                    this.Region = ControlRegion;
                }
            }
예제 #18
0
 /// <summary>
 ///   Creates <c>GraphicsPath</c> for cylinder surface section. This 
 ///   path consists of two arcs and two vertical lines.
 /// </summary>
 /// <param name="startAngle">
 ///   Starting angle of the surface.
 /// </param>
 /// <param name="endAngle">
 ///   Ending angle of the surface.
 /// </param>
 /// <param name="pointStart">
 ///   Starting point on the cylinder surface.
 /// </param>
 /// <param name="pointEnd">
 ///   Ending point on the cylinder surface.
 /// </param>
 /// <returns>
 ///   <c>GraphicsPath</c> object representing the cylinder surface.
 /// </returns>
 private GraphicsPath CreatePathForCylinderSurfaceSection(float startAngle, float endAngle, GpPointF pointStart, GpPointF pointEnd)
 {
     GraphicsPath path = new GraphicsPath();
     path.AddArc(m_boundingRectangle.X, m_boundingRectangle.Y, m_boundingRectangle.Width, m_boundingRectangle.Height,startAngle, endAngle - startAngle);
     path.AddLine(pointEnd.X, pointEnd.Y, pointEnd.X, pointEnd.Y + m_sliceHeight);
     path.AddArc(m_boundingRectangle.X, m_boundingRectangle.Y + m_sliceHeight, m_boundingRectangle.Width, m_boundingRectangle.Height, endAngle, startAngle - endAngle);
     path.AddLine(pointStart.X, pointStart.Y + m_sliceHeight, pointStart.X, pointStart.Y);
     return path;
 }
예제 #19
0
    private void Draw3DBorder(Graphics g, float offset, Brush color, bool fill, float r, float percent)
    {
        int pen_width = 2;
        float x = this.ClientRectangle.Left + (pen_width / 2) + offset;
        float y = this.ClientRectangle.Top + (pen_width / 2) + offset;
        float w = (this.ClientRectangle.Width - (pen_width / 2 + 2 + offset * 2)) * percent;
        float h = this.ClientRectangle.Height - (pen_width / 2 + 2 + offset * 2);

        Pen pen = new Pen(color, (float)pen_width);
        GraphicsPath path = new GraphicsPath();

        if (w < 2 * r) {
            w = 2 * r;
        }

        path.AddLine(x + r, y, x + (w - r * 2), y);
        path.AddArc(x + w - r * 2, y, r * 2, r * 2, 270, 90);
        path.AddLine(x + w, y + r, x + w, y + h - r * 2);
        path.AddArc(x + w - r * 2, y + h - r * 2, r * 2, r * 2, 0, 90);
        path.AddLine(x + w - r * 2, y + h, x + r, y + h);
        path.AddArc(x, y + h - r * 2, r * 2, r * 2, 90, 90);
        path.AddLine(x, y + h - r * 2, x, y + r);
        path.AddArc(x, y, r * 2, r * 2, 180, 90);
        path.CloseFigure();

        g.SmoothingMode = SmoothingMode.AntiAlias;
        if (fill) {
            g.FillPath(color, path);
        } else {
            g.DrawPath(pen, path);
        }
    }
예제 #20
0
        private GraphicsPath CreateBorderPath(Rectangle rect)
        {
            GraphicsPath path = new GraphicsPath();

            switch (Orientation)
            {
            case VisualOrientation.Top:
                path.AddLine(rect.Left, rect.Bottom - 1, rect.Left, rect.Top + 2);
                path.AddLine(rect.Left, rect.Top + 2, rect.Left + 2, rect.Top);
                path.AddLine(rect.Left + 2, rect.Top, rect.Right - 3, rect.Top);
                path.AddLine(rect.Right - 3, rect.Top, rect.Right - 1, rect.Top + 2);
                path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 1);
                path.AddLine(rect.Right - 1, rect.Bottom - 1, rect.Left, rect.Bottom - 1);
                break;

            case VisualOrientation.Bottom:
                path.AddLine(rect.Left, rect.Top, rect.Left, rect.Bottom - 3);
                path.AddLine(rect.Left, rect.Bottom - 3, rect.Left + 2, rect.Bottom - 1);
                path.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Right - 3, rect.Bottom - 1);
                path.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 3);
                path.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 1, rect.Top);
                path.AddLine(rect.Right - 1, rect.Top, rect.Left, rect.Top);
                break;

            case VisualOrientation.Left:
                path.AddLine(rect.Right - 1, rect.Top, rect.Left + 2, rect.Top);
                path.AddLine(rect.Left + 2, rect.Top, rect.Left, rect.Top + 2);
                path.AddLine(rect.Left, rect.Top + 2, rect.Left, rect.Bottom - 3);
                path.AddLine(rect.Left, rect.Bottom - 3, rect.Left + 2, rect.Bottom - 1);
                path.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
                path.AddLine(rect.Right - 1, rect.Bottom - 1, rect.Right - 1, rect.Top);
                break;

            case VisualOrientation.Right:
                path.AddLine(rect.Left, rect.Top, rect.Right - 3, rect.Top);
                path.AddLine(rect.Right - 3, rect.Top, rect.Right - 1, rect.Top + 2);
                path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 3);
                path.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1);
                path.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left, rect.Bottom - 1);
                path.AddLine(rect.Left, rect.Bottom - 1, rect.Left, rect.Top);
                break;
            }

            return(path);
        }
예제 #21
0
        internal void ProcessMovement()
        {
            // update robot position
            PointD tOldPosition = m_tPosition;

            m_tPosition += m_tMovement;
            m_tMovement  = PointD.Empty;

            // check if we have hit a wall
            bool bHitWall = false;

            if (m_tPosition.X - Size.Width / 2.0 < 0)
            {
                m_tPosition.X = Size.Width / 2.0;
                bHitWall      = true;
            }
            else if (m_tPosition.X + Size.Width / 2.0 > m_pBattle.BattleFieldSize.Width)
            {
                m_tPosition.X = m_pBattle.BattleFieldSize.Width - Size.Width / 2.0;
                bHitWall      = true;
            }
            if (m_tPosition.Y - Size.Height / 2.0 < 0)
            {
                m_tPosition.Y = Size.Height / 2.0;
                bHitWall      = true;
            }
            else if (m_tPosition.Y + Size.Height / 2.0 > m_pBattle.BattleFieldSize.Height)
            {
                m_tPosition.Y = m_pBattle.BattleFieldSize.Height - Size.Height / 2.0;
                bHitWall      = true;
            }
            if (bHitWall)
            {
                m_pEvents.Add(new HitWallEvent());
                m_dEnergy -= 3.0;
            }

            // rotate robot
            m_nHeading += m_nRotation;
            if (m_nHeading < 0)
            {
                m_nHeading = 360 + m_nHeading;
            }
            if (m_nHeading > 359)
            {
                m_nHeading -= 360;
            }
            m_nRotation = 0;

            PointF tEndPoint = new PointF((float)(Position.X + Math.Sin(HeadingRadians) * BattleFieldSize.Width),
                                          (float)(Position.Y + Math.Cos(HeadingRadians) * BattleFieldSize.Width));

            // check if we can see another robot
            for (int i = 0; i < m_pBattle.Robots.Length; i++)
            {
                Robot pRobot = m_pBattle.Robots[i];

                // make sure we're not testing against ourselves
                if (pRobot != this)
                {
                    GraphicsPath pPath = new GraphicsPath();
                    pPath.AddLine(Position, tEndPoint);
                    pPath.CloseFigure();
                    pPath.Widen(new Pen(Color.Black, 1));
                    Region pRegion = new Region(pPath);
                    pRegion.Intersect(pRobot.Bounds);
                    if (!pRegion.IsEmpty(m_pGraphics))
                    {
                        // we can see this robot
                        PointD            tDistance = pRobot.Position - Position;
                        double            dDistance = Math.Sqrt(tDistance.X * tDistance.X + tDistance.Y * tDistance.Y);
                        ScannedRobotEvent pEvent    = new ScannedRobotEvent(
                            pRobot.Name, pRobot.Energy, pRobot.Heading - Heading,
                            dDistance, pRobot.Heading, pRobot.Velocity);
                        m_pEvents.Add(pEvent);
                    }
                }
            }

            // check if we have collided with another robot
            for (int i = 0; i < m_pBattle.Robots.Length; i++)
            {
                Robot pRobot = m_pBattle.Robots[i];

                // make sure we're not testing against ourselves
                if (pRobot != this)
                {
                    if (pRobot.Bounds.IntersectsWith(Bounds))
                    {
                        // send message to ourselves
                        bool          bAtFault = true;
                        HitRobotEvent pEvent   = new HitRobotEvent(pRobot.Name,
                                                                   Math.Abs(pRobot.Heading - Heading),
                                                                   pRobot.Energy, bAtFault);
                        m_pEvents.Add(pEvent);
                        m_tPosition = tOldPosition;
                        m_dEnergy  -= 3.0;
                    }
                }
            }
        }
예제 #22
0
 public GraphicsPath GetValueRec()
 {
     GraphicsPath gp = new GraphicsPath();
     gp.AddArc((float)((.05f) * vm.Width), (float)((1f / 3f) * vm.Height), (float)(.90f) * vm.Width, (float)(1.2f) * vm.Height, -180f, 180f);
     gp.AddLine((float)((.05f) * vm.Width), (float)((70f / 75f) * vm.Height), (float)(.95f) * vm.Width, (float)((70f / 75f) * vm.Height));
     return gp;
 }
예제 #23
0
        /// <summary>Generates the boundary of the hint balloon</summary>
        private GraphicsPath GeneratePath(bool region_border)
        {
            var width  = Width + (region_border ? 1 : 0);
            var height = Height + (region_border ? 1 : 0);
            var cr     = Math.Max(1, CornerRadius);

            GraphicsPath path;

            if (TipLength == 0 || TipBaseWidth == 0)
            {
                path = Gdi.RoundedRectanglePath(new RectangleF(0, 0, width, height), cr);
            }
            else
            {
                var tip_length = TipLength;
                var tip_width  = Math_.Clamp(width - 2 * (tip_length + cr), Math.Min(5, TipBaseWidth), TipBaseWidth);

                // Find the corner to start from
                path = new GraphicsPath();
                switch (TipCorner)
                {
                default:
                    Debug.Assert(false, "Unknown corner");
                    break;

                case ETipCorner.TopLeft:
                    path.AddLine(0, 0, tip_length + cr + tip_width, tip_length);
                    path.AddArc(width - tip_length - cr, tip_length, cr, cr, 270f, 90f);
                    path.AddArc(width - tip_length - cr, height - tip_length - cr, cr, cr, 0f, 90f);
                    path.AddArc(tip_length, height - tip_length - cr, cr, cr, 90f, 90f);
                    path.AddArc(tip_length, tip_length, cr, cr, 180f, 90f);
                    path.AddLine(tip_length + cr, tip_length, 0, 0);
                    break;

                case ETipCorner.TopRight:
                    path.AddLine(width, 0, width - tip_length - cr, tip_length);
                    path.AddArc(width - tip_length - cr, tip_length, cr, cr, 270f, 90f);
                    path.AddArc(width - tip_length - cr, height - tip_length - cr, cr, cr, 0f, 90f);
                    path.AddArc(tip_length, height - tip_length - cr, cr, cr, 90f, 90f);
                    path.AddArc(tip_length, tip_length, cr, cr, 180f, 90f);
                    path.AddLine(tip_length + cr, tip_length, width - tip_length - cr - tip_width, tip_length);
                    path.AddLine(width - tip_length - cr - tip_width, tip_length, width, 0);
                    break;

                case ETipCorner.BottomLeft:
                    path.AddLine(0, height, tip_length + cr, height - tip_length);
                    path.AddArc(tip_length, height - tip_length - cr, cr, cr, 90f, 90f);
                    path.AddArc(tip_length, tip_length, cr, cr, 180f, 90f);
                    path.AddArc(width - tip_length - cr, tip_length, cr, cr, 270f, 90f);
                    path.AddArc(width - tip_length - cr, height - tip_length - cr, cr, cr, 0f, 90f);
                    path.AddLine(width - tip_length - cr, height - tip_length, tip_length + cr + tip_width, height - tip_length);
                    path.AddLine(tip_length + cr + tip_width, height - tip_length, 0, height);
                    break;

                case ETipCorner.BottomRight:
                    path.AddLine(width, height, width - tip_length - cr - tip_width, height - tip_length);
                    path.AddArc(tip_length, height - tip_length - cr, cr, cr, 90f, 90f);
                    path.AddArc(tip_length, tip_length, cr, cr, 180f, 90f);
                    path.AddArc(width - tip_length - cr, tip_length, cr, cr, 270f, 90f);
                    path.AddArc(width - tip_length - cr, height - tip_length - cr, cr, cr, 0f, 90f);
                    path.AddLine(width - tip_length - cr, height - tip_length, width, height);
                    break;
                }
            }
            return(path);
        }
예제 #24
0
                public static void DrawDocumentTab(Graphics g, Rectangle rect, Color backColorBegin, Color backColorEnd, Color edgeColor, TabDrawType tabType, bool closed)
                {
                    GraphicsPath path;
                    Region Region;
                    Brush brush = null;
                    Pen pen;
                    brush = new LinearGradientBrush(rect, backColorBegin, backColorEnd, LinearGradientMode.Vertical);
                    pen = new pen(edgeColor, 1.0F);
                    path = new GraphicsPath();

                    if (tabType == TabDrawType.First)
                    {
                        path.AddLine(rect.Left + 1, rect.Bottom + 1, rect.Left + rect.Height, rect.Top + 2);
                        path.AddLine(rect.Left + rect.Height + 4, rect.Top, rect.Right - 3, rect.Top);
                        path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                    }
                    else
                    {
                        if (tabType == TabDrawType.Active)
                        {
                            path.AddLine(rect.Left + 1, rect.Bottom + 1, rect.Left + rect.Height, rect.Top + 2);
                            path.AddLine(rect.Left + rect.Height + 4, rect.Top, rect.Right - 3, rect.Top);
                            path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                        }
                        else
                        {
                            path.AddLine(rect.Left, rect.Top + 6, rect.Left + 4, rect.Top + 2);
                            path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top);
                            path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                            path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left, rect.Bottom + 1);
                        }
                    }
                    Region = new Region(path);
                    g.FillRegion(brush, Region);
                    g.DrawPath(pen, path);
                }
예제 #25
0
        public static SharpDX.Direct2D1.Bitmap RedrawMiscNoteBitmapCache(RenderTarget renderTargetSource, Color color)
        {
            ImagingFactory factory = new ImagingFactory();

            SharpDX.Direct2D1.Factory   factory2  = new SharpDX.Direct2D1.Factory();
            SharpDX.DirectWrite.Factory factory3  = new SharpDX.DirectWrite.Factory();
            SharpDX.WIC.Bitmap          wicBitmap = new SharpDX.WIC.Bitmap(factory, 0x10, 0x10, SharpDX.WIC.PixelFormat.Format32bppPBGRA, BitmapCreateCacheOption.CacheOnDemand);
            RenderTargetProperties      renderTargetProperties = new RenderTargetProperties(RenderTargetType.Default, new SharpDX.Direct2D1.PixelFormat(Format.Unknown, SharpDX.Direct2D1.AlphaMode.Unknown), 0f, 0f, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT);
            WicRenderTarget             renderTarget           = new WicRenderTarget(factory2, wicBitmap, renderTargetProperties);

            try
            {
                PointF[] pathPoints;
                renderTarget.BeginDraw();
                renderTarget.Clear(new RawColor4?(Color.Transparent.ToRawColor4(1f)));
                RawVector2 vector = new RawVector2(8f, 8f);
                using (GraphicsPath path = new GraphicsPath())
                {
                    float num  = vector.X - 6f;
                    float num2 = vector.Y - 3f;
                    path.AddLine((float)(num + 0f), (float)(num2 + 0f), (float)(num + 12f), (float)(num2 + 0f));
                    path.AddLine((float)(num + 12f), (float)(num2 + 0f), (float)(num + 12f), (float)(num2 + 6f));
                    path.AddLine((float)(num + 12f), (float)(num2 + 6f), (float)(num + 0f), (float)(num2 + 6f));
                    path.AddLine((float)(num + 0f), (float)(num2 + 6f), (float)(num + 0f), (float)(num2 + 0f));
                    path.Flatten();
                    pathPoints = path.PathPoints;
                    path.Dispose();
                }
                PathGeometry geometry = new PathGeometry(factory2);
                if (pathPoints.Length > 1)
                {
                    GeometrySink sink = geometry.Open();
                    sink.SetSegmentFlags(PathSegment.ForceRoundLineJoin);
                    sink.BeginFigure(new RawVector2(pathPoints[0].X, pathPoints[0].Y), FigureBegin.Filled);
                    for (int i = 1; i < pathPoints.Length; i++)
                    {
                        sink.AddLine(new RawVector2(pathPoints[i].X, pathPoints[i].Y));
                    }
                    sink.EndFigure(FigureEnd.Closed);
                    sink.Close();
                    sink.Dispose();
                }
                SolidColorBrush brush = new SolidColorBrush(renderTarget, color.ToRawColor4(1f));
                renderTarget.FillGeometry(geometry, brush);
                brush.Dispose();
                geometry.Dispose();
                renderTarget.EndDraw();
            }
            catch (Exception)
            {
                factory.Dispose();
                factory2.Dispose();
                factory3.Dispose();
                wicBitmap.Dispose();
                renderTarget.Dispose();
                return(null);
            }
            SharpDX.Direct2D1.Bitmap bitmap2 = SharpDX.Direct2D1.Bitmap.FromWicBitmap(renderTargetSource, wicBitmap);
            factory.Dispose();
            factory2.Dispose();
            factory3.Dispose();
            wicBitmap.Dispose();
            renderTarget.Dispose();
            return(bitmap2);
        }
예제 #26
0
파일: Chart.cs 프로젝트: bemk/rhc
        public void panel1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.HighQuality;
            Pen p = new Pen(c.GetPanel1().ForeColor, 3);
            p.LineJoin = LineJoin.Bevel;
            string selectedData = "" + c.GetComboBox1().SelectedItem;
            SizeF stringsize = g.MeasureString(selectedData, c.GetPanel1().Font);
            g.DrawString(selectedData, c.GetPanel1().Font, p.Brush, new Point(c.GetPanel1().Width - (int)stringsize.Width, 0));
            Console.WriteLine(selectedData);
            switch (c.GetComboBox1().SelectedIndex)
            {
                case 0:
                    {
                        g.TranslateTransform(0, c.GetPanel1().Height);
                        Point newPoint = new Point(c.GetPanel1().Width, (int)-(c.getData().heartRate / 1.5 + 5));
                        PointsHeartrate.Add(newPoint);
                        GraphicsPath path = new GraphicsPath();
                        path.StartFigure();
                        for (int i = 0; i < PointsHeartrate.Count; i++)
                        {
                            Point point = PointsHeartrate[i];
                            point.X -= 4;
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            PointsHeartrate[i] = point;
                        }
                        for (int j = PointsHeartrate.Count - 1; j > 0; j--)
                        {
                            Point point = PointsHeartrate[j];
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            PointsHeartrate[j] = point;
                        }
                        g.DrawPath(p, path);
                        for (int k = 0; k < PointsHeartrate.Count; k++)
                        {
                            if (PointsHeartrate[k].X < 0)
                            {
                                PointsHeartrate.RemoveAt(k);
                            }
                        }
                        break;
                    }
                case 1:
                    {
                        g.TranslateTransform(0, c.GetPanel1().Height);
                        Point newPoint = new Point(c.GetPanel1().Width, (int)-(c.getData().RPM / 1.2 + 5));
                        this.PointsRPM.Add(newPoint);
                        GraphicsPath path = new GraphicsPath();
                        path.StartFigure();
                        for (int i = 0; i < this.PointsRPM.Count; i++)
                        {
                            Point point = this.PointsRPM[i];
                            point.X -= 4;
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsRPM[i] = point;
                        }
                        for (int j = this.PointsRPM.Count - 1; j > 0; j--)
                        {
                            Point point = this.PointsRPM[j];
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsRPM[j] = point;
                        }
                        g.DrawPath(p, path);
                        for (int k = 0; k < this.PointsRPM.Count; k++)
                        {
                            if (this.PointsRPM[k].X < 0)
                            {
                                this.PointsRPM.RemoveAt(k);
                            }
                        }
                        break;
                    }

                case 2:
                    {
                        g.TranslateTransform(0, c.GetPanel1().Height);
                        Point newPoint = new Point(c.GetPanel1().Width, (int)-((int)c.getData().speed / (4.2 / 10) + 5));
                        this.PointsSpeed.Add(newPoint);
                        GraphicsPath path = new GraphicsPath();
                        path.StartFigure();
                        for (int i = 0; i < this.PointsSpeed.Count; i++)
                        {
                            Point point = this.PointsSpeed[i];
                            point.X -= 4;
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsSpeed[i] = point;
                        }
                        for (int j = this.PointsSpeed.Count - 1; j > 0; j--)
                        {
                            Point point = this.PointsSpeed[j];
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsSpeed[j] = point;
                        }
                        g.DrawPath(p, path);
                        for (int k = 0; k < this.PointsSpeed.Count; k++)
                        {
                            if (this.PointsSpeed[k].X < 0)
                            {
                                this.PointsSpeed.RemoveAt(k);
                            }
                        }
                        break;
                    }

                case 3:
                    {
                        g.TranslateTransform(0, c.GetPanel1().Height);
                        Point newPoint = new Point(c.GetPanel1().Width, (int)-(c.getData().distance / 600 + 5));
                        this.PointsDistance.Add(newPoint);
                        GraphicsPath path = new GraphicsPath();
                        path.StartFigure();
                        for (int i = 0; i < this.PointsDistance.Count; i++)
                        {
                            Point point = this.PointsDistance[i];
                            point.X -= 4;
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsDistance[i] = point;
                        }
                        for (int j = this.PointsDistance.Count - 1; j > 0; j--)
                        {
                            Point point = this.PointsDistance[j];
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsDistance[j] = point;
                        }
                        g.DrawPath(p, path);
                        for (int k = 0; k < this.PointsDistance.Count; k++)
                        {
                            if (this.PointsDistance[k].X < 0)
                            {
                                this.PointsDistance.RemoveAt(k);
                            }
                        }
                        break;
                    }

                case 4:
                    {
                        g.TranslateTransform(0, c.GetPanel1().Height);
                        Point newPoint = new Point(c.GetPanel1().Width, (int)-(c.getData().power / 2.4 + 5));
                        this.PointsPower.Add(newPoint);
                        GraphicsPath path = new GraphicsPath();
                        path.StartFigure();
                        for (int i = 0; i < this.PointsPower.Count; i++)
                        {
                            Point point = this.PointsPower[i];
                            point.X -= 4;
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsPower[i] = point;
                        }
                        for (int j = this.PointsPower.Count - 1; j > 0; j--)
                        {
                            Point point = this.PointsPower[j];
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsPower[j] = point;
                        }
                        g.DrawPath(p, path);
                        for (int k = 0; k < this.PointsPower.Count; k++)
                        {
                            if (this.PointsPower[k].X < 0)
                            {
                                this.PointsPower.RemoveAt(k);
                            }
                        }
                        break;
                    }

                case 5:
                    {
                        g.TranslateTransform(0, c.GetPanel1().Height);
                        Point newPoint = new Point(c.GetPanel1().Width, (int)-(c.getData().energy / 600 + 5));
                        this.PointsEnergy.Add(newPoint);
                        GraphicsPath path = new GraphicsPath();
                        path.StartFigure();
                        for (int i = 0; i < this.PointsEnergy.Count; i++)
                        {
                            Point point = this.PointsEnergy[i];
                            point.X -= 4;
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsEnergy[i] = point;
                        }
                        for (int j = this.PointsEnergy.Count - 1; j > 0; j--)
                        {
                            Point point = this.PointsEnergy[j];
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsEnergy[j] = point;
                        }
                        g.DrawPath(p, path);
                        for (int k = 0; k < this.PointsEnergy.Count; k++)
                        {
                            if (this.PointsEnergy[k].X < 0)
                            {
                                this.PointsEnergy.RemoveAt(k);
                            }
                        }
                        break;
                    }

                case 6:
                    {
                        g.TranslateTransform(0, c.GetPanel1().Height);
                        Point newPoint = new Point(c.GetPanel1().Width, (int)-(c.getData().currentPower / 2.4 + 5));
                        this.PointsCurrentPower.Add(newPoint);
                        GraphicsPath path = new GraphicsPath();
                        path.StartFigure();
                        for (int i = 0; i < this.PointsCurrentPower.Count; i++)
                        {
                            Point point = this.PointsCurrentPower[i];
                            point.X -= 4;
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsCurrentPower[i] = point;
                        }
                        for (int j = this.PointsCurrentPower.Count - 1; j > 0; j--)
                        {
                            Point point = this.PointsCurrentPower[j];
                            path.AddLine(oldPoint, point);
                            oldPoint = point;
                            this.PointsCurrentPower[j] = point;
                        }
                        g.DrawPath(p, path);
                        for (int k = 0; k < this.PointsCurrentPower.Count; k++)
                        {
                            if (this.PointsCurrentPower[k].X < 0)
                            {
                                this.PointsCurrentPower.RemoveAt(k);
                            }
                        }
                        break;
                    }
            }
            base.OnPaint(e);

            g.Dispose();
        }
예제 #27
0
        public static SharpDX.Direct2D1.Bitmap RedrawRestNoteBitmapCache(RenderTarget renderTargetSource, Color color, DurationTypes durationType)
        {
            ImagingFactory factory = new ImagingFactory();

            SharpDX.Direct2D1.Factory   factory2  = new SharpDX.Direct2D1.Factory();
            SharpDX.DirectWrite.Factory factory3  = new SharpDX.DirectWrite.Factory();
            SharpDX.WIC.Bitmap          wicBitmap = new SharpDX.WIC.Bitmap(factory, 0x20, 0x30, SharpDX.WIC.PixelFormat.Format32bppPBGRA, BitmapCreateCacheOption.CacheOnDemand);
            RenderTargetProperties      renderTargetProperties = new RenderTargetProperties(RenderTargetType.Default, new SharpDX.Direct2D1.PixelFormat(Format.Unknown, SharpDX.Direct2D1.AlphaMode.Unknown), 0f, 0f, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT);
            WicRenderTarget             renderTarget           = new WicRenderTarget(factory2, wicBitmap, renderTargetProperties);

            try
            {
                PointF[] pathPoints;
                renderTarget.BeginDraw();
                renderTarget.Clear(new RawColor4?(Color.Transparent.ToRawColor4(1f)));
                RawVector2 pos = new RawVector2(18f, 44f);
                using (GraphicsPath path = new GraphicsPath())
                {
                    DurationTypes types = durationType;
                    if (types <= DurationTypes.Eighth)
                    {
                        switch (types)
                        {
                        case DurationTypes.The32nd:
                            pos = new RawVector2(pos.X, (pos.Y - (8f * (((float)McMeasure.StaveSpacing) / 2f))) + 3f);
                            path.AddLine(pos.X, pos.Y, pos.X + 1.6f, pos.Y);
                            path.AddLine(pos.X + 1.6f, pos.Y, (pos.X - 8f) + 2.4f, pos.Y + 41f);
                            path.AddLine((float)((pos.X - 8f) + 2.4f), (float)(pos.Y + 41f), (float)((pos.X - 8f) - 0.8f), (float)(pos.Y + 41f));
                            path.AddLine((pos.X - 8f) - 0.8f, pos.Y + 41f, pos.X, pos.Y);
                            DrawRestDotPart(renderTarget, pos, color);
                            DrawRestDotPart(renderTarget, new RawVector2(pos.X - 2.2f, pos.Y + 11f), color);
                            DrawRestDotPart(renderTarget, new RawVector2(pos.X - 4.4f, pos.Y + 22f), color);
                            break;

                        case DurationTypes.The16th:
                            pos = new RawVector2(pos.X, (pos.Y - (6f * (((float)McMeasure.StaveSpacing) / 2f))) + 3f);
                            path.AddLine(pos.X, pos.Y, pos.X + 1.6f, pos.Y);
                            path.AddLine(pos.X + 1.6f, pos.Y, (pos.X - 8f) + 2.4f, pos.Y + 30f);
                            path.AddLine((float)((pos.X - 8f) + 2.4f), (float)(pos.Y + 30f), (float)((pos.X - 8f) - 0.8f), (float)(pos.Y + 30f));
                            path.AddLine((pos.X - 8f) - 0.8f, pos.Y + 30f, pos.X, pos.Y);
                            DrawRestDotPart(renderTarget, pos, color);
                            DrawRestDotPart(renderTarget, new RawVector2(pos.X - 2.4f, pos.Y + 11f), color);
                            break;

                        case DurationTypes.Eighth:
                            goto Label_06F6;
                        }
                    }
                    else
                    {
                        switch (types)
                        {
                        case DurationTypes.Quarter:
                            pos = new RawVector2(pos.X - 11f, pos.Y - (7f * (((float)McMeasure.StaveSpacing) / 2f)));
                            path.AddLine(pos.X, pos.Y, pos.X + 7f, pos.Y + 9.5f);
                            path.AddBezier((float)(pos.X + 7f), (float)(pos.Y + 9.5f), (float)(pos.X + 3f), (float)(pos.Y + 16f), (float)(pos.X + 3f), (float)(pos.Y + 16f), (float)(pos.X + 8f), (float)(pos.Y + 24f));
                            path.AddBezier((float)(pos.X + 8f), (float)(pos.Y + 24f), (float)(pos.X - 0f), (float)(pos.Y + 21f), (float)(pos.X - 1f), (float)(pos.Y + 26f), (float)(pos.X + 4f), (float)(pos.Y + 34f));
                            path.AddBezier((float)(pos.X + 4f), (float)(pos.Y + 34f), (float)(pos.X - 8f), (float)(pos.Y + 28f), (float)(pos.X - 4f), (float)(pos.Y + 17f), (float)(pos.X + 4.5f), (float)(pos.Y + 21f));
                            path.AddLine((float)(pos.X + 4.5f), (float)(pos.Y + 21f), (float)(pos.X - 1f), (float)(pos.Y + 14f));
                            path.AddBezier((float)(pos.X - 1f), (float)(pos.Y + 14f), (float)(pos.X + 3.5f), (float)(pos.Y + 11f), (float)(pos.X + 4f), (float)(pos.Y + 7f), (float)(pos.X - 1f), (float)(pos.Y + 2f));
                            goto Label_0AD7;

                        case DurationTypes.Half:
                            pos = new RawVector2(pos.X - 8f, pos.Y - (4f * (((float)McMeasure.StaveSpacing) / 2f)));
                            path.AddLine(pos.X - 7f, pos.Y, pos.X + 7f, pos.Y);
                            path.AddLine(pos.X + 7f, pos.Y, pos.X + 7f, pos.Y - 5f);
                            path.AddLine((float)(pos.X + 7f), (float)(pos.Y - 5f), (float)(pos.X - 7f), (float)(pos.Y - 5f));
                            path.AddLine(pos.X - 7f, pos.Y - 5f, pos.X - 7f, pos.Y);
                            path.AddLine(pos.X - 7f, pos.Y, pos.X - 10f, pos.Y);
                            path.AddLine(pos.X - 10f, pos.Y, pos.X - 10f, pos.Y + 1f);
                            path.AddLine((float)(pos.X - 10f), (float)(pos.Y + 1f), (float)(pos.X + 10f), (float)(pos.Y + 1f));
                            path.AddLine(pos.X + 10f, pos.Y + 1f, pos.X + 10f, pos.Y);
                            goto Label_0AD7;
                        }
                        if (types == DurationTypes.Whole)
                        {
                            pos = new RawVector2(pos.X - 8f, pos.Y - (6f * (((float)McMeasure.StaveSpacing) / 2f)));
                            path.AddLine(pos.X - 7f, pos.Y, pos.X + 7f, pos.Y);
                            path.AddLine(pos.X + 7f, pos.Y, pos.X + 7f, pos.Y + 5f);
                            path.AddLine((float)(pos.X + 7f), (float)(pos.Y + 5f), (float)(pos.X - 7f), (float)(pos.Y + 5f));
                            path.AddLine(pos.X - 7f, pos.Y + 5f, pos.X - 7f, pos.Y);
                            path.AddLine(pos.X - 7f, pos.Y, pos.X - 10f, pos.Y);
                            path.AddLine(pos.X - 10f, pos.Y, pos.X - 10f, pos.Y - 1f);
                            path.AddLine((float)(pos.X - 10f), (float)(pos.Y - 1f), (float)(pos.X + 10f), (float)(pos.Y - 1f));
                            path.AddLine(pos.X + 10f, pos.Y - 1f, pos.X + 10f, pos.Y);
                        }
                    }
                    goto Label_0AD7;
                    Label_06F6:
                    pos = new RawVector2(pos.X - 2f, (pos.Y - (6f * (((float)McMeasure.StaveSpacing) / 2f))) + 3f);
                    path.AddLine(pos.X, pos.Y, pos.X + 1.6f, pos.Y);
                    path.AddLine(pos.X + 1.6f, pos.Y, (pos.X - 8f) + 2.4f, pos.Y + 19f);
                    path.AddLine((float)((pos.X - 8f) + 2.4f), (float)(pos.Y + 19f), (float)((pos.X - 8f) - 0.8f), (float)(pos.Y + 19f));
                    path.AddLine((pos.X - 8f) - 0.8f, pos.Y + 19f, pos.X, pos.Y);
                    DrawRestDotPart(renderTarget, pos, color);
                    Label_0AD7:
                    path.Flatten();
                    pathPoints = path.PathPoints;
                    path.Dispose();
                }
                PathGeometry geometry = new PathGeometry(factory2);
                if (pathPoints.Length > 1)
                {
                    GeometrySink sink = geometry.Open();
                    sink.SetSegmentFlags(PathSegment.ForceRoundLineJoin);
                    sink.BeginFigure(new RawVector2(pathPoints[0].X, pathPoints[0].Y), FigureBegin.Filled);
                    for (int i = 1; i < pathPoints.Length; i++)
                    {
                        sink.AddLine(new RawVector2(pathPoints[i].X, pathPoints[i].Y));
                    }
                    sink.EndFigure(FigureEnd.Closed);
                    sink.Close();
                    sink.Dispose();
                }
                SolidColorBrush brush = new SolidColorBrush(renderTarget, color.ToRawColor4(1f));
                renderTarget.FillGeometry(geometry, brush);
                brush.Dispose();
                geometry.Dispose();
                renderTarget.EndDraw();
            }
            catch (Exception)
            {
                factory.Dispose();
                factory2.Dispose();
                factory3.Dispose();
                wicBitmap.Dispose();
                renderTarget.Dispose();
                return(null);
            }
            SharpDX.Direct2D1.Bitmap bitmap2 = SharpDX.Direct2D1.Bitmap.FromWicBitmap(renderTargetSource, wicBitmap);
            factory.Dispose();
            factory2.Dispose();
            factory3.Dispose();
            wicBitmap.Dispose();
            renderTarget.Dispose();
            return(bitmap2);
        }
예제 #28
0
        private GraphicsPath CreateMaximizeFlafPath(Rectangle rect, bool maximize)
        {
            var tf   = new PointF(rect.X + (rect.Width / 2f), rect.Y + (rect.Height / 2f));
            var path = new GraphicsPath();

            if (maximize)
            {
                path.AddLine(tf.X - 3f, tf.Y - 3f, tf.X - 6f, tf.Y - 3f);
                path.AddLine(tf.X - 6f, tf.Y - 3f, tf.X - 6f, tf.Y + 5f);
                path.AddLine(tf.X - 6f, tf.Y + 5f, tf.X + 3f, tf.Y + 5f);
                path.AddLine(tf.X + 3f, tf.Y + 5f, tf.X + 3f, tf.Y + 1f);
                path.AddLine(tf.X + 3f, tf.Y + 1f, tf.X + 6f, tf.Y + 1f);
                path.AddLine(tf.X + 6f, tf.Y + 1f, tf.X + 6f, tf.Y - 6f);
                path.AddLine(tf.X + 6f, tf.Y - 6f, tf.X - 3f, tf.Y - 6f);
                path.CloseFigure();
                path.AddRectangle(new RectangleF(tf.X - 4f, tf.Y, 5f, 3f));
                path.AddLine(tf.X - 1f, tf.Y - 4f, tf.X + 4f, tf.Y - 4f);
                path.AddLine(tf.X + 4f, tf.Y - 4f, tf.X + 4f, tf.Y - 1f);
                path.AddLine(tf.X + 4f, tf.Y - 1f, tf.X + 3f, tf.Y - 1f);
                path.AddLine(tf.X + 3f, tf.Y - 1f, tf.X + 3f, tf.Y - 3f);
                path.AddLine(tf.X + 3f, tf.Y - 3f, tf.X - 1f, tf.Y - 3f);
                path.CloseFigure();
                return(path);
            }
            path.AddRectangle(new RectangleF(tf.X - 6f, tf.Y - 4f, 12f, 8f));
            path.AddRectangle(new RectangleF(tf.X - 3f, tf.Y - 1f, 6f, 3f));
            return(path);
        }
 public void AddLine(Point pt1, Point pt2)
 {
     Changed();
     gdiPath.AddLine(pt1, pt2);
 }
예제 #30
0
        private GraphicsPath CreateTabPath(Rectangle rect)
        {
            GraphicsPath path = new GraphicsPath();

            switch (Alignment)
            {
            case TabAlignment.Top:
                rect.X++;
                rect.Width -= 2;
                path.AddLine(
                    rect.X,
                    rect.Bottom,
                    rect.X,
                    rect.Y + Radius / 2);
                path.AddArc(
                    rect.X,
                    rect.Y,
                    Radius,
                    Radius,
                    180F,
                    90F);
                path.AddArc(
                    rect.Right - Radius,
                    rect.Y,
                    Radius,
                    Radius,
                    270F,
                    90F);
                path.AddLine(
                    rect.Right,
                    rect.Y + Radius / 2,
                    rect.Right,
                    rect.Bottom);
                break;

            case TabAlignment.Bottom:
                rect.X++;
                rect.Width -= 2;
                path.AddLine(
                    rect.X,
                    rect.Y,
                    rect.X,
                    rect.Bottom - Radius / 2);
                path.AddArc(
                    rect.X,
                    rect.Bottom - Radius,
                    Radius,
                    Radius,
                    180,
                    -90);
                path.AddArc(
                    rect.Right - Radius,
                    rect.Bottom - Radius,
                    Radius,
                    Radius,
                    90,
                    -90);
                path.AddLine(
                    rect.Right,
                    rect.Bottom - Radius / 2,
                    rect.Right,
                    rect.Y);

                break;

            case TabAlignment.Left:
                rect.Y++;
                rect.Height -= 2;
                path.AddLine(
                    rect.Right,
                    rect.Y,
                    rect.X + Radius / 2,
                    rect.Y);
                path.AddArc(
                    rect.X,
                    rect.Y,
                    Radius,
                    Radius,
                    270F,
                    -90F);
                path.AddArc(
                    rect.X,
                    rect.Bottom - Radius,
                    Radius,
                    Radius,
                    180F,
                    -90F);
                path.AddLine(
                    rect.X + Radius / 2,
                    rect.Bottom,
                    rect.Right,
                    rect.Bottom);
                break;

            case TabAlignment.Right:
                rect.Y++;
                rect.Height -= 2;
                path.AddLine(
                    rect.X,
                    rect.Y,
                    rect.Right - Radius / 2,
                    rect.Y);
                path.AddArc(
                    rect.Right - Radius,
                    rect.Y,
                    Radius,
                    Radius,
                    270F,
                    90F);
                path.AddArc(
                    rect.Right - Radius,
                    rect.Bottom - Radius,
                    Radius,
                    Radius,
                    0F,
                    90F);
                path.AddLine(
                    rect.Right - Radius / 2,
                    rect.Bottom,
                    rect.X,
                    rect.Bottom);
                break;
            }
            path.CloseFigure();
            return(path);
        }
예제 #31
0
파일: ShapeRater.cs 프로젝트: jcbarton/MUMS
    public GraphicsPath DrawHeart(float Xc, float Yc)
    {
        GraphicsPath gp = new GraphicsPath();

        Rectangle HeartTopLeftSquare = new Rectangle((int)Xc, (int)Yc, (int)RadiusOuter, (int)RadiusOuter);
        Rectangle HeartTopRightSquare = new Rectangle((int)Xc + (int)RadiusOuter, (int)Yc, (int)RadiusOuter, (int)RadiusOuter);

        gp.AddArc(HeartTopLeftSquare, 135f, 225f);
        gp.AddArc(HeartTopRightSquare, 180f, 225f);
        gp.AddLine((int)(Xc + (RadiusOuter * 2) - (1 - Math.Sin(45 / 180 * Math.PI)) * RadiusOuter / 2), (int)(Yc + RadiusOuter / 2 + Math.Sin(45 / 180 * Math.PI) * RadiusOuter / 2), (int)(Xc + RadiusOuter), (int)(Yc + (RadiusOuter * 2)));
        gp.AddLine((int)(Xc + RadiusOuter / 2 - Math.Sin(45 / 180 * Math.PI) * RadiusOuter / 2), (int)(Yc + RadiusOuter / 2 + Math.Sin(45 / 180 * Math.PI) * RadiusOuter / 2), (int)(Xc + RadiusOuter), (int)(Yc + (RadiusOuter * 2)));
        return gp;
    }
예제 #32
0
        public void DrawString(Node node, StyleAttributes styleAttributes, int x, int y, int dx, int dy, string text, Color color)
        {
            Brush brush1;

            if (styleAttributes != null)
            {
                if (node.NotBlack() || (((node.type_.type == ElementType.Entity) && (node.parent_ != null)) && node.parent_.NotBlack()))
                {
                    brush1 = new SolidBrush(styleAttributes.color);
                }
                else
                {
                    brush1 = new SolidBrush(color);
                }
            }
            else if (color != Color.Black)
            {
                brush1 = new SolidBrush(color);
            }
            else
            {
                brush1 = this.blackBrush;
            }
            System.Drawing.Font font1 = this.GetSuitableFont(node, styleAttributes);

            PointF tf1 = new PointF((float)((this.oX + x) + dx), (float)((this.oY + y) + dy));

            if (((node.glyph != null) && node.glyph.IsVisible) && ((node.glyph.Category.Name != "Spaces") && (node.glyph.FontFamily.Length == 0)))
            {
                brush1 = new SolidBrush(Color.Red);
                this.graphics_.DrawString("?", font1, brush1, tf1, this.typographicsFormat);
                return;
            }
            if ((text == "{"))
            {
                try
                {
                    double num3 = this.MeasureWidth(node, node.style_, text);
                    double num4 = 0.1;
                    double num5 = num4 * num3;
                    tf1.X -= (int)Math.Round(num5);
                }
                catch
                {
                }
            }
            if (((node.type_.type == ElementType.Entity) && (node.glyph != null)) && (node.glyph.Code == "0222C"))
            {
                this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                tf1.X += node.box.Width / 3;
                this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                goto Label_1B94;
            }
            if (((node.type_.type == ElementType.Entity) && (node.glyph != null)) && (node.glyph.Code == "000A8"))
            {
                string text1 = "";
                text1 = text + text;
                this.graphics_.DrawString(text1, font1, brush1, tf1, this.typographicsFormat);
                goto Label_1B94;
            }
            if (((node.type_.type == ElementType.Entity) && (node.glyph != null)) && (node.glyph.Code == "0222D"))
            {
                this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                tf1.X += node.box.Width / 4;
                this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                tf1.X += node.box.Width / 4;
                this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                goto Label_1B94;
            }
            if (((node.type_.type != ElementType.Entity) || (node.glyph == null)) || (((((node.glyph.Code != "02192") && (node.glyph.Code != "02190")) && ((node.glyph.Code != "02194") && (node.glyph.Code != "0F576"))) && (((node.glyph.Code != "0F577") && (node.glyph.Code != "0F578")) && ((node.glyph.Code != "021C4") && (node.glyph.Code != "021C6")))) && ((((node.glyph.Code != "021CC") && (node.glyph.Code != "021CB")) && ((node.glyph.Code != "021C0") && (node.glyph.Code != "021C1"))) && ((((node.glyph.Code != "021BC") && (node.glyph.Code != "021BD")) && ((node.glyph.Code != "0005E") && (node.glyph.Code != "000AF"))) && (((node.glyph.Code != "0FE37") && (node.glyph.Code != "0FE38")) && (node.glyph.Code != "00332"))))))
            {
                this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                goto Label_1B94;
            }
            float single1 = node.box.Width;
            float single2 = node.box.Height;

            this.graphics_.SetClip(new Rectangle((int)tf1.X, ((int)tf1.Y) - 20, node.box.Width, node.box.Height + 40));
            try
            {
                PointF tf2;
                SizeF  ef1;
                if (node.glyph.Code == "0FE37")
                {
                    ef1 = this.graphics_.MeasureString("D", font1, tf1, this.typographicsFormat);
                    float single3 = ef1.Width;
                    ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                    float single4 = ef1.Width;
                    ef1 = this.graphics_.MeasureString("F", font1, tf1, this.typographicsFormat);
                    float single5 = ef1.Width;
                    ef1 = this.graphics_.MeasureString("C", font1, tf1, this.typographicsFormat);
                    float single6 = ef1.Width;
                    float single7 = 0f;
                    float single8 = 0f;
                    single8  = tf1.X;
                    single6 -= 2f;
                    this.graphics_.DrawString("D", font1, brush1, tf1, this.typographicsFormat);
                    tf2     = tf1;
                    tf2.X  += single3 - 2f;
                    single7 = single3 - 2f;
                    int num6 = ((int)(((single1 / 2f) - (single4 / 2f)) - single3)) + 4;
                    this.graphics_.SetClip(new Rectangle((int)tf2.X, ((int)tf2.Y) - 20, num6, node.box.Height + 40));
                    try
                    {
                        while (single7 < ((single1 / 2f) - (single4 / 2f)))
                        {
                            this.graphics_.DrawString("C", font1, brush1, tf2, this.typographicsFormat);
                            tf2.X   += single6;
                            single7 += single6;
                        }
                    }
                    catch
                    {
                    }
                    this.graphics_.ResetClip();
                    tf2     = tf1;
                    tf2.X  += ((single1 / 2f) + (single4 / 2f)) - 2f;
                    single7 = ((single1 / 2f) + (single4 / 2f)) - 2f;
                    this.graphics_.SetClip(new Rectangle((int)tf2.X, ((int)tf2.Y) - 20, num6, node.box.Height + 40));
                    try
                    {
                        while (single7 < (single1 - single5))
                        {
                            this.graphics_.DrawString("C", font1, brush1, tf2, this.typographicsFormat);
                            tf2.X   += single6;
                            single7 += single6;
                        }
                    }
                    catch
                    {
                    }
                    this.graphics_.ResetClip();
                    tf1.X = (single8 + (single1 / 2f)) - (single4 / 2f);
                    this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                    tf1.X = (single8 + single1) - single5;
                    this.graphics_.DrawString("F", font1, brush1, tf1, this.typographicsFormat);
                }
                else if (node.glyph.Code == "0FE38")
                {
                    ef1 = this.graphics_.MeasureString("?", font1, tf1, this.typographicsFormat);
                    float single9 = ef1.Width;
                    ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                    float single10 = ef1.Width;
                    ef1 = this.graphics_.MeasureString("A", font1, tf1, this.typographicsFormat);
                    float single11 = ef1.Width;
                    ef1 = this.graphics_.MeasureString("C", font1, tf1, this.typographicsFormat);
                    float single12 = ef1.Width;
                    float single13 = 0f;
                    float single14 = 0f;
                    single14  = tf1.X;
                    single12 -= 2f;
                    this.graphics_.DrawString("?", font1, brush1, tf1, this.typographicsFormat);
                    tf2      = tf1;
                    tf2.X   += single9 - 2f;
                    single13 = single9 - 2f;
                    int num7 = ((int)(((single1 / 2f) - (single10 / 2f)) - single9)) + 4;
                    this.graphics_.SetClip(new Rectangle((int)tf2.X, ((int)tf2.Y) - 20, num7, node.box.Height + 40));
                    try
                    {
                        while (single13 < ((single1 / 2f) - (single10 / 2f)))
                        {
                            this.graphics_.DrawString("C", font1, brush1, tf2, this.typographicsFormat);
                            tf2.X    += single12;
                            single13 += single12;
                        }
                    }
                    catch
                    {
                    }
                    this.graphics_.ResetClip();
                    tf2      = tf1;
                    tf2.X   += ((single1 / 2f) + (single10 / 2f)) - 2f;
                    single13 = ((single1 / 2f) + (single10 / 2f)) - 2f;
                    this.graphics_.SetClip(new Rectangle((int)tf2.X, ((int)tf2.Y) - 20, num7, node.box.Height + 40));
                    try
                    {
                        while (single13 < (single1 - single11))
                        {
                            this.graphics_.DrawString("C", font1, brush1, tf2, this.typographicsFormat);
                            tf2.X    += single12;
                            single13 += single12;
                        }
                    }
                    catch
                    {
                    }
                    this.graphics_.ResetClip();
                    tf1.X = (single14 + (single1 / 2f)) - (single10 / 2f);
                    this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                    tf1.X = (single14 + single1) - single11;
                    this.graphics_.DrawString("A", font1, brush1, tf1, this.typographicsFormat);
                }
                else if (node.glyph.Code == "021C4")
                {
                    ef1 = this.graphics_.MeasureString("&", font1, tf1, this.typographicsFormat);
                    float single15 = ef1.Width;
                    ef1 = this.graphics_.MeasureString("(", font1, tf1, this.typographicsFormat);
                    float single16 = ef1.Width;
                    ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                    float single17 = ef1.Width;
                    float single18 = 0f;
                    this.graphics_.DrawString("&", font1, brush1, tf1, this.typographicsFormat);
                    tf2    = tf1;
                    tf2.X += single15;
                    for (single18 = single15; single18 < (single1 - single17); single18 += single16)
                    {
                        this.graphics_.DrawString("(", font1, brush1, tf2, this.typographicsFormat);
                        tf2.X += single16;
                    }
                    tf1.X = (tf1.X + single1) - single17;
                    this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                }
                else if (node.glyph.Code == "021C6")
                {
                    ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                    float single19 = ef1.Width;
                    ef1 = this.graphics_.MeasureString("(", font1, tf1, this.typographicsFormat);
                    float single20 = ef1.Width;
                    ef1 = this.graphics_.MeasureString(",", font1, tf1, this.typographicsFormat);
                    float single21 = ef1.Width;
                    float single22 = 0f;
                    this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                    tf2    = tf1;
                    tf2.X += single19;
                    for (single22 = single19; single22 < (single1 - single21); single22 += single20)
                    {
                        this.graphics_.DrawString("(", font1, brush1, tf2, this.typographicsFormat);
                        tf2.X += single20;
                    }
                    tf1.X = (tf1.X + single1) - single21;
                    this.graphics_.DrawString(",", font1, brush1, tf1, this.typographicsFormat);
                }
                else if (node.glyph.Code == "021CC")
                {
                    ef1 = this.graphics_.MeasureString("2", font1, tf1, this.typographicsFormat);
                    float single23 = ef1.Width;
                    ef1 = this.graphics_.MeasureString("(", font1, tf1, this.typographicsFormat);
                    float single24 = ef1.Width;
                    ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                    float single25 = ef1.Width;
                    float single26 = 0f;
                    this.graphics_.DrawString("2", font1, brush1, tf1, this.typographicsFormat);
                    tf2    = tf1;
                    tf2.X += single23;
                    for (single26 = single23; single26 < (single1 - single25); single26 += single24)
                    {
                        this.graphics_.DrawString("(", font1, brush1, tf2, this.typographicsFormat);
                        tf2.X += single24;
                    }
                    tf1.X = (tf1.X + single1) - single25;
                    this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                }
                else if (node.glyph.Code == "021CB")
                {
                    ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                    float single27 = ef1.Width;
                    ef1 = this.graphics_.MeasureString("(", font1, tf1, this.typographicsFormat);
                    float single28 = ef1.Width;
                    ef1 = this.graphics_.MeasureString("3", font1, tf1, this.typographicsFormat);
                    float single29 = ef1.Width;
                    float single30 = 0f;
                    this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                    tf2    = tf1;
                    tf2.X += single27;
                    for (single30 = single27; single30 < (single1 - single29); single30 += single28)
                    {
                        this.graphics_.DrawString("(", font1, brush1, tf2, this.typographicsFormat);
                        tf2.X += single28;
                    }
                    tf1.X = (tf1.X + single1) - single29;
                    this.graphics_.DrawString("3", font1, brush1, tf1, this.typographicsFormat);
                }
                else if ((node.glyph.Code == "02192") || (node.glyph.Code == "0F577"))
                {
                    ef1 = this.graphics_.MeasureString("$", font1, tf1, this.typographicsFormat);
                    float single31 = ef1.Width;
                    ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                    float single32 = ef1.Width;
                    float single33 = 0f;
                    single31 -= 1f;
                    tf2       = tf1;
                    while (single33 < (single1 - single32))
                    {
                        this.graphics_.DrawString("$", font1, brush1, tf2, this.typographicsFormat);
                        tf2.X    += single31;
                        single33 += single31;
                    }
                    tf1.X = (tf1.X + single1) - single32;
                    this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                }
                else
                {
                    if (node.glyph.Code == "0005E")
                    {
                        tf2 = tf1;
                        try
                        {
                            ef1 = this.graphics_.MeasureString("m", font1, tf1, this.typographicsFormat);
                            float single34 = ef1.Width;
                            if (single1 > (single34 * 1.1))
                            {
                                float single35 = single1 / 2f;
                                single35 = (float)Math.Round((double)single35);
                                float single36 = single2 / 3f;
                                single36 = (float)Math.Round((double)single36);
                                if (single36 < 1f)
                                {
                                    single36 = 1f;
                                }
                                PointF       tf3   = new PointF(tf2.X, tf2.Y + single2);
                                PointF       tf4   = new PointF(tf2.X + single35, tf2.Y);
                                PointF       tf5   = new PointF(tf2.X + single1, tf2.Y + single2);
                                PointF       tf6   = new PointF(tf2.X + single35, tf2.Y + single36);
                                GraphicsPath path1 = new GraphicsPath();
                                path1.AddLine(tf3, tf4);
                                path1.AddLine(tf4, tf5);
                                path1.AddLine(tf5, tf6);
                                path1.AddLine(tf6, tf3);
                                this.graphics_.FillPath(brush1, path1);
                                goto Label_1B71;
                            }
                            this.graphics_.DrawString(text, font1, brush1, tf2, this.typographicsFormat);
                            goto Label_1B71;
                        }
                        catch
                        {
                            goto Label_1B71;
                        }
                    }
                    if (node.glyph.Code == "000AF")
                    {
                        ef1 = this.graphics_.MeasureString("$", font1, tf1, this.typographicsFormat);
                        float single37 = ef1.Width;
                        ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                        float single38 = ef1.Width;
                        float single39 = 0f;
                        tf2 = tf1;
                        while (single39 < (single1 - single38))
                        {
                            this.graphics_.DrawString("$", font1, brush1, tf2, this.typographicsFormat);
                            tf2.X    += single37;
                            single39 += single37;
                        }
                        tf1.X = (tf1.X + single1) - single38;
                        this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                    }
                    else if (node.glyph.Code == "00332")
                    {
                        ef1 = this.graphics_.MeasureString("$", font1, tf1, this.typographicsFormat);
                        float single40 = ef1.Width;
                        ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                        float single41 = ef1.Width;
                        float single42 = 0f;
                        tf2 = tf1;
                        while (single42 < (single1 - single41))
                        {
                            this.graphics_.DrawString("$", font1, brush1, tf2, this.typographicsFormat);
                            tf2.X    += single40;
                            single42 += single40;
                        }
                        tf1.X = (tf1.X + single1) - single41;
                        this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                    }
                    else if ((node.glyph.Code == "021C0") || (node.glyph.Code == "021C1"))
                    {
                        ef1 = this.graphics_.MeasureString("$", font1, tf1, this.typographicsFormat);
                        float single43 = ef1.Width;
                        ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                        float single44 = ef1.Width;
                        float single45 = 0f;
                        tf2 = tf1;
                        while (single45 < (single1 - single44))
                        {
                            this.graphics_.DrawString("$", font1, brush1, tf2, this.typographicsFormat);
                            tf2.X    += single43;
                            single45 += single43;
                        }
                        tf1.X = (tf1.X + single1) - single44;
                        this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                    }
                    else if ((node.glyph.Code == "021BC") || (node.glyph.Code == "021BD"))
                    {
                        ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                        float single46 = ef1.Width;
                        ef1 = this.graphics_.MeasureString("$", font1, tf1, this.typographicsFormat);
                        float single47 = ef1.Width;
                        float single48 = 0f;
                        this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                        tf2   = tf1;
                        tf2.X = (tf2.X + single1) - single47;
                        for (single48 = single1; single48 > single46; single48 -= single47)
                        {
                            this.graphics_.DrawString("$", font1, brush1, tf2, this.typographicsFormat);
                            tf2.X -= single47;
                        }
                    }
                    else if ((node.glyph.Code == "02190") || (node.glyph.Code == "0F576"))
                    {
                        ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                        float single49 = ef1.Width;
                        ef1 = this.graphics_.MeasureString("$", font1, tf1, this.typographicsFormat);
                        float single50 = ef1.Width;
                        float single51 = 0f;
                        this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                        single50 -= 1f;
                        tf2       = tf1;
                        tf2.X     = (tf2.X + single1) - single50;
                        for (single51 = single1; single51 > single49; single51 -= single50)
                        {
                            this.graphics_.DrawString("$", font1, brush1, tf2, this.typographicsFormat);
                            tf2.X -= single50;
                        }
                    }
                    else if ((node.glyph.Code == "0F578") || (node.glyph.Code == "02194"))
                    {
                        ef1 = this.graphics_.MeasureString("!", font1, tf1, this.typographicsFormat);
                        float single52 = ef1.Width;
                        ef1 = this.graphics_.MeasureString("$", font1, tf1, this.typographicsFormat);
                        float single53 = ef1.Width;
                        ef1 = this.graphics_.MeasureString(text, font1, tf1, this.typographicsFormat);
                        float single54 = ef1.Width;
                        float single55 = 0f;
                        this.graphics_.DrawString("!", font1, brush1, tf1, this.typographicsFormat);
                        single53 -= 1f;
                        single52 -= 1f;
                        tf2       = tf1;
                        tf2.X    += single52;
                        for (single55 = single52; single55 < (single1 - single54); single55 += single53)
                        {
                            this.graphics_.DrawString("$", font1, brush1, tf2, this.typographicsFormat);
                            tf2.X += single53;
                        }
                        tf1.X = (tf1.X + single1) - single54;
                        this.graphics_.DrawString(text, font1, brush1, tf1, this.typographicsFormat);
                    }
                }
            }
            catch
            {
            }
Label_1B71:
            this.graphics_.ResetClip();
Label_1B94:
            if (!node.IsUnderlined())
            {
                return;
            }
            int num8 = (int)this.Leading((float)node.box.Height, font1);

            this.graphics_.DrawLine(new Pen(brush1), this.oX + node.box.X, ((this.oY + node.box.Y) + node.box.Height) - (num8 / 2), (this.oX + node.box.X) + node.box.Width, ((this.oY + node.box.Y) + node.box.Height) - (num8 / 2));
        }
        /// <summary>
        /// Updates the line.
        /// </summary>
        /// <param name="_loc">The loc.</param>
        private void UpdateLine(Point _loc)
        {
            GraphicsPath path = new GraphicsPath();

            double m = 0f, angle = 0f, r = -10f, x = 0f, y = 0f;

            if ((endPoint.Y - startPoint.Y) == 0)
            {
                x = ((endPoint.X - startPoint.X) > 0) ? 2f : ((endPoint.X - startPoint.X) < 0) ? -2f : 0f;
            }

            if ((endPoint.X - startPoint.X) == 0)
            {
                y = ((endPoint.Y - startPoint.Y) > 0) ? 2f : ((endPoint.Y - startPoint.Y) < 0) ? -2f : 0f;
            }

            Point stPoint = startPoint;
            Point enPoint = endPoint;

            if ((endPoint.Y - startPoint.Y) != 0 && (endPoint.X - startPoint.X) != 0)
            {
                m     = ((double)endPoint.Y - startPoint.Y) / (endPoint.X - startPoint.X);
                angle = Math.Atan(m);
                x     = r * Math.Cos(angle);
                y     = r * Math.Sin(angle);
            }
            enPoint += new Size((int)x, (int)y);
            stPoint -= new Size((int)x, (int)y);
            path.AddLine(stPoint, enPoint);

            endPoint = _loc;

            stPoint = startPoint;
            enPoint = endPoint;

            if ((endPoint.Y - startPoint.Y) == 0)
            {
                x = ((endPoint.X - startPoint.X) > 0) ? 2f : ((endPoint.X - startPoint.X) < 0) ? -2f : 0f;
            }

            if ((endPoint.X - startPoint.X) == 0)
            {
                y = ((endPoint.Y - startPoint.Y) > 0) ? 2f : ((endPoint.Y - startPoint.Y) < 0) ? -2f : 0f;
            }

            if ((endPoint.Y - startPoint.Y) != 0 && (endPoint.X - startPoint.X) != 0)
            {
                m     = ((double)endPoint.Y - startPoint.Y) / (endPoint.X - startPoint.X);
                angle = Math.Atan(m);
                x     = r * Math.Cos(angle);
                y     = r * Math.Sin(angle);
            }

            enPoint += new Size((int)x, (int)y);
            stPoint -= new Size((int)x, (int)y);
            path.AddLine(stPoint, enPoint);

            Pen widenPen = new Pen(Color.Black, 3f);

            path.Widen(widenPen);
            widenPen.Dispose();

            Region rgn = new Region(path);

            Parent.Invalidate(rgn);
        } //Useless
예제 #34
0
        /// <summary>
        /// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
        /// </summary>
        /// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            var g = e.Graphics;

            g.SetGDIHigh();

            //玻璃管管
            GraphicsPath path = new GraphicsPath();

            path.AddLine(m_rectWorking.Left, m_rectWorking.Bottom, m_rectWorking.Left, m_rectWorking.Top + m_rectWorking.Width / 2);
            path.AddArc(new Rectangle(m_rectWorking.Left, m_rectWorking.Top, m_rectWorking.Width, m_rectWorking.Width), 180, 180);
            path.AddLine(m_rectWorking.Right, m_rectWorking.Top + m_rectWorking.Width / 2, m_rectWorking.Right, m_rectWorking.Bottom);
            path.CloseAllFigures();
            g.FillPath(new SolidBrush(glassTubeColor), path);

            //底部
            var rectDi = new Rectangle(this.Width / 2 - m_rectWorking.Width, m_rectWorking.Bottom - m_rectWorking.Width - 2, m_rectWorking.Width * 2, m_rectWorking.Width * 2);

            g.FillEllipse(new SolidBrush(glassTubeColor), rectDi);
            g.FillEllipse(new SolidBrush(mercuryColor), new Rectangle(rectDi.Left + 4, rectDi.Top + 4, rectDi.Width - 8, rectDi.Height - 8));

            //刻度
            decimal decSplit       = (maxValue - minValue) / splitCount;
            decimal decSplitHeight = m_rectLeft.Height / splitCount;

            for (int i = 0; i <= splitCount; i++)
            {
                g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Left + 2, (float)(m_rectLeft.Bottom - decSplitHeight * i)), new PointF(m_rectLeft.Right, (float)(m_rectLeft.Bottom - decSplitHeight * i)));

                var valueLeft = (minValue + decSplit * i).ToString("0.##");
                var sizeLeft  = g.MeasureString(valueLeft, Font);
                g.DrawString(valueLeft, Font, new SolidBrush(ForeColor), new PointF(m_rectLeft.Left, m_rectLeft.Bottom - (float)decSplitHeight * i - sizeLeft.Height - 1));

                if (rightTemperatureUnit != TemperatureUnit.None)
                {
                    g.DrawLine(new Pen(new SolidBrush(Color.Black), 1), new PointF(m_rectRight.Left + 2, (float)(m_rectRight.Bottom - decSplitHeight * i)), new PointF(m_rectRight.Right, (float)(m_rectRight.Bottom - decSplitHeight * i)));
                    var valueRight = GetRightValue(minValue + decSplit * i).ToString("0.##");
                    var sizeRight  = g.MeasureString(valueRight, Font);
                    g.DrawString(valueRight, Font, new SolidBrush(ForeColor), new PointF(m_rectRight.Right - sizeRight.Width - 1, m_rectRight.Bottom - (float)decSplitHeight * i - sizeRight.Height - 1));
                }
                if (i != splitCount)
                {
                    if (decSplitHeight > 40)
                    {
                        var decSp1 = decSplitHeight / 10;
                        for (int j = 1; j < 10; j++)
                        {
                            if (j == 5)
                            {
                                g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Right - 10, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectLeft.Right, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))));
                                if (rightTemperatureUnit != TemperatureUnit.None)
                                {
                                    g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectRight.Left + 10, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectRight.Left, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))));
                                }
                            }
                            else
                            {
                                g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Right - 5, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectLeft.Right, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))));
                                if (rightTemperatureUnit != TemperatureUnit.None)
                                {
                                    g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectRight.Left + 5, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectRight.Left, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))));
                                }
                            }
                        }
                    }
                    else if (decSplitHeight > 10)
                    {
                        g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Right - 5, (m_rectLeft.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2)), new PointF(m_rectLeft.Right, (m_rectLeft.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2)));
                        if (rightTemperatureUnit != TemperatureUnit.None)
                        {
                            g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectRight.Left + 5, (m_rectRight.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2)), new PointF(m_rectRight.Left, (m_rectRight.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2)));
                        }
                    }
                }
            }
            //单位
            string strLeftUnit = GetUnitChar(leftTemperatureUnit);

            g.DrawString(strLeftUnit, Font, new SolidBrush(ForeColor), new PointF(m_rectLeft.Left + 2, 2));
            if (rightTemperatureUnit != TemperatureUnit.None)
            {
                string strRightUnit = GetUnitChar(rightTemperatureUnit);
                var    rightSize    = g.MeasureString(strRightUnit, Font);
                g.DrawString(strRightUnit, Font, new SolidBrush(ForeColor), new PointF(m_rectRight.Right - 2 - rightSize.Width, 2));
            }
            //值
            float      fltHeightValue = (float)(Value / (maxValue - minValue) * m_rectLeft.Height);
            RectangleF rectValue      = new RectangleF(m_rectWorking.Left + 4, m_rectLeft.Top + (m_rectLeft.Height - fltHeightValue), m_rectWorking.Width - 8, fltHeightValue + (m_rectWorking.Height - m_rectWorking.Width / 2 - m_rectLeft.Height));

            g.FillRectangle(new SolidBrush(mercuryColor), rectValue);


            var sizeValue = g.MeasureString(m_value.ToString("0.##"), Font);

            g.DrawString(m_value.ToString("0.##"), Font, new SolidBrush(Color.White), new PointF(rectDi.Left + (rectDi.Width - sizeValue.Width) / 2, rectDi.Top + (rectDi.Height - sizeValue.Height) / 2 + 1));
        }
예제 #35
0
        /// <summary>
        /// 建立带有圆角样式的路径。
        /// </summary>
        /// <param name="rect">用来建立路径的矩形。</param>
        /// <param name="_radius">圆角的大小。</param>
        /// <param name="style">圆角的样式。</param>
        /// <param name="correction">是否把矩形长宽减 1,以便画出边框。</param>
        /// <returns>建立的路径。</returns>
        public static GraphicsPath CreatePath(Rectangle rect, int radius, RoundStyle style, bool correction)
        {
            GraphicsPath path             = new GraphicsPath();
            int          radiusCorrection = correction ? 1 : 0;

            switch (style)
            {
            case RoundStyle.None:
                path.AddRectangle(rect);
                break;

            case RoundStyle.All:
                path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
                path.AddArc(
                    rect.Right - radius - radiusCorrection,
                    rect.Y,
                    radius,
                    radius,
                    270,
                    90);
                path.AddArc(
                    rect.Right - radius - radiusCorrection,
                    rect.Bottom - radius - radiusCorrection,
                    radius,
                    radius, 0, 90);
                path.AddArc(
                    rect.X,
                    rect.Bottom - radius - radiusCorrection,
                    radius,
                    radius,
                    90,
                    90);
                break;

            case RoundStyle.Left:
                path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
                path.AddLine(
                    rect.Right - radiusCorrection, rect.Y,
                    rect.Right - radiusCorrection, rect.Bottom - radiusCorrection);
                path.AddArc(
                    rect.X,
                    rect.Bottom - radius - radiusCorrection,
                    radius,
                    radius,
                    90,
                    90);
                break;

            case RoundStyle.Right:
                path.AddArc(
                    rect.Right - radius - radiusCorrection,
                    rect.Y,
                    radius,
                    radius,
                    270,
                    90);
                path.AddArc(
                    rect.Right - radius - radiusCorrection,
                    rect.Bottom - radius - radiusCorrection,
                    radius,
                    radius,
                    0,
                    90);
                path.AddLine(rect.X, rect.Bottom - radiusCorrection, rect.X, rect.Y);
                break;

            case RoundStyle.Top:
                path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
                path.AddArc(
                    rect.Right - radius - radiusCorrection,
                    rect.Y,
                    radius,
                    radius,
                    270,
                    90);
                path.AddLine(
                    rect.Right - radiusCorrection, rect.Bottom - radiusCorrection,
                    rect.X, rect.Bottom - radiusCorrection);
                break;

            case RoundStyle.Bottom:
                path.AddArc(
                    rect.Right - radius - radiusCorrection,
                    rect.Bottom - radius - radiusCorrection,
                    radius,
                    radius,
                    0,
                    90);
                path.AddArc(
                    rect.X,
                    rect.Bottom - radius - radiusCorrection,
                    radius,
                    radius,
                    90,
                    90);
                path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y);
                break;

            case RoundStyle.BottomLeft:
                path.AddArc(
                    rect.X,
                    rect.Bottom - radius - radiusCorrection,
                    radius,
                    radius,
                    90,
                    90);
                path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y);
                path.AddLine(
                    rect.Right - radiusCorrection,
                    rect.Y,
                    rect.Right - radiusCorrection,
                    rect.Bottom - radiusCorrection);
                break;

            case RoundStyle.BottomRight:
                path.AddArc(
                    rect.Right - radius - radiusCorrection,
                    rect.Bottom - radius - radiusCorrection,
                    radius,
                    radius,
                    0,
                    90);
                path.AddLine(rect.X, rect.Bottom - radiusCorrection, rect.X, rect.Y);
                path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y);
                break;
            }
            path.CloseFigure();
            return(path);
        }
예제 #36
0
        // Snippet by RodStephens
        private GraphicsPath RoundedRect(RectangleF rect, float x_radius, float y_radius,
                                         bool round_upperLeft, bool round_upperRight,
                                         bool round_lowerRight, bool round_lowerLeft)
        {
            PointF point1, point2;
            var    path = new GraphicsPath();

            // Upper left corner
            if (round_upperLeft)
            {
                var corner = new RectangleF(rect.X, rect.Y, 2 * x_radius, 2 * y_radius);
                path.AddArc(corner, 180, 90);
                point1 = new PointF(rect.X + x_radius, rect.Y);
            }
            else
            {
                point1 = new PointF(rect.X, rect.Y);
            }

            // Top side
            if (round_upperRight)
            {
                point2 = new PointF(rect.Right - x_radius, rect.Y);
            }
            else
            {
                point2 = new PointF(rect.Right, rect.Y);
                path.AddLine(point1, point2);
            }

            // Upper right corner
            if (round_upperRight)
            {
                var corner = new RectangleF(rect.Right - 2 * x_radius, rect.Y, 2 * x_radius, 2 * y_radius);
                path.AddArc(corner, 270, 90);
                point1 = new PointF(rect.Right, rect.Y + y_radius);
            }
            else
            {
                point1 = new PointF(rect.Right, rect.Y);
            }

            // Right side
            if (round_lowerRight)
            {
                point2 = new PointF(rect.Right, rect.Bottom - y_radius);
            }
            else
            {
                point2 = new PointF(rect.Right, rect.Bottom);
                path.AddLine(point1, point2);
            }

            // Lower right corner
            if (round_lowerRight)
            {
                var corner = new RectangleF(rect.Right - 2 * x_radius, rect.Bottom - 2 * y_radius, 2 * x_radius, 2 * y_radius);
                path.AddArc(corner, 0, 90);
                point1 = new PointF(rect.Right - x_radius, rect.Bottom);
            }
            else
            {
                point1 = new PointF(rect.Right, rect.Bottom);
            }

            // Bottom side
            if (round_lowerLeft)
            {
                point2 = new PointF(rect.X + x_radius, rect.Bottom);
            }
            else
            {
                point2 = new PointF(rect.X, rect.Bottom);
                path.AddLine(point1, point2);
            }

            // Lower left corner
            if (round_lowerLeft)
            {
                var corner = new RectangleF(rect.X, rect.Bottom - 2 * y_radius, 2 * x_radius, 2 * y_radius);
                path.AddArc(corner, 90, 90);
                point1 = new PointF(rect.X, rect.Bottom - y_radius);
            }
            else
            {
                point1 = new PointF(rect.X, rect.Bottom);
            }

            // Left side
            if (round_upperLeft)
            {
                point2 = new PointF(rect.X, rect.Y + y_radius);
            }
            else
            {
                point2 = new PointF(rect.X, rect.Y);
                path.AddLine(point1, point2);
            }

            path.CloseFigure();
            return(path);
        }
예제 #37
0
        /// <summary>
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="bounds"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
        {
            if (Bars == null || ChartControl == null)
            {
                return;
            }

            // plot error if data not complete
            if (textBrush.Color != ChartControl.AxisColor || textFont != ChartControl.Font)
            {
                textBrush.Color = ChartControl.AxisColor;
                textFont        = ChartControl.Font;

                SizeF errorSize = graphics.MeasureString(errorData, textFont);
                errorTextWidth  = errorSize.Width + 5;
                errorTextHeight = errorSize.Height + 5;
            }

            if (priorDayHLC == HLCCalculationMode.CalcFromIntradayData)
            {
                DateTime lastBarDate = (Bars.Count == 0) ? Cbi.Globals.MaxDate : ChartControl.EquidistantBars ?
                                       Bars.GetTime(Math.Min(Bars.Count - 1, ChartControl.LastBarPainted)).Date
                                                                                : Bars.GetTime(Math.Min(Bars.Count - 1, Bars.GetBar(ChartControl.LastBarTimePainted))).Date;
                if ((lastBarDate == Cbi.Globals.MaxDate) ||
                    (Bars.BarsType.BuiltFrom == PeriodType.Minute &&
                     ((pivotRangeType == PivotRange.Monthly && Bars.Count > 0 && Bars.GetTime(0).AddSeconds(-1).Date >= new DateTime(lastBarDate.Year, lastBarDate.Month, 1).AddMonths(-1)) ||
                      (pivotRangeType == PivotRange.Weekly && Bars.Count > 0 && Bars.GetTime(0).AddSeconds(-1).Date >= lastBarDate.AddDays(-(((int)lastBarDate.DayOfWeek) + 1) % 7).AddDays(-7)) ||
                      (pivotRangeType == PivotRange.Daily && Bars.Count > 0 && Bars.GetTime(0).AddSeconds(-1).Date >= lastBarDate.AddDays(-1)))) ||
                    (Bars.BarsType.BuiltFrom != PeriodType.Minute &&
                     ((pivotRangeType == PivotRange.Monthly && Bars.Count > 0 && Bars.GetTime(0).Date >= new DateTime(lastBarDate.Year, lastBarDate.Month, 1).AddMonths(-1)) ||
                      (pivotRangeType == PivotRange.Weekly && Bars.Count > 0 && Bars.GetTime(0).Date >= lastBarDate.AddDays(-(((int)lastBarDate.DayOfWeek) + 1) % 7).AddDays(-7)) ||
                      (pivotRangeType == PivotRange.Daily && Bars.Count > 0 && Bars.GetTime(0).Date >= lastBarDate.AddDays(-1)))))
                {
                    graphics.DrawString(errorData, ChartControl.Font, textBrush, bounds.X + bounds.Width - errorTextWidth, bounds.Y + bounds.Height - errorTextHeight, stringFormatNear);
                }
            }
            else if (priorDayHLC == HLCCalculationMode.DailyBars && existsHistDailyData)
            {
                DateTime lastBarDate = (dailyBars.Count == 0) ? Cbi.Globals.MaxDate : ChartControl.EquidistantBars ?
                                       dailyBars.GetTime(Math.Min(dailyBars.Count - 1, ChartControl.LastBarPainted)).Date
                                        : dailyBars.GetTime(Math.Min(dailyBars.Count - 1, dailyBars.GetBar(ChartControl.LastBarTimePainted))).Date;
                if ((lastBarDate == Cbi.Globals.MaxDate) ||
                    (pivotRangeType == PivotRange.Monthly && dailyBars.GetTime(0).Date >= new DateTime(lastBarDate.Year, lastBarDate.Month, 1).AddMonths(-1)) ||
                    (pivotRangeType == PivotRange.Weekly && dailyBars.GetTime(0).Date >= lastBarDate.AddDays(-(((int)lastBarDate.DayOfWeek) + 1) % 7).AddDays(-7)) ||
                    (pivotRangeType == PivotRange.Daily && dailyBars.GetTime(0).Date >= lastBarDate.AddDays(-1)))
                {
                    graphics.DrawString(errorData, ChartControl.Font, textBrush, bounds.X + bounds.Width - errorTextWidth, bounds.Y + bounds.Height - errorTextHeight, stringFormatNear);
                }
            }

            float textHeight = ChartControl.Font.GetHeight();

            for (int seriesCount = 0; seriesCount < Values.Length; seriesCount++)
            {
                SolidBrush     brush = brushes[seriesCount];
                int            firstBarIdxToPaint = -1;
                int            lastX            = -1;
                int            lastY            = -1;
                SmoothingMode  oldSmoothingMode = graphics.SmoothingMode;
                Gui.Chart.Plot plot             = Plots[seriesCount];
                DataSeries     series           = (DataSeries)Values[seriesCount];

                for (int i = newSessionBarIdxArr.Count - 1; i >= 0; i--)
                {
                    int prevSessionBreakIdx = (int)newSessionBarIdxArr[i];
                    if (prevSessionBreakIdx <= this.LastBarIndexPainted)
                    {
                        firstBarIdxToPaint = prevSessionBreakIdx;
                        break;
                    }
                }

                using (GraphicsPath path = new GraphicsPath())
                {
                    if (brush.Color != plot.Pen.Color)
                    {
                        brush = new SolidBrush(plot.Pen.Color);
                    }

                    for (int idx = this.LastBarIndexPainted; idx >= Math.Max(this.FirstBarIndexPainted, this.LastBarIndexPainted - Width); idx--)
                    {
                        if (idx - Displacement < 0 || idx - Displacement >= Bars.Count || (!ChartControl.ShowBarsRequired && idx - Displacement < BarsRequired))
                        {
                            continue;
                        }
                        else if (!series.IsValidPlot(idx))
                        {
                            continue;
                        }

                        if (idx < firstBarIdxToPaint)
                        {
                            break;
                        }

                        double val = series.Get(idx);
                        int    x   = ChartControl.GetXByBarIdx(BarsArray[0], idx);
                        int    y   = ChartControl.GetYByValue(this, val);

                        if (lastX >= 0)
                        {
                            if (y != lastY)                             // Problem here is, that last bar of old day has date of new day
                            {
                                y = lastY;
                            }
                            path.AddLine(lastX - plot.Pen.Width / 2, lastY, x - plot.Pen.Width / 2, y);
                        }
                        lastX = x;
                        lastY = y;
                    }

                    graphics.SmoothingMode = SmoothingMode.AntiAlias;
                    graphics.DrawPath(plot.Pen, path);
                    graphics.SmoothingMode = oldSmoothingMode;
                    graphics.DrawString(plot.Name, ChartControl.Font, brush, lastX, lastY - textHeight / 2, stringFormatFar);
                }
            }
        }
예제 #38
0
        public static GraphicsPath Create(int x, int y, int width, int height,
                                          int radius, RectangleCorners corners)
        {
            int xw   = x + width;
            int yh   = y + height;
            int xwr  = xw - radius;
            int yhr  = yh - radius;
            int xr   = x + radius;
            int yr   = y + radius;
            int r2   = radius * 2;
            int xwr2 = xw - r2;
            int yhr2 = yh - r2;

            GraphicsPath p = new GraphicsPath();

            p.StartFigure();

            //Top Left Corner
            if ((RectangleCorners.TopLeft & corners) == RectangleCorners.TopLeft)
            {
                p.AddArc(x, y, r2, r2, 180, 90);
            }
            else
            {
                p.AddLine(x, yr, x, y);
                p.AddLine(x, y, xr, y);
            }

            //Top Edge
            p.AddLine(xr, y, xwr, y);

            //Top Right Corner
            if ((RectangleCorners.TopRight & corners) == RectangleCorners.TopRight)
            {
                p.AddArc(xwr2, y, r2, r2, 270, 90);
            }
            else
            {
                p.AddLine(xwr, y, xw, y);
                p.AddLine(xw, y, xw, yr);
            }

            //Right Edge
            p.AddLine(xw, yr, xw, yhr);

            //Bottom Right Corner
            if ((RectangleCorners.BottomRight & corners) == RectangleCorners.BottomRight)
            {
                p.AddArc(xwr2, yhr2, r2, r2, 0, 90);
            }
            else
            {
                p.AddLine(xw, yhr, xw, yh);
                p.AddLine(xw, yh, xwr, yh);
            }

            //Bottom Edge
            p.AddLine(xwr, yh, xr, yh);

            //Bottom Left Corner
            if ((RectangleCorners.BottomLeft & corners) == RectangleCorners.BottomLeft)
            {
                p.AddArc(x, yhr2, r2, r2, 90, 90);
            }
            else
            {
                p.AddLine(xr, yh, x, yh);
                p.AddLine(x, yh, x, yhr);
            }

            //Left Edge
            p.AddLine(x, yhr, x, yr);

            p.CloseFigure();
            return(p);
        }
예제 #39
0
        private static GraphicsPath GenerateRoundedRectangle(this Graphics graphics, RectangleF rectangle, float radius, RectangleEdgeFilter filter)
        {
            float        diameter;
            GraphicsPath path = new GraphicsPath();

            if (radius <= 0.0F || filter == RectangleEdgeFilter.None)
            {
                path.AddRectangle(rectangle);
                path.CloseFigure();
                return(path);
            }
            else
            {
                if (radius >= (Math.Min(rectangle.Width, rectangle.Height)) / 2.0)
                {
                    return(graphics.GenerateCapsule(rectangle));
                }

                diameter = radius * 2.0F;
                SizeF      sizeF = new SizeF(diameter, diameter);
                RectangleF arc   = new RectangleF(rectangle.Location, sizeF);
                if ((RectangleEdgeFilter.TopLeft & filter) == RectangleEdgeFilter.TopLeft)
                {
                    path.AddArc(arc, 180, 90);
                }
                else
                {
                    path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y);
                    path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y);
                }
                arc.X = rectangle.Right - diameter;
                if ((RectangleEdgeFilter.TopRight & filter) == RectangleEdgeFilter.TopRight)
                {
                    path.AddArc(arc, 270, 90);
                }
                else
                {
                    path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y);
                    path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X + arc.Width, arc.Y);
                }
                arc.Y = rectangle.Bottom - diameter;
                if ((RectangleEdgeFilter.BottomRight & filter) == RectangleEdgeFilter.BottomRight)
                {
                    path.AddArc(arc, 0, 90);
                }
                else
                {
                    path.AddLine(arc.X + arc.Width, arc.Y, arc.X + arc.Width, arc.Y + arc.Height);
                    path.AddLine(arc.X, arc.Y + arc.Height, arc.X + arc.Width, arc.Y + arc.Height);
                }
                arc.X = rectangle.Left;
                if ((RectangleEdgeFilter.BottomLeft & filter) == RectangleEdgeFilter.BottomLeft)
                {
                    path.AddArc(arc, 90, 90);
                }
                else
                {
                    path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X, arc.Y + arc.Height);
                    path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y);
                }
                path.CloseFigure();
            }
            return(path);
        }
예제 #40
0
	public static void Main () 
	{

		Bitmap bmp = new Bitmap (600, 300);
		Graphics dc = Graphics.FromImage (bmp);        		
		Font fnt = new Font ("Arial", 8);
		Font fnttitle = new Font ("Arial", 8, FontStyle.Underline);
		Matrix matrix = new Matrix ();		
		GraphicsPath patha = new GraphicsPath ();
		GraphicsPath pathb = new GraphicsPath ();
		Pen redPen = new Pen (Color.Red, 2);		
		Region rgn1;
		Region rgn2;		
		int x = 0;		
		
		SolidBrush whiteBrush = new SolidBrush (Color.White);				
		
		dc.DrawString ("Region samples using GraphicsPath", fnttitle, whiteBrush, 5, 5);				
		
		/* First*/		
		patha.AddLine (60, 40, 90, 90);
		patha.AddLine (90, 90, 10, 90);
		patha.AddLine (10, 90, 60, 40);			
		dc.DrawPath (redPen, patha);		
				
		pathb.AddEllipse(30, 55, 60, 60);
		dc.DrawPath(redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Complement (rgn2);
		dc.FillRegion (Brushes.Blue, rgn1);			
		dc.DrawString ("Complement (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 140);	
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
		x += 110;
		
		/* Second*/		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
		patha.AddLine (90+x, 90, 10+x, 90);
		patha.AddLine (10+x, 90, 60+x, 40);					
		
		dc.DrawPath (redPen, patha);						
				
		pathb.AddEllipse (30+x, 55, 60, 60);						
		dc.DrawPath(redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Exclude (rgn2);
		dc.FillRegion (Brushes.Blue, rgn1);				
		dc.DrawString ("Exclude ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 140, 140);	
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
		x += 110;
		
		/* Third*/		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
		patha.AddLine (90+x, 90, 10+x, 90);
		patha.AddLine (10+x, 90, 60+x, 40);			
		
		dc.DrawPath (redPen, patha);		
				
		pathb.AddEllipse (30+x, 55, 60, 60);
		dc.DrawPath (redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Intersect (rgn2);
		dc.FillRegion (Brushes.Blue, rgn1);		
		dc.DrawString ("Intersect ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 270, 140);		
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));	
		x += 110;
		
		/* Four*/		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
		patha.AddLine (90+x, 90, 10+x, 90);
		patha.AddLine (10+x, 90, 60+x, 40);			
		
		dc.DrawPath (redPen, patha);		
				
		pathb.AddEllipse (30+x, 55, 60, 60);
		dc.DrawPath (redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Xor (rgn2);
		dc.FillRegion(Brushes.Blue, rgn1);		
		dc.DrawString ("Xor ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 380, 140);		
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));	
		x += 110;	
		
		/* Fifth */		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
		patha.AddLine (90+x, 90, 10+x, 90);
		patha.AddLine (10+x, 90, 60+x, 40);			
		
		dc.DrawPath (redPen, patha);		
				
		pathb.AddEllipse (30+x, 55, 60, 60);
		dc.DrawPath (redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Union (rgn2);
		dc.FillRegion(Brushes.Blue, rgn1);		
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
		dc.DrawString ("Union (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 490, 140);							
		
        	bmp.Save("regionsgp.bmp", ImageFormat.Bmp);				
	}	
예제 #41
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            //base.OnPaint(pevent);

            if (inOnPaint)
            {
                return;
            }

            inOnPaint = true;

            try
            {
                Graphics gr = pevent.Graphics;

                gr.Clear(this.BackColor);

                gr.SmoothingMode = SmoothingMode.AntiAlias;

                Rectangle outside = new Rectangle(0, 0, this.Width, this.Height);

                LinearGradientBrush linear = new LinearGradientBrush(outside, BGGradTop, BGGradBot, LinearGradientMode.Vertical);

                Pen mypen = new Pen(Outline, 1);

                GraphicsPath outline = new GraphicsPath();

                float wid = this.Height / 3f;

                wid = 1;

                int width  = this.Width - 1;
                int height = this.Height - 1;

                // tl
                outline.AddArc(0, 0, wid, wid, 180, 90);
                // top line
                outline.AddLine(wid, 0, width - wid, 0);
                // tr
                outline.AddArc(width - wid, 0, wid, wid, 270, 90);
                // br
                outline.AddArc(width - wid, height - wid, wid, wid, 0, 90);
                // bottom line
                outline.AddLine(wid, height, width - wid, height);
                // bl
                outline.AddArc(0, height - wid, wid, wid, 90, 90);
                // left line
                outline.AddLine(0, height - wid, 0, wid - wid / 2);


                gr.FillPath(linear, outline);

                gr.DrawPath(mypen, outline);

                SolidBrush mybrush = new SolidBrush(TextColor);

                if (_mouseover)
                {
                    SolidBrush brush = new SolidBrush(ColorMouseOver);

                    gr.FillPath(brush, outline);
                }
                if (_mousedown)
                {
                    SolidBrush brush = new SolidBrush(ColorMouseDown);

                    gr.FillPath(brush, outline);
                }

                if (!this.Enabled)
                {
                    SolidBrush brush = new SolidBrush(_ColorNotEnabled);

                    gr.FillPath(brush, outline);
                }


                StringFormat stringFormat = new StringFormat();
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Center;

                string display = this.Text;
                int    amppos  = display.IndexOf('&');
                if (amppos != -1)
                {
                    display = display.Remove(amppos, 1);
                }

                gr.DrawString(display, this.Font, mybrush, outside, stringFormat);
            }
            catch { }

            inOnPaint = false;
        }
예제 #42
0
 private GraphicsPath RoundRect(RectangleF r, float r1, float r2, float r3, float r4)
 {
     float x = r.X, y = r.Y, w = r.Width, h = r.Height;
     GraphicsPath rr = new GraphicsPath();
     rr.AddBezier(x, y + r1, x, y, x + r1, y, x + r1, y);
     rr.AddLine(x + r1, y, x + w - r2, y);
     rr.AddBezier(x + w - r2, y, x + w, y, x + w, y + r2, x + w, y + r2);
     rr.AddLine(x + w, y + r2, x + w, y + h - r3);
     rr.AddBezier(x + w, y + h - r3, x + w, y + h, x + w - r3, y + h, x + w - r3, y + h);
     rr.AddLine(x + w - r3, y + h, x + r4, y + h);
     rr.AddBezier(x + r4, y + h, x, y + h, x, y + h - r4, x, y + h - r4);
     rr.AddLine(x, y + h - r4, x, y + r1);
     return rr;
 }
예제 #43
0
        private static GraphicsPath CreateRoundRectangle(Rectangle rectangle, int radius, RoundCornerStyle rcStyle)
        {
            GraphicsPath path = new GraphicsPath();

            int l = rectangle.Left;
            int t = rectangle.Top;
            int w = rectangle.Width;
            int h = rectangle.Height;

            if (radius <= 0)
            {
                path.AddLine(l, t, l + w, t);         // top
                path.AddLine(l + w, t, l + w, t + h); // right
                path.AddLine(l + w, t + h, l, t + h); // bottom
                path.AddLine(l, t + h, l, t);         // left
            }
            else
            {
                int d = radius << 1;

                int lefttop_eff  = 0;
                int leftbtm_eff  = 0;
                int righttop_eff = 0;
                int rightbtm_eff = 0;
                int topleft_eff  = 0;
                int topright_eff = 0;
                int btmleft_eff  = 0;
                int btmright_eff = 0;

                if ((rcStyle & RoundCornerStyle.LeftTop) == RoundCornerStyle.LeftTop)
                {
                    lefttop_eff = radius;
                    topleft_eff = radius;
                }

                if ((rcStyle & RoundCornerStyle.RightTop) == RoundCornerStyle.RightTop)
                {
                    righttop_eff = radius;
                    topright_eff = radius;
                }

                if ((rcStyle & RoundCornerStyle.RightBottom) == RoundCornerStyle.RightBottom)
                {
                    btmright_eff = radius;
                    rightbtm_eff = radius;
                }

                if ((rcStyle & RoundCornerStyle.LeftBottom) == RoundCornerStyle.LeftBottom)
                {
                    leftbtm_eff = radius;
                    btmleft_eff = radius;
                }

                if ((rcStyle & RoundCornerStyle.LeftTop) == RoundCornerStyle.LeftTop)
                {
                    path.AddArc(l, t, d, d, 180, 90);                      // topleft
                }
                path.AddLine(l + lefttop_eff, t, l + w - righttop_eff, t); // top
                if ((rcStyle & RoundCornerStyle.RightTop) == RoundCornerStyle.RightTop)
                {
                    path.AddArc(l + w - d, t, d, d, 270, 90);                       // topright
                }
                path.AddLine(l + w, t + topright_eff, l + w, t + h - btmright_eff); // right
                if ((rcStyle & RoundCornerStyle.RightBottom) == RoundCornerStyle.RightBottom)
                {
                    path.AddArc(l + w - d, t + h - d, d, d, 0, 90);                // bottomright
                }
                path.AddLine(l + w - rightbtm_eff, t + h, l + leftbtm_eff, t + h); // bottom
                if ((rcStyle & RoundCornerStyle.LeftBottom) == RoundCornerStyle.LeftBottom)
                {
                    path.AddArc(l, t + h - d, d, d, 90, 90);              // bottomleft
                }
                path.AddLine(l, t + h - btmleft_eff, l, t + topleft_eff); // left
            }

            path.CloseFigure();
            return(path);
        }
예제 #44
0
    // REAL MAGIC HERE! y- B-
    private void DrawData(Graphics g, float Xunit, float Yunit,int xstart )
    {
        PeptideMW PMW = new PeptideMW(PeptideSequence);
        float[] Bs = PMW.GetPepFragmentBValues();
        float[] Ys = PMW.GetPepFragmentYValues();
        bool bPhos = PMW.IsPhosphorylation();
        int Count = SpectrumData.Count;
        int i = 0;
        for (i = 0; i < Count; i++)
        {

            float mz = ((MZintensitiy )SpectrumData[i]).mz ;
            float intensity = ((MZintensitiy )SpectrumData[i]).intensity  ;

            float x = (mz - xstart)*Xunit + NETAREALEFTMARGIN ;
            float y;

            if (bZoomOut)
            {
                if (intensity * 100 / MaxIntensitiy > DisplayMaxY)
                {
                    y = NETAREATOPMARGIN ;
                }
                else
                {
                    y = HEIGHT - NETAREABOTTOMMARGIN - intensity * 100 * Yunit / MaxIntensitiy;
                }

            }
            else
                y = HEIGHT - NETAREABOTTOMMARGIN - intensity * 100 * Yunit / MaxIntensitiy;

            Pen dataPen  = new Pen (Brushes.Black ,1);
            Pen BLinePen = new Pen(Brushes.Blue, 2);
            Pen YLinePen = new Pen(Brushes.Red, 2);
            Pen ALinePen = new Pen (Brushes.Green ,2);
            Pen MLinePen = new Pen(Brushes.Gray , 2);
            Font Numberfont = new Font("Arial", 9, FontStyle.Regular);
              if (y < HEIGHT - NETAREABOTTOMMARGIN -20  && bShowLabel )
              {
                  string strAnn = GetAnnotation(SpectrumData,i, Bs, Ys,PrecursorMZ,int.Parse (ChargeState ),bPhos );
                  if (strAnn.StartsWith("(b"))
                  {
                      g.DrawLine(BLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
                      g.DrawString(strAnn, Numberfont, Brushes.Blue , new PointF(x, y));
                  }
                  else if (strAnn.StartsWith("(y"))
                  {
                      g.DrawLine(YLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
                      g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y));
                  }
                  else if (strAnn.StartsWith("(a"))
                  {
                      g.DrawLine(ALinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
                      g.DrawString(strAnn, Numberfont, Brushes.Green, new PointF(x, y));
                  }
                  else if (strAnn.StartsWith("(M") && y < HEIGHT - NETAREABOTTOMMARGIN -100)
                  {
                      g.DrawLine(MLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
                      g.DrawString(strAnn, Numberfont, Brushes.Gray  , new PointF(x, y));
                  }
                  else
                  {
                      g.DrawLine(dataPen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
                  }
                  //g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y));
              }
              else
                  g.DrawLine(dataPen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);

            if (intensity == MaxIntensitiy)
            {
             //peak value point
                GraphicsPath p = new GraphicsPath();
                p.AddLine(x, (float)HEIGHT - NETAREABOTTOMMARGIN, x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength);
                p.AddLine(x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength, x - XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength);
                p.CloseFigure();
                g.FillPath(Brushes.Red, p);

                 g.DrawString(mz.ToString(), Numberfont, Brushes.Red, x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN);
            }

        }
    }
예제 #45
0
        private GraphicsPath MakeRoundedRect(
            RectangleF rect, float xradius, float yradius,
            bool round_ul, bool round_ur, bool round_lr, bool round_ll)
        {
            // Make a GraphicsPath to draw the rectangle.
            PointF       point1, point2;
            GraphicsPath path = new GraphicsPath();

            // Upper left corner.
            if (round_ul)
            {
                RectangleF corner = new RectangleF(
                    rect.X, rect.Y,
                    2 * xradius, 2 * yradius);
                path.AddArc(corner, 180, 90);
                point1 = new PointF(rect.X + xradius, rect.Y);
            }
            else
            {
                point1 = new PointF(rect.X, rect.Y);
            }

            // Top side.
            if (round_ur)
            {
                point2 = new PointF(rect.Right - xradius, rect.Y);
            }
            else
            {
                point2 = new PointF(rect.Right, rect.Y);
            }
            path.AddLine(point1, point2);

            // Upper right corner.
            if (round_ur)
            {
                RectangleF corner = new RectangleF(
                    rect.Right - 2 * xradius, rect.Y,
                    2 * xradius, 2 * yradius);
                path.AddArc(corner, 270, 90);
                point1 = new PointF(rect.Right, rect.Y + yradius);
            }
            else
            {
                point1 = new PointF(rect.Right, rect.Y);
            }

            // Right side.
            if (round_lr)
            {
                point2 = new PointF(rect.Right, rect.Bottom - yradius);
            }
            else
            {
                point2 = new PointF(rect.Right, rect.Bottom);
            }
            path.AddLine(point1, point2);

            // Lower right corner.
            if (round_lr)
            {
                RectangleF corner = new RectangleF(
                    rect.Right - 2 * xradius,
                    rect.Bottom - 2 * yradius,
                    2 * xradius, 2 * yradius);
                path.AddArc(corner, 0, 90);
                point1 = new PointF(rect.Right - xradius, rect.Bottom);
            }
            else
            {
                point1 = new PointF(rect.Right, rect.Bottom);
            }

            // Bottom side.
            if (round_ll)
            {
                point2 = new PointF(rect.X + xradius, rect.Bottom);
            }
            else
            {
                point2 = new PointF(rect.X, rect.Bottom);
            }
            path.AddLine(point1, point2);

            // Lower left corner.
            if (round_ll)
            {
                RectangleF corner = new RectangleF(
                    rect.X, rect.Bottom - 2 * yradius,
                    2 * xradius, 2 * yradius);
                path.AddArc(corner, 90, 90);
                point1 = new PointF(rect.X, rect.Bottom - yradius);
            }
            else
            {
                point1 = new PointF(rect.X, rect.Bottom);
            }

            // Left side.
            if (round_ul)
            {
                point2 = new PointF(rect.X, rect.Y + yradius);
            }
            else
            {
                point2 = new PointF(rect.X, rect.Y);
            }
            path.AddLine(point1, point2);

            // Join with the start point.
            path.CloseFigure();

            return(path);
        }
            private Region CreateRoundedRectangleRegion(int radius, Rectangle rectangle)
            {
                using (GraphicsPath Path = new GraphicsPath())
                {
                    int Radius2 = (radius * 2);

                    Path.FillMode = FillMode.Winding;

                    Path.StartFigure();
                    Path.AddArc(rectangle.X, rectangle.Y, Radius2, Radius2, 180, 90);
                    Path.AddLine(rectangle.X + radius, rectangle.Y, rectangle.Right - radius, rectangle.Y);
                    Path.AddArc(rectangle.Right - Radius2 - 1, rectangle.Y, Radius2, Radius2, 270, 90);
                    Path.AddLine(rectangle.Right, rectangle.Y + radius, rectangle.Right, rectangle.Bottom - radius);
                    Path.AddArc(rectangle.Right - Radius2 - 1, rectangle.Bottom - Radius2 - 1, Radius2, Radius2, 0, 90);
                    Path.AddLine(rectangle.Right - radius, rectangle.Bottom, rectangle.X + radius, rectangle.Bottom);
                    Path.AddArc(rectangle.X, rectangle.Bottom - Radius2 - 1, Radius2, Radius2, 90, 90);
                    Path.AddLine(rectangle.X, rectangle.Bottom - radius, rectangle.X, rectangle.Y + radius);
                    Path.CloseFigure();

                    return new Region(Path);
                }
            }
예제 #47
0
        private void DrawGlowingNeedle(Dictionary <float, float> angleLut, float value, Color bOut, Color bGlow, Color bIn, Graphics g)
        {
            var angleStart = angleLut.Values.FirstOrDefault();

            var angleSweep = float.MaxValue;

            if (value < 0)
            {
                value = 0;
            }

            var lastK = 0.0f;
            var lastV = 0.0f;

            foreach (var kvp in angleLut)
            {
                if (kvp.Key >= value)
                {
                    var d    = kvp.Key - lastK;
                    var s    = kvp.Value - lastV;
                    var duty = (value - lastK) / d;

                    angleSweep = s * duty + lastV;
                    break;
                }
                else
                {
                    lastK = kvp.Key;
                    lastV = kvp.Value;
                }
            }
            if (float.IsNaN(angleSweep))
            {
                angleSweep = angleStart;
            }
            if (float.MaxValue == angleSweep)
            {
                angleSweep = angleLut.Values.LastOrDefault();
            }

            angleSweep -= angleStart;
            if (Math.Abs(angleSweep) < 0.1f)
            {
                angleSweep = 0.1f;
            }

            var angleEnd = angleStart + angleSweep;
            //angleSweep = 360;
            var finalRadius = 503 / 2 - 24 / 2; // outer radius of blue blob (-width of blob)
            var outerRadius = 456 / 2;          // outer radius of glow
            var innerRadius = outerRadius - 30; // inner radius of glow
            var endRadius   = 296 / 2;          // radius of inner part

            innerRadius = 1;

            var dialX = 700;
            var dialY = 284;

            GraphicsPath path        = new GraphicsPath();
            Point        centerPoint = new Point(dialX, dialY);

            path.AddLine(this.DistanceFromCenter(centerPoint, innerRadius, angleStart), this.DistanceFromCenter(centerPoint, outerRadius, angleStart));
            path.AddArc(new RectangleF(centerPoint.X - (float)outerRadius, centerPoint.Y - (float)outerRadius, (float)outerRadius * 2, (float)outerRadius * 2), angleStart, angleSweep);
            path.AddLine(this.DistanceFromCenter(centerPoint, outerRadius, angleEnd), this.DistanceFromCenter(centerPoint, innerRadius, angleEnd));
            path.AddArc(new RectangleF(centerPoint.X - (float)innerRadius, centerPoint.Y - (float)innerRadius, (float)innerRadius * 2, (float)innerRadius * 2), angleEnd, -angleSweep);

            Blend blend = new Blend();

            // Create point and positions arrays
            float[] factArray = { 0.1f, 1.0f, 1.0f };
            float[] posArray  = { 0.0f, 0.225f, 1.0f };
            // Set Factors and Positions properties of Blend
            blend.Factors   = factArray;
            blend.Positions = posArray;

            PathGradientBrush pthGrBrush = new PathGradientBrush(path);

            pthGrBrush.Blend = blend;

            pthGrBrush.CenterColor = bIn;
            pthGrBrush.CenterPoint = centerPoint;

            Color[] colors = { bGlow, bGlow, bGlow, bGlow };
            pthGrBrush.SurroundColors = colors;

            g.FillPath(pthGrBrush, path);

            var p = new Pen(bOut, 22.0f);

            g.DrawArc(p, centerPoint.X - finalRadius, centerPoint.Y - finalRadius, finalRadius * 2, finalRadius * 2, angleStart, angleSweep);
            g.DrawLine(new Pen(bOut, 5.0f), this.DistanceFromCenter(centerPoint, finalRadius + 11, angleEnd), DistanceFromCenter(centerPoint, endRadius, angleEnd));
        }
예제 #48
0
    protected override void OnPaint(PaintEventArgs e)
    {
        var g = e.Graphics;

        g.Clear(Color.White);

        using (var dataPointPath = new GraphicsPath())
        using (var gridPen = new Pen(Color.FromArgb(20, Color.Black)))
        using (var dashPen = new Pen(MainColor) { DashStyle = DashStyle.Dash })
        using (var borderPen = new Pen(MainColor))
        using (var fillBrush = new SolidBrush(Color.FromArgb(35, MainColor)))
        using (var textBrush = new SolidBrush(MainColor))
        {
            if (DataPoints.Count > 1)
            {
                var infoRect = new Rectangle();
                var highlightRect = new RectangleF();
                var infoString = string.Empty;

                dataPointPath.AddLine(Width + 10, Height + 10, Width + 10, Height + 10);

                var offset = 0;

                for (var i = DataPoints.Count - 1; i >= 1; i--)
                {
                    if (DataPoints[i].Index % LineDensity == 0)
                        g.DrawLine(gridPen, Width - offset, 0, Width - offset, Height);

                    var scaledY = GetScaledPoint(DataPoints[i].Value);

                    dataPointPath.AddLine(Width - offset, scaledY, Width - offset - PointDensity,
                        GetScaledPoint(DataPoints[i - 1].Value));

                    if (HighlightPoint && new Rectangle(Width - offset - (PointDensity / 2), 0, PointDensity, Height).Contains(MouseLocation))
                    {
                        g.DrawLine(gridPen, 0, scaledY, Width, scaledY);

                        highlightRect = new RectangleF(Width - offset - 3, scaledY - 3, 6, 6);

                        infoString = DataPoints[i].Value.ToString(CultureInfo.InvariantCulture);
                        var infoStringSize = TextRenderer.MeasureText(infoString, Font);

                        infoRect = new Rectangle
                        {
                            Height = infoStringSize.Height + 2,
                            Width = infoStringSize.Width + 5
                        };

                        if (offset < infoStringSize.Width + 10)
                            infoRect.X = Width - offset - infoStringSize.Width - 10;
                        else
                            infoRect.X = Width - offset + 5;

                        if (scaledY > Height - infoStringSize.Height - 5)
                            infoRect.Y = (int)scaledY - infoStringSize.Height - 5;
                        else
                            infoRect.Y = (int)scaledY + 5;
                    }

                    offset += PointDensity;
                }

                dataPointPath.AddLine(-10, Height + 10, -10, Height + 10);

                dataPointPath.CloseFigure();

                g.SmoothingMode = SmoothingMode.AntiAlias;

                g.FillPath(fillBrush, dataPointPath);
                g.DrawPath(borderPen, dataPointPath);

                g.SmoothingMode = SmoothingMode.None;

                if (ShowAverage)
                {
                    var average = GetScaledPoint(GetAverage());
                    g.DrawLine(dashPen, 0, average, Width, average);
                    g.FillRectangle(fillBrush, 0, average, Width, Height - average);
                }

                if (HighlightPoint)
                {
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    g.FillEllipse(Brushes.White, highlightRect);
                    g.DrawEllipse(borderPen, highlightRect);

                    g.SmoothingMode = SmoothingMode.None;

                    g.FillRectangle(Brushes.White, infoRect);
                    g.DrawRectangle(borderPen, infoRect);
                    g.DrawString(infoString, HighlightFont, textBrush, infoRect.X + 4, infoRect.Y + 1);
                }
            }

            g.DrawRectangle(borderPen, new Rectangle(0, 0, Width - 1, Height - 1));
        }
    }
예제 #49
0
        private static void drawHeader(Bitmap myBitmap, JToken myBundle)
        {
            bool   isSXBanner        = false;
            string bundleDisplayName = BundleInfos.getBundleDisplayName(myItem);
            string lastFolder        = BundleInfos.getLastFolder(BundlePath);

            JToken displayStyle = myBundle["DisplayStyle"];

            if (displayStyle != null)
            {
                if (Settings.Default.isChallengesTheme)
                {
                    string[] colorParts = Settings.Default.challengesColors.Split(',');
                    headerColor = Color.FromArgb(255, Int32.Parse(colorParts[0]), Int32.Parse(colorParts[1]), Int32.Parse(colorParts[2]));
                }
                else
                {
                    headerColor = BundleInfos.getSecondaryColor(myBundle);
                }

                JToken customBackground = displayStyle["CustomBackground"];
                JToken displayImage     = displayStyle["DisplayImage"];
                if (customBackground != null)
                {
                    JToken assetPathName = customBackground["asset_path_name"];
                    if (assetPathName != null)
                    {
                        if (assetPathName.Value <string>().Contains("/Game/Athena/UI/Challenges/Art/MissionTileImages/") && !ThePak.CurrentUsedItem.Equals("QuestBundle_S10_SeasonX"))
                        {
                            isSXBanner = true;
                            string textureFile   = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));
                            Image  challengeIcon = Resources.unknown512;
                            string textureAsset  = JohnWick.AssetToTexture2D(textureFile);;
                            if (!string.IsNullOrEmpty(textureAsset))
                            {
                                using (var bmpTemp = new Bitmap(textureAsset))
                                {
                                    challengeIcon = new Bitmap(bmpTemp);
                                }
                            }

                            toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                            if (Settings.Default.isChallengesTheme && File.Exists(Settings.Default.challengesBannerFileName))
                            {
                                Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                                var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                                toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                            }
                            else
                            {
                                var opacityImage = ImageUtilities.SetImageOpacity(challengeIcon, (float)0.3);
                                toDrawOn.DrawImage(opacityImage, new Point(0, 0));
                            }
                        }
                    }
                }
                if (!isSXBanner)
                {
                    if (displayImage != null)
                    {
                        JToken assetPathName = displayImage["asset_path_name"];
                        if (assetPathName != null)
                        {
                            string textureFile   = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));
                            Image  challengeIcon = Resources.unknown512;
                            string textureAsset  = JohnWick.AssetToTexture2D(textureFile);
                            if (!string.IsNullOrEmpty(textureAsset))
                            {
                                using (var bmpTemp = new Bitmap(textureAsset))
                                {
                                    challengeIcon = new Bitmap(bmpTemp);
                                }
                            }

                            toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                            if (Settings.Default.isChallengesTheme)
                            {
                                if (File.Exists(Settings.Default.challengesBannerFileName))
                                {
                                    Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                                    var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                                    toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                                }
                            }

                            toDrawOn.DrawImage(ImageUtilities.ResizeImage(challengeIcon, 256, 256), new Point(0, 0));
                        }
                    }
                    else
                    {
                        toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                        if (Settings.Default.isChallengesTheme)
                        {
                            if (File.Exists(Settings.Default.challengesBannerFileName))
                            {
                                Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                                var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                                toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                            }
                        }
                    }
                }
            }
            else
            {
                if (Settings.Default.isChallengesTheme)
                {
                    string[] colorParts = Settings.Default.challengesColors.Split(',');
                    headerColor = Color.FromArgb(255, Int32.Parse(colorParts[0]), Int32.Parse(colorParts[1]), Int32.Parse(colorParts[2]));
                }
                else
                {
                    headerColor = getRandomColor();
                }

                toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                if (Settings.Default.isChallengesTheme)
                {
                    if (File.Exists(Settings.Default.challengesBannerFileName))
                    {
                        Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                        var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                        toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                    }
                }
            }

            GraphicsPath gp = new GraphicsPath();

            gp.StartFigure();
            gp.AddLine(0, 256, myBitmap.Width, 256);
            gp.AddLine(myBitmap.Width, 256, myBitmap.Width, 241);
            gp.AddLine(myBitmap.Width, 241, myBitmap.Width / 2 + 25, 236);
            gp.AddLine(myBitmap.Width / 2 + 25, 236, myBitmap.Width / 2 + 35, 249);
            gp.AddLine(myBitmap.Width / 2 + 35, 249, 0, 241);
            gp.CloseFigure();
            toDrawOn.FillPath(new SolidBrush(ControlPaint.Light(headerColor)), gp);

            GraphicsPath p     = new GraphicsPath();
            Pen          myPen = new Pen(ControlPaint.Light(headerColor, (float)0.2), 3);

            myPen.LineJoin = LineJoin.Round; //needed to avoid spikes
            p.AddString(
                lastFolder,
                Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[1],
                (int)FontStyle.Regular, 30,
                new Point(isSXBanner || displayStyle == null ? 30 : 265, 70),
                FontUtilities.leftString
                );
            toDrawOn.DrawPath(myPen, p);
            toDrawOn.FillPath(new SolidBrush(ControlPaint.Dark(headerColor, (float)0.05)), p);

            toDrawOn.DrawString(bundleDisplayName, new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[1], 40), new SolidBrush(Color.White), new Point(isSXBanner || displayStyle == null ? 25 : 260, 105));

            toDrawOn.FillRectangle(new SolidBrush(ControlPaint.Dark(headerColor, (float)0.1)), new Rectangle(-1, 255, myBitmap.Width + 1, myBitmap.Height));
        }
예제 #50
0
                public static void DrawTab(Graphics g, Rectangle r, Corners corner, GradientType gradient, Color darkColor, Color lightColor, Color edgeColor, bool closed)
                {
                    //dims
                    Point[] points;
                    GraphicsPath path;
                    Region Region;
                    LinearGradientBrush linearBrush;
                    Brush brush = null;
                    Pen pen;
                    r.Inflate(- 1, - 1);
                    //set brushes
                    switch (gradient)
                    {
                        case GradientType.Flat:
                            brush = new SolidBrush(darkColor);
                            break;
                        case GradientType.Linear:
                            brush = new LinearGradientBrush(r, darkColor, lightColor, LinearGradientMode.Vertical);
                            break;
                        case GradientType.Bell:
                            linearBrush = new LinearGradientBrush(r, darkColor, lightColor, LinearGradientMode.Vertical);
                            linearBrush.SetSigmaBellShape((float) (0.17F), (float) (0.67F));
                            brush = linearBrush;
                            break;
                    }
                    pen = new pen(edgeColor, 1);
                    //generic points
                    points = new Point[12] {new Point(r.Left, r.Bottom), new Point(r.Left, r.Bottom - bshift), new Point(r.Left, r.Top + bshift), new Point(r.Left, r.Top), new Point(r.Left + bshift, r.Top), new Point(r.Right - bshift, r.Top), new Point(r.Right, r.Top), new Point(r.Right, r.Top + bshift), new Point(r.Right, r.Bottom - bshift), new Point(r.Right, r.Bottom), new Point(r.Right - bshift, r.Bottom), new Point(r.Left + bshift, r.Bottom)};

                    path = new GraphicsPath();
                    switch (corner)
                    {
                        case Corners.LeftBottom:
                            path.AddLine(points[3], points[1]);
                            path.AddBezier(points[1], points[0], points[0], points[11]);
                            path.AddLine(points[11], points[9]);
                            path.AddLine(points[9], points[6]);
                            path.AddLine(points[6], points[3]);
                            Region = new Region(path);
                            g.FillRegion(brush, Region);
                            g.DrawLine(pen, points[3], points[1]);
                            g.DrawBezier(pen, points[1], points[0], points[0], points[11]);
                            g.DrawLine(pen, points[11], points[9]);
                            g.DrawLine(pen, points[9], points[6]);
                            if (closed)
                            {
                                g.DrawLine(pen, points[6], points[3]);
                            }
                            break;
                        case Corners.LeftTop:
                            path.AddLine(points[0], points[2]);
                            path.AddBezier(points[2], points[3], points[3], points[4]);
                            path.AddLine(points[4], points[6]);
                            path.AddLine(points[6], points[9]);
                            path.AddLine(points[9], points[0]);
                            Region = new Region(path);
                            g.FillRegion(brush, Region);
                            g.DrawLine(pen, points[0], points[2]);
                            g.DrawBezier(pen, points[2], points[3], points[3], points[4]);
                            g.DrawLine(pen, points[4], points[6]);
                            g.DrawLine(pen, points[6], points[9]);
                            if (closed)
                            {
                                g.DrawLine(pen, points[9], points[0]);
                            }
                            break;
                        case Corners.Bottom:

                            path.AddLine(points[1], points[3]);
                            path.AddBezier(points[1], points[0], points[0], points[11]);
                            path.AddLine(points[11], points[10]);
                            path.AddBezier(points[10], points[9], points[9], points[8]);
                            path.AddLine(points[8], points[6]);
                            path.AddLine(points[6], points[3]);
                            Region = new Region(path);
                            g.FillRegion(brush, Region);

                            g.DrawLine(pen, points[1], points[3]);
                            g.DrawBezier(pen, points[1], points[0], points[0], points[11]);
                            g.DrawLine(pen, points[11], points[10]);
                            g.DrawBezier(pen, points[10], points[9], points[9], points[8]);
                            g.DrawLine(pen, points[8], points[6]);

                            if (closed)
                            {
                                g.DrawLine(pen, points[6], points[3]);
                            }

                            break;

                        case Corners.Top:
                            path.AddLine(points[0], points[2]);
                            path.AddBezier(points[2], points[3], points[3], points[4]);
                            path.AddLine(points[4], points[5]);
                            path.AddBezier(points[5], points[6], points[6], points[7]);
                            path.AddLine(points[7], points[9]);
                            path.AddLine(points[9], points[0]);
                            Region = new Region(path);
                            g.FillRegion(brush, Region);

                            g.DrawLine(pen, points[0], points[2]);
                            g.DrawBezier(pen, points[2], points[3], points[3], points[4]);
                            g.DrawLine(pen, points[4], points[5]);
                            g.DrawBezier(pen, points[5], points[6], points[6], points[7]);
                            g.DrawLine(pen, points[7], points[9]);

                            if (closed)
                            {
                                g.DrawLine(pen, points[9], points[0]);
                            }

                            break;

                        case Corners.RightBottom:
                            path.AddLine(points[3], points[0]);
                            path.AddLine(points[0], points[10]);
                            path.AddBezier(points[10], points[9], points[9], points[8]);
                            path.AddLine(points[8], points[6]);
                            path.AddLine(points[6], points[3]);
                            Region = new Region(path);
                            g.FillRegion(brush, Region);
                            g.DrawLine(pen, points[3], points[0]);
                            g.DrawLine(pen, points[0], points[10]);
                            g.DrawBezier(pen, points[10], points[9], points[9], points[8]);
                            g.DrawLine(pen, points[8], points[6]);
                            if (closed)
                            {
                                g.DrawLine(pen, points[6], points[3]);
                            }
                            break;
                        case Corners.RightTop:
                            path.AddLine(points[0], points[3]);
                            path.AddLine(points[3], points[5]);
                            path.AddBezier(points[5], points[6], points[6], points[7]);
                            path.AddLine(points[7], points[9]);
                            path.AddLine(points[9], points[0]);
                            Region = new Region(path);
                            g.FillRegion(brush, Region);
                            g.DrawLine(pen, points[0], points[3]);
                            g.DrawLine(pen, points[3], points[5]);
                            g.DrawBezier(pen, points[5], points[6], points[6], points[7]);
                            g.DrawLine(pen, points[7], points[9]);
                            if (closed)
                            {
                                g.DrawLine(pen, points[9], points[0]);
                            }
                            break;
                    }
                }
예제 #51
0
        /// <summary>
        /// Supporting rounded corners.
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        protected override RequestedAction PreRenderImage(ImageState s)
        {
            if (s.sourceBitmap == null)
            {
                return(RequestedAction.None);
            }
            double[] vals = s.settings.GetList <double>("s.roundcorners", 0, 1, 4);
            if (vals == null)
            {
                return(RequestedAction.None);
            }

            if (vals.Length == 1)
            {
                vals = new double[] { vals[0], vals[0], vals[0], vals[0] }
            }
            ;

            bool hasValue = false;

            foreach (double d in vals)
            {
                if (d > 0)
                {
                    hasValue = true;
                }
            }
            if (!hasValue)
            {
                return(RequestedAction.None);
            }

            Bitmap cropped = null;

            try{
                //Make sure cropping is applied, and use existing prerendered bitmap if present.
                s.ApplyCropping();

                cropped = s.preRenderBitmap ?? s.sourceBitmap;

                s.preRenderBitmap = new Bitmap(cropped.Width, cropped.Height, PixelFormat.Format32bppArgb);

                int[] radius = new int[4];
                //Radius percentages are 0-100, a percentage of the smaller of the width and height.
                for (int i = 0; i < vals.Length; i++)
                {
                    radius[i] = (int)Math.Round(Math.Max(0, Math.Min(99.999, vals[i])) * ((double)Math.Min(s.preRenderBitmap.Width, s.preRenderBitmap.Height) / 100));
                }


                s.preRenderBitmap.MakeTransparent();
                using (Graphics g = Graphics.FromImage(s.preRenderBitmap)) {
                    g.SmoothingMode      = SmoothingMode.AntiAlias;
                    g.CompositingMode    = CompositingMode.SourceOver;
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                    using (TextureBrush tb = new TextureBrush(cropped))
                        using (GraphicsPath gp = new GraphicsPath(FillMode.Winding)) {
                            Rectangle bounds = new Rectangle(0, 0, s.preRenderBitmap.Width, s.preRenderBitmap.Height);
                            int[]     angles = new int[] { 180, 270, 0, 90 };
                            int[]     xs     = new int[] { bounds.X, bounds.Right - radius[1], bounds.Right - radius[2], bounds.X };
                            int[]     ys     = new int[] { bounds.Y, bounds.Y, bounds.Bottom - radius[2], bounds.Bottom - radius[3] };
                            for (int i = 0; i < 4; i++)
                            {
                                if (radius[i] > 0)
                                {
                                    gp.AddArc(xs[i], ys[i], radius[i], radius[i], angles[i], 90);
                                }
                                else
                                {
                                    gp.AddLine(xs[i], ys[i], xs[i], ys[i]);
                                }
                            }
                            g.FillPath(tb, gp);
                        }
                }
            }finally{
                if (cropped != null & cropped != s.sourceBitmap)
                {
                    cropped.Dispose();
                }
            }
            return(RequestedAction.None);
        }
예제 #52
0
파일: Theme.cs 프로젝트: massimoca/Wedit
    private GraphicsPath DrawArrow(int x, int y, bool flip)
    {
        GraphicsPath GP = new GraphicsPath();

        int W = 5;
        int H = 9;

        if (flip)
        {
            GP.AddLine(x, y + 1, x, y + H + 1);
            GP.AddLine(x, y + H, x + W - 1, y + W);
        }
        else
        {
            GP.AddLine(x + W, y, x + W, y + H);
            GP.AddLine(x + W, y + H, x + 1, y + W);
        }

        GP.CloseFigure();
        return GP;
    }
예제 #53
0
파일: Form1.cs 프로젝트: Botawed/-
        public void picDrawingSurface_MouseMove(object sender, MouseEventArgs e)
        {
            label1.Text = e.X.ToString() + "X,Y" + e.Y.ToString();
            x2          = e.X;
            y2          = e.Y;
            switch (selectedTool)
            {
            case "Circle":
                if (drawing)
                {
                    Graphics g = Graphics.FromImage(picDrawingSurface.Image);
                    g.Clear(Color.White);
                    g.DrawEllipse(currentPen, x1, y1, x2 - x1, y2 - y1);
                    g.FillEllipse(currentBrush, x1, y1, x2 - x1, y2 - y1);
                    g.Dispose();
                    picDrawingSurface.Invalidate();
                }
                break;

            case "Rectanglee":
                if (drawing)
                {
                    //Graphics g = this.CreateGraphics();
                    Graphics g = Graphics.FromImage(picDrawingSurface.Image);
                    g.Clear(Color.White);
                    Point p = new Point(x1, y1);
                    Size  s = new Size(x2, y2);

                    //g.DrawRectangle(currentBrush, x1, y1, x2 - x1, y2 - y1);
                    Rectangle r2 = new Rectangle(p, s);
                    g.DrawRectangle(currentPen, r2);
                    //g.DrawRectangle(currentPen, x1, y1, x2 - x1, y2 - y1);
                    g.FillRectangle(currentBrush, r2);
                    g.Dispose();
                    picDrawingSurface.Invalidate();
                }
                break;

            case "Pencil":
                if (drawing)
                {
                    Graphics g = Graphics.FromImage(picDrawingSurface.Image);
                    currentPath.AddLine(oldLocation, e.Location);    //GraphicsPath currentPath;
                    g.DrawPath(currentPen, currentPath);
                    oldLocation = e.Location;
                    g.Dispose();
                    picDrawingSurface.Invalidate();
                }
                break;

            case "Line":
                if (drawing)
                {
                    //twopoint.Clear();
                    Graphics g = Graphics.FromImage(picDrawingSurface.Image);
                    g.Clear(Color.White);
                    g.DrawLine(currentPen, new Point(x1, y1), new Point(x2, y2));
                    //g.Dispose();
                    picDrawingSurface.Invalidate();
                    foreach (var p in twopoint)
                    {
                        g.DrawLine(currentPen, p.X1, p.Y1);
                    }
                }
                break;

            case "Polygon":
                if (drawing)
                {
                    Graphics g = Graphics.FromImage(picDrawingSurface.Image);
                    g.Clear(Color.White);

                    Point[] pnts = new Point[points.Count];
                    for (int i = 0; i < points.Count; i++)
                    {
                        pnts[i] = points[i];
                    }
                    g.DrawPolygon(currentPen, pnts);
                    g.FillPolygon(currentBrush, pnts);
                    g.SmoothingMode = SmoothingMode.HighQuality;
                    g.Dispose();
                    picDrawingSurface.Invalidate();
                }
                break;

            case "Polline":
                if (drawing)
                {
                    Graphics g = Graphics.FromImage(picDrawingSurface.Image);
                    g.Clear(Color.White);

                    Point[] pnts = new Point[points.Count];
                    for (int i = 0; i < points.Count; i++)
                    {
                        pnts[i] = points[i];
                    }
                    g.DrawLines(currentPen, pnts);
                    //g.FillPolygon(currentBrush, pnts);
                    g.SmoothingMode = SmoothingMode.HighQuality;
                    g.Dispose();
                    picDrawingSurface.Invalidate();
                }
                break;

            default:
                break;
            }


            //if (drawing)
            //{
            //    x2 = e.X;
            //    y2 = e.Y;


            //    Graphics g = Graphics.FromImage(picDrawingSurface.Image);
            //    g.Clear(Color.White);
            //    //g.DrawRectangle(currentBrush, x1, y1, x2 - x1, y2 - y1);
            //    g.DrawRectangle(currentPen, x1, y1, x2 - x1, y2 - y1);
            //    g.FillRectangle(currentBrush, x1, y1, x2 - x1, y2 - y1);
            //    g.Dispose();
            //    picDrawingSurface.Invalidate();

            //    //Graphics g = Graphics.FromImage(picDrawingSurface.Image);

            //    //currentPath.AddLine(oldLocation, e.Location);//GraphicsPath currentPath;
            //    //g.DrawPath(currentPen, currentPath);
            //    //oldLocation = e.Location;

            //    //g.Dispose();
            //    //picDrawingSurface.Invalidate();

            //}
        }