Beispiel #1
0
    protected override void OnResize(EventArgs e)
    {
        Height = 19; Width = 47;
        
        RoundedRectangle = new GraphicsPath();
        int radius = 10;

        RoundedRectangle.AddArc(11, 4, radius - 1, radius, 180, 90);
        RoundedRectangle.AddArc(Width - 21, 4, radius - 1, radius, -90, 90);
        RoundedRectangle.AddArc(Width - 21, Height - 15, radius - 1, radius, 0, 90);
        RoundedRectangle.AddArc(11, Height - 15, radius - 1, radius, 90, 90);

        RoundedRectangle.CloseAllFigures();
        Invalidate(); 
    }
Beispiel #2
0
    private void IrregularForm_Load(object sender, EventArgs e)
    {
        GraphicsPath path = new GraphicsPath();

        Point[] pointsA = new Point[] { new Point(0, 0), new Point(40, 60), new Point(this.Width - 100, 10) };
        path.AddCurve(pointsA);

        Point[] pointsB = new Point[]{
                new Point(this.Width - 40, this.Height - 60),
                new Point(this.Width, this.Height),
                new Point(10, this.Height)
            };
        path.AddCurve(pointsB);

        path.CloseAllFigures();

        this.Region = new Region(path);
    }
Beispiel #3
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 pathLineIn      = new GraphicsPath();
            GraphicsPath pathLineOut     = new GraphicsPath();
            int          intLinePenWidth = 0;

            switch (exitDirection)
            {
            case BlowerExitDirection.Left:
                g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(0, m_rectWorking.Top, this.Width / 2, m_rectWorking.Height / 2 - 5));
                intLinePenWidth = m_rectWorking.Height / 2 - 5;
                pathLineOut.AddLine(new Point(-10, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2));
                g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(1, m_rectWorking.Top - 2), new Point(1, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) + 2));
                break;

            case BlowerExitDirection.Right:
                g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(this.Width / 2, m_rectWorking.Top, this.Width / 2, m_rectWorking.Height / 2 - 5));
                intLinePenWidth = m_rectWorking.Height / 2 - 5;
                pathLineOut.AddLine(new Point(this.Width + 10, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2));
                g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(this.Width - 2, m_rectWorking.Top - 2), new Point(this.Width - 2, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) + 2));
                break;

            case BlowerExitDirection.Up:
                g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5), 0, m_rectWorking.Width / 2 - 5, this.Height / 2));
                intLinePenWidth = m_rectWorking.Width / 2 - 5;
                pathLineOut.AddLine(new Point(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5) / 2, -10), new Point(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5) / 2, m_rectWorking.Top + m_rectWorking.Height / 2));
                g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(m_rectWorking.Right + 2, 1), new Point(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5) - 2, 1));
                break;
            }

            switch (entranceDirection)
            {
            case BlowerEntranceDirection.Left:
                g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(0, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5, this.Width / 2, m_rectWorking.Height / 2 - 5));
                pathLineIn.AddLine(new Point(-10, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2));
                g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(1, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 - 2), new Point(1, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) + 2));
                break;

            case BlowerEntranceDirection.Right:
                g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(this.Width / 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5, this.Width / 2, m_rectWorking.Height / 2 - 5));
                pathLineIn.AddLine(new Point(this.Width + 10, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2));
                g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(this.Width - 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 - 2), new Point(this.Width - 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) + 2));
                break;

            case BlowerEntranceDirection.Up:
                g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(m_rectWorking.Left, 0, m_rectWorking.Width / 2 - 5, this.Height / 2));
                pathLineIn.AddLine(new Point(m_rectWorking.Left + (m_rectWorking.Width / 2 - 5) / 2, -10), new Point(m_rectWorking.Left + (m_rectWorking.Width / 2 - 5) / 2, m_rectWorking.Top + m_rectWorking.Height / 2));
                g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(m_rectWorking.Left - 2, 1), new Point(m_rectWorking.Left + (m_rectWorking.Width / 2 - 5) + 2, 1));
                break;
            }

            //渐变色
            int _intPenWidth = intLinePenWidth;
            int intCount     = _intPenWidth / 2 / 4;

            for (int i = 0; i < intCount; i++)
            {
                int _penWidth = _intPenWidth / 2 - 4 * i;
                if (_penWidth <= 0)
                {
                    _penWidth = 1;
                }
                if (entranceDirection != BlowerEntranceDirection.None)
                {
                    g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), pathLineIn);
                }
                g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), pathLineOut);
                if (_penWidth == 1)
                {
                    break;
                }
            }

            //底座
            GraphicsPath gpDZ = new GraphicsPath();

            gpDZ.AddLines(new Point[]
            {
                new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Top + m_rectWorking.Height / 2),
                new Point(m_rectWorking.Left + 2, this.Height),
                new Point(m_rectWorking.Right - 2, this.Height)
            });
            gpDZ.CloseAllFigures();
            g.FillPath(new SolidBrush(blowerColor), gpDZ);
            g.FillPath(new SolidBrush(Color.FromArgb(50, Color.White)), gpDZ);
            g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(m_rectWorking.Left, this.Height - 2), new Point(m_rectWorking.Right, this.Height - 2));

            //中心
            g.FillEllipse(new SolidBrush(blowerColor), m_rectWorking);
            g.FillEllipse(new SolidBrush(Color.FromArgb(20, Color.White)), m_rectWorking);


            //扇叶
            Rectangle _rect = new Rectangle(m_rectWorking.Left + (m_rectWorking.Width - (m_rectWorking.Width / 3 * 2)) / 2, m_rectWorking.Top + (m_rectWorking.Height - (m_rectWorking.Width / 3 * 2)) / 2, (m_rectWorking.Width / 3 * 2), (m_rectWorking.Width / 3 * 2));

            int   _splitCount   = 8;
            float fltSplitValue = 360F / (float)_splitCount;

            for (int i = 0; i <= _splitCount; i++)
            {
                float fltAngle = (fltSplitValue * i - 180) % 360;
                float fltY1    = (float)(_rect.Top + _rect.Width / 2 - ((_rect.Width / 2) * Math.Sin(Math.PI * (fltAngle / 180.00F))));
                float fltX1    = (float)(_rect.Left + (_rect.Width / 2 - ((_rect.Width / 2) * Math.Cos(Math.PI * (fltAngle / 180.00F)))));
                float fltY2    = 0;
                float fltX2    = 0;

                fltY2 = (float)(_rect.Top + _rect.Width / 2 - ((_rect.Width / 4) * Math.Sin(Math.PI * (fltAngle / 180.00F))));
                fltX2 = (float)(_rect.Left + (_rect.Width / 2 - ((_rect.Width / 4) * Math.Cos(Math.PI * (fltAngle / 180.00F)))));

                g.DrawLine(new Pen(new SolidBrush(fanColor), 2), new PointF(fltX1, fltY1), new PointF(fltX2, fltY2));
            }

            g.FillEllipse(new SolidBrush(fanColor), new Rectangle(_rect.Left + _rect.Width / 2 - _rect.Width / 4 + 2, _rect.Top + _rect.Width / 2 - _rect.Width / 4 + 2, _rect.Width / 2 - 4, _rect.Width / 2 - 4));
            g.FillEllipse(new SolidBrush(Color.FromArgb(50, Color.White)), new Rectangle(_rect.Left - 5, _rect.Top - 5, _rect.Width + 10, _rect.Height + 10));
        }
Beispiel #4
0
        public override void DrawRoundedRectangle(Graphics gfx, Rectangle Bounds, int CornerRadius, Pen DrawPen, Color FillColor)
        {
            // Rectangle Bounds = new Rectangle(strokeOffset, strokeOffset, Width - strokeOffset * 2, Height - strokeOffset * 2);
            int notch = CornerRadius + (CornerRadius >> 1);
            int along = 150;


            int X      = Bounds.X + 1;
            int radius = CornerRadius;
            int Y      = Bounds.Y + notch + 1;
            int width  = Bounds.Width - 2;
            int height = Bounds.Height - notch - 2;

            DrawPen.Width  = StrokeWidth;
            DrawPen.EndCap = DrawPen.StartCap = LineCap.Round;


            using (GraphicsPath gfxPath = new GraphicsPath())
            {
                // TOP LINE LEFT
                //gfxPath.AddLine(X + radius, Y, X + along - (radius * 4), Y);

                gfx.SmoothingMode = SmoothingMode.AntiAlias;


                gfxPath.AddArc(X + along - (int)(radius * 3), Y - notch - radius * 0, radius * 2, radius * 2, 180 + 34, 34);


                // TOP LINE RIGHT
                //gfxPath.AddLine(X + along - (radius * 0), Y - notch, X + width - (radius*2), Y - notch);


                // TOP RIGHT
                gfxPath.AddArc(X + width - (radius * 2), Y - notch, radius * 2, radius * 2, 270, 90);

                // RIGHT LINE
                // gfxPath.AddLine(X + width, Y + (radius * 1), X + width, Y + height - (radius * 2));

                // BOTTOM RIGHT
                gfxPath.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);

                // BOTTOM LINE
                // gfxPath.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);

                // BOTTOM LEFT ?
                gfxPath.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);

                // LEFT LINE
                // gfxPath.AddLine(X, Y + height - (radius * 2), X, Y + radius + notch);

                // TOP LEFT
                gfxPath.AddArc(X, Y, radius * 2, radius * 2, 180, 90);



                gfxPath.AddArc(X + along - (radius * 5), Y - radius * 2, radius * 2, radius * 2, 90, -45);

                gfxPath.CloseAllFigures();

                gfx.FillPath(new SolidBrush(FillColor), gfxPath);
                gfx.DrawPath(DrawPen, gfxPath);
            }

            //  DrawRoundedRectangleCustomPost(gfx, Bounds, CornerRadius, DrawPen, FillColor);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics _graphics = e.Graphics;

            _graphics.SmoothingMode     = SmoothingMode.HighQuality;
            _graphics.TextRenderingHint = TextStyle.TextRenderingHint;

            Rectangle _clientRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1);

            ControlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _border);

            _graphics.SetClip(ControlGraphicsPath);

            _buttonRectangle = new Rectangle(Width - _buttonWidth, 1, _buttonWidth, Height);

            Size incrementSize = TextManager.MeasureText("+", _buttonFont, _graphics);
            Size decrementSize = TextManager.MeasureText("-", _buttonFont, _graphics);

            _incrementButtonPoints[0] = new Point((_buttonRectangle.X + (_buttonRectangle.Width / 2)) - (incrementSize.Width / 2), (_buttonRectangle.Y + (_buttonRectangle.Height / 2)) - (_buttonRectangle.Height / 4) - (incrementSize.Height / 2));
            _decrementButtonPoints[0] = new Point((_buttonRectangle.X + (_buttonRectangle.Width / 2)) - (decrementSize.Width / 2), (_buttonRectangle.Y + (_buttonRectangle.Height / 2) + (_buttonRectangle.Height / 4)) - (decrementSize.Height / 2));

            _incrementButtonPoints[1] = new Point((_buttonRectangle.X + (_buttonRectangle.Width / 4)) - (incrementSize.Width / 2), (Height / 2) - (incrementSize.Height / 2));
            _decrementButtonPoints[1] = new Point((_buttonRectangle.X + (_buttonRectangle.Width / 2) + (_buttonRectangle.Width / 4)) - (decrementSize.Width / 2), (Height / 2) - (decrementSize.Height / 2));

            int toggleInt;

            switch (_buttonOrientation)
            {
            case Orientation.Horizontal:
            {
                toggleInt = 1;
                _borderButtons.Location = new Point(_buttonRectangle.X + (_buttonRectangle.Width / 2), _border.Thickness);
                _borderButtons.Size     = new Size(1, Height - _border.Thickness - 1);
                break;
            }

            case Orientation.Vertical:
            {
                toggleInt = 0;
                _borderButtons.Location = new Point(_buttonRectangle.X, (_buttonRectangle.Bottom / 2) - _border.Thickness);
                _borderButtons.Size     = new Size(Width - _border.Thickness - 1, 1);
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException();
            }
            }

            _buttonPath = new GraphicsPath();
            _buttonPath.AddRectangle(_buttonRectangle);
            _buttonPath.CloseAllFigures();

            Color _backColor = Enabled ? BackColorState.Enabled : BackColorState.Disabled;

            VisualBackgroundRenderer.DrawBackground(e.Graphics, _backColor, BackgroundImage, MouseState, _clientRectangle, Border);

            _graphics.SetClip(ControlGraphicsPath);
            _graphics.FillRectangle(new SolidBrush(_buttonColor), _buttonRectangle);
            _graphics.ResetClip();

            _graphics.DrawString("+", _buttonFont, new SolidBrush(_buttonForeColor), _incrementButtonPoints[toggleInt]);
            _graphics.DrawString("-", _buttonFont, new SolidBrush(_buttonForeColor), _decrementButtonPoints[toggleInt]);

            _borderEdge.Location = new Point(_buttonRectangle.X, _border.Thickness);
            _borderEdge.Size     = new Size(1, Height - _border.Thickness - 1);

            DrawText(_graphics);

            VisualBorderRenderer.DrawBorderStyle(e.Graphics, _border, ControlGraphicsPath, MouseState);
        }
        /// <summary>
        /// Baws the on paint.
        /// </summary>
        /// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
        private void BAWOnPaint(PaintEventArgs e)
        {
            //Bitmap B = new Bitmap(Width, Height);
            Graphics G = e.Graphics;

            G.SmoothingMode = Smoothing;

            G.Clear(Parent.BackColor);
            dynamic progressWidth = Convert.ToInt32(Value * (1 / Maximum) * Width - 50);


            OGB         = new LinearGradientBrush(new Rectangle(Width - 44, Height - 31, 31, 31), Color.FromArgb(173, 173, 173), Color.FromArgb(195, 195, 195), 90);
            IGB         = new LinearGradientBrush(new Rectangle(Width - 43, Height - 30, 30, 30), Color.FromArgb(201, 201, 201), Color.FromArgb(225, 225, 225), 90);
            IOGB        = new LinearGradientBrush(new Rectangle(19, Height - 26, Width - 6, Height - 26), Color.FromArgb(125, 175, 225), Color.FromArgb(55, 130, 205), -90);
            IndicatorGB = new LinearGradientBrush(new Rectangle(progressWidth - 11, 0, progressWidth + 19, 45), Color.FromArgb(232, 232, 232), Color.FromArgb(202, 202, 202), 90);

            baWP1 = new Pen(OGB);
            baWP2 = new Pen(IOGB);

            TB.TranslateTransform(0, -5, MatrixOrder.Prepend);

            if (progressWidth >= 13)
            {
                IPath.AddArc(19, Height - 26, 20, 20, 180, 90);
                IPath.AddArc(progressWidth, Height - 26, 20, 20, -90, 90);
                IPath.AddArc(progressWidth, Height - 26, 20, 20, 0, 90);
                IPath.AddArc(19, Height - 26, 20, 20, 90, 90);
            }
            Indicator.AddArc(progressWidth - 11, 0, 8, 8, 180, 90);
            Indicator.AddArc(progressWidth + 40, 0, 8, 8, -90, 90);
            Indicator.AddArc(progressWidth + 40, 27, 8, 8, 0, 90);
            Indicator.AddLine(progressWidth + 24, 35, progressWidth + 19, 45);
            Indicator.AddLine(progressWidth + 14, 35, progressWidth - 3, 35);
            Indicator.AddArc(progressWidth - 11, 27, 8, 8, 90, 90);
            Indicator.CloseFigure();

            OPath = new GraphicsPath();

            OPath.AddArc(14, Height - 31, 20, 20, 180, 90);
            OPath.AddArc(Width - 44, Height - 31, 20, 20, -90, 90);
            OPath.AddArc(Width - 44, Height - 21, 20, 20, 0, 90);
            OPath.AddArc(14, Height - 21, 20, 20, 90, 90);
            OPath.CloseAllFigures();

            //ChangePaths();
            G.FillPath(IGB, OPath);
            G.DrawPath(baWP1, OPath);

            if (progressWidth > 0)
            {
                G.FillPath(IGB, OPath);
                G.DrawPath(baWP1, OPath);
                G.FillPath(TB, IPath);
                G.DrawPath(baWP2, IPath);

                G.FillPath(IndicatorGB, Indicator);
                G.DrawPath(baWP3, Indicator);
            }

            //        switch (_Value)
            //        {
            //            case 0:
            //                G.FillPath(IGB, OPath);
            //                G.DrawPath(baWP1, OPath);
            //                break;
            //            default:
            //                G.FillPath(IGB, OPath);
            //                G.DrawPath(baWP1, OPath);
            //                G.FillPath(TB, IPath);
            //                G.DrawPath(baWP2, IPath);

            //                G.FillPath(IndicatorGB, Indicator);
            //                G.DrawPath(baWP3, Indicator);

            ////                switch (_Value)
            ////                {
            ////                    case  // ERROR: Case labels with binary operators are unsupported : LessThan
            ////10:
            ////                        _with2.DrawString(_Value + "%", Font, baWB1, FillValue + 6, 7);
            ////                        break;
            ////                    case  // ERROR: Case labels with binary operators are unsupported : LessThan
            ////100:
            ////                        _with2.DrawString(_Value + "%", Font, baWB1, FillValue - 5, 7);
            ////                        break;
            ////                    default:
            ////                        _with2.DrawString(_Value + "%", Font, baWB1, FillValue - 11, 7);
            ////                        break;
            ////                }
            //                break;
            //        }

            //e.Graphics.DrawImage(B, 0, 0);
        }
Beispiel #7
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));
        }
Beispiel #8
0
        private static GraphicsPath GetSegment14(LEDSegment14 segment, PointF p, float size)
        {
            GraphicsPath graphicsPath = new GraphicsPath();
            SizeF        sizeF        = new SizeF(size * 0.618034f, size);
            float        num          = sizeF.Width * 0.142857149f;
            SizeF        s            = new SizeF(sizeF.Width - num, num);
            SizeF        s2           = new SizeF(sizeF.Height / 2f - num / 2f, num);

            s.Width  -= num / 3f;
            s2.Width -= num / 3f;
            switch (segment)
            {
            case LEDSegment14.SG1:
            {
                s.Width = s.Width / 2f - num / 6f;
                graphicsPath.AddPolygon(GetSegment7(p, s));
                graphicsPath.CloseAllFigures();
                using (Matrix matrix8 = new Matrix())
                {
                    matrix8.Translate((0f - s.Width) / 2f - num / 6f, 0f);
                    graphicsPath.Transform(matrix8);
                    return(graphicsPath);
                }
            }

            case LEDSegment14.SG2:
            {
                s.Width = s.Width / 2f - num / 6f;
                graphicsPath.AddPolygon(GetSegment7(p, s));
                graphicsPath.CloseAllFigures();
                using (Matrix matrix7 = new Matrix())
                {
                    matrix7.Translate(s.Width / 2f + num / 6f, 0f);
                    graphicsPath.Transform(matrix7);
                    return(graphicsPath);
                }
            }

            case LEDSegment14.SJ:
            {
                s2.Width -= num / 3f;
                graphicsPath.AddPolygon(GetSegment7(p, s2));
                graphicsPath.CloseAllFigures();
                using (Matrix matrix6 = new Matrix())
                {
                    matrix6.RotateAt(90f, p);
                    graphicsPath.Transform(matrix6);
                    matrix6.Reset();
                    matrix6.Translate(0f, (0f - s2.Width) / 2f - num / 6f);
                    graphicsPath.Transform(matrix6);
                    return(graphicsPath);
                }
            }

            case LEDSegment14.SM:
            {
                s2.Width -= num / 3f;
                graphicsPath.AddPolygon(GetSegment7(p, s2));
                graphicsPath.CloseAllFigures();
                using (Matrix matrix5 = new Matrix())
                {
                    matrix5.RotateAt(90f, p);
                    graphicsPath.Transform(matrix5);
                    matrix5.Reset();
                    matrix5.Translate(0f, s2.Width / 2f + num / 6f);
                    graphicsPath.Transform(matrix5);
                    return(graphicsPath);
                }
            }

            case LEDSegment14.SH:
            {
                graphicsPath.AddPolygon(GetSegmentHKLN(p, s, num, left: true));
                using (Matrix matrix4 = new Matrix())
                {
                    matrix4.Translate((0f - (s.Width / 2f + num / 6f)) / 2f, (0f - s2.Width) / 2f - num / 6f);
                    graphicsPath.Transform(matrix4);
                    return(graphicsPath);
                }
            }

            case LEDSegment14.SL:
            {
                graphicsPath.AddPolygon(GetSegmentHKLN(p, s, num, left: true));
                using (Matrix matrix3 = new Matrix())
                {
                    matrix3.Translate((s.Width / 2f + num / 6f) / 2f, s2.Width / 2f - num / 6f);
                    graphicsPath.Transform(matrix3);
                    return(graphicsPath);
                }
            }

            case LEDSegment14.SK:
            {
                graphicsPath.AddPolygon(GetSegmentHKLN(p, s, num, left: false));
                using (Matrix matrix2 = new Matrix())
                {
                    matrix2.Translate((s.Width / 2f + num / 6f) / 2f, (0f - s2.Width) / 2f - num / 6f);
                    graphicsPath.Transform(matrix2);
                    return(graphicsPath);
                }
            }

            case LEDSegment14.SN:
            {
                graphicsPath.AddPolygon(GetSegmentHKLN(p, s, num, left: false));
                using (Matrix matrix = new Matrix())
                {
                    matrix.Translate((0f - (s.Width / 2f + num / 6f)) / 2f, s2.Width / 2f - num / 6f);
                    graphicsPath.Transform(matrix);
                    return(graphicsPath);
                }
            }

            default:
                return(graphicsPath);
            }
        }
        internal override void Paint(Chart chart, ChartGraphics graphics)
        {
            Chart = chart;
            if (path.PointCount == 0)
            {
                return;
            }
            PointF location       = PointF.Empty;
            PointF anchorLocation = PointF.Empty;
            SizeF  size           = SizeF.Empty;

            GetRelativePosition(out location, out size, out anchorLocation);
            PointF     pointF      = new PointF(location.X + size.Width, location.Y + size.Height);
            RectangleF rectangleF  = new RectangleF(location, new SizeF(pointF.X - location.X, pointF.Y - location.Y));
            RectangleF rectangleF2 = new RectangleF(rectangleF.Location, rectangleF.Size);

            if (rectangleF2.Width < 0f)
            {
                rectangleF2.X     = rectangleF2.Right;
                rectangleF2.Width = 0f - rectangleF2.Width;
            }
            if (rectangleF2.Height < 0f)
            {
                rectangleF2.Y      = rectangleF2.Bottom;
                rectangleF2.Height = 0f - rectangleF2.Height;
            }
            if (float.IsNaN(rectangleF2.X) || float.IsNaN(rectangleF2.Y) || float.IsNaN(rectangleF2.Right) || float.IsNaN(rectangleF2.Bottom))
            {
                return;
            }
            RectangleF absoluteRectangle = graphics.GetAbsoluteRectangle(rectangleF2);
            float      num  = absoluteRectangle.Width / 100f;
            float      num2 = absoluteRectangle.Height / 100f;

            PointF[] array     = path.PathPoints;
            byte[]   pathTypes = path.PathTypes;
            for (int i = 0; i < array.Length; i++)
            {
                array[i].X = absoluteRectangle.X + array[i].X * num;
                array[i].Y = absoluteRectangle.Y + array[i].Y * num2;
            }
            GraphicsPath graphicsPath = new GraphicsPath(array, pathTypes);
            bool         flag         = false;
            LineCap      lineCap      = LineCap.Flat;
            LineCap      lineCap2     = LineCap.Flat;

            if (!isPolygon && (startCap != 0 || endCap != 0))
            {
                flag     = true;
                lineCap  = graphics.pen.StartCap;
                lineCap2 = graphics.pen.EndCap;
                if (startCap == LineAnchorCap.Arrow)
                {
                    if (LineWidth < 4)
                    {
                        int num3 = 3 - LineWidth;
                        graphics.pen.StartCap       = LineCap.Custom;
                        graphics.pen.CustomStartCap = new AdjustableArrowCap(LineWidth + num3, LineWidth + num3, isFilled: true);
                    }
                    else
                    {
                        graphics.pen.StartCap = LineCap.ArrowAnchor;
                    }
                }
                else if (startCap == LineAnchorCap.Diamond)
                {
                    graphics.pen.StartCap = LineCap.DiamondAnchor;
                }
                else if (startCap == LineAnchorCap.Round)
                {
                    graphics.pen.StartCap = LineCap.RoundAnchor;
                }
                else if (startCap == LineAnchorCap.Square)
                {
                    graphics.pen.StartCap = LineCap.SquareAnchor;
                }
                if (endCap == LineAnchorCap.Arrow)
                {
                    if (LineWidth < 4)
                    {
                        int num4 = 3 - LineWidth;
                        graphics.pen.EndCap       = LineCap.Custom;
                        graphics.pen.CustomEndCap = new AdjustableArrowCap(LineWidth + num4, LineWidth + num4, isFilled: true);
                    }
                    else
                    {
                        graphics.pen.EndCap = LineCap.ArrowAnchor;
                    }
                }
                else if (endCap == LineAnchorCap.Diamond)
                {
                    graphics.pen.EndCap = LineCap.DiamondAnchor;
                }
                else if (endCap == LineAnchorCap.Round)
                {
                    graphics.pen.EndCap = LineCap.RoundAnchor;
                }
                else if (endCap == LineAnchorCap.Square)
                {
                    graphics.pen.EndCap = LineCap.SquareAnchor;
                }
            }
            if (Chart.chartPicture.common.ProcessModePaint)
            {
                if (isPolygon)
                {
                    graphicsPath.CloseAllFigures();
                    graphics.DrawPathAbs(graphicsPath, BackColor, BackHatchStyle, string.Empty, ChartImageWrapMode.Scaled, Color.Empty, ChartImageAlign.Center, BackGradientType, BackGradientEndColor, LineColor, LineWidth, LineStyle, PenAlignment.Center, ShadowOffset, ShadowColor);
                }
                else
                {
                    graphics.DrawPathAbs(graphicsPath, Color.Transparent, ChartHatchStyle.None, string.Empty, ChartImageWrapMode.Scaled, Color.Empty, ChartImageAlign.Center, GradientType.None, Color.Empty, LineColor, LineWidth, LineStyle, PenAlignment.Center, ShadowOffset, ShadowColor);
                }
            }
            if (Chart.chartPicture.common.ProcessModeRegions)
            {
                GraphicsPath graphicsPath2 = null;
                if (isPolygon)
                {
                    graphicsPath2 = graphicsPath;
                }
                else
                {
                    graphicsPath2 = new GraphicsPath();
                    graphicsPath2.AddPath(graphicsPath, connect: false);
                    using (Pen pen = (Pen)graphics.pen.Clone())
                    {
                        pen.DashStyle = DashStyle.Solid;
                        pen.Width    += 2f;
                        ChartGraphics.Widen(graphicsPath2, pen);
                    }
                }
                Chart.chartPicture.common.HotRegionsList.AddHotRegion(graphics, graphicsPath2, relativePath: false, ReplaceKeywords(ToolTip), ReplaceKeywords(Href), ReplaceKeywords(MapAreaAttributes), this, ChartElementType.Annotation);
            }
            if (flag)
            {
                graphics.pen.StartCap = lineCap;
                graphics.pen.EndCap   = lineCap2;
            }
            PaintSelectionHandles(graphics, rectangleF2, graphicsPath);
        }
        /// <summary>This method will paint the group title.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintGroupText(Graphics g)
        {
            //Check if string has something-------------
            if (this.GroupTitle == string.Empty)
            {
                return;
            }
            //------------------------------------------

            //Set Graphics smoothing mode to Anit-Alias--
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //-------------------------------------------

            //Declare Variables------------------
            SizeF StringSize  = g.MeasureString(this.GroupTitle, this.Font);
            Size  StringSize2 = StringSize.ToSize();

            if (this.GroupImage != null)
            {
                StringSize2.Width += 18;
            }
            int                 ArcWidth                = this.RoundCorners;
            int                 ArcHeight               = this.RoundCorners;
            int                 ArcX1                   = 20;
            int                 ArcX2                   = (StringSize2.Width + 34) - (ArcWidth + 1);
            int                 ArcY1                   = 0;
            int                 ArcY2                   = 24 - (ArcHeight + 1);
            GraphicsPath        path                    = new GraphicsPath();
            Brush               BorderBrush             = new SolidBrush(this.BorderColor);
            Pen                 BorderPen               = new Pen(BorderBrush, this.BorderThickness);
            LinearGradientBrush BackgroundGradientBrush = null;
            Brush               BackgroundBrush         = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
            SolidBrush          TextColorBrush          = new SolidBrush(this.ForeColor);
            SolidBrush          ShadowBrush             = null;
            GraphicsPath        ShadowPath              = null;

            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new GraphicsPath();
                ShadowPath.AddArc(
                    ArcX1 + (this.ShadowThickness - 1),
                    ArcY1 + (this.ShadowThickness - 1),
                    ArcWidth,
                    ArcHeight,
                    180,
                    GroupBoxConstants.SweepAngle); // TopCount Left
                ShadowPath.AddArc(
                    ArcX2 + (this.ShadowThickness - 1),
                    ArcY1 + (this.ShadowThickness - 1),
                    ArcWidth,
                    ArcHeight,
                    270,
                    GroupBoxConstants.SweepAngle); //TopCount Right
                ShadowPath.AddArc(
                    ArcX2 + (this.ShadowThickness - 1),
                    ArcY2 + (this.ShadowThickness - 1),
                    ArcWidth,
                    ArcHeight,
                    360,
                    GroupBoxConstants.SweepAngle); //Bottom Right
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);
                //Bottom Left
                ShadowPath.CloseAllFigures();

                //Paint Rounded Rectangle------------
                g.FillPath(ShadowBrush, ShadowPath);
                //-----------------------------------
            }
            //-----------------------------------

            //Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle); // TopCount Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle); //TopCount Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle); //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);  //Bottom Left
            path.CloseAllFigures();
            //-----------------------------------

            //Check if Gradient Mode is enabled--
            if (this.PaintGroupBox)
            {
                //Paint Rounded Rectangle------------
                g.FillPath(BackgroundBrush, path);
                //-----------------------------------
            }
            else
            {
                if (this.BackgroundGradientMode == GroupBoxGradientMode.None)
                {
                    //Paint Rounded Rectangle------------
                    g.FillPath(BackgroundBrush, path);
                    //-----------------------------------
                }
                else
                {
                    BackgroundGradientBrush = new LinearGradientBrush(
                        new Rectangle(0, 0, this.Width, this.Height),
                        this.BackgroundColor,
                        this.BackgroundGradientColor,
                        (LinearGradientMode)this.BackgroundGradientMode);

                    //Paint Rounded Rectangle------------
                    g.FillPath(BackgroundGradientBrush, path);
                    //-----------------------------------
                }
            }
            //-----------------------------------

            //Paint Borded-----------------------
            g.DrawPath(BorderPen, path);
            //-----------------------------------

            //Paint Text-------------------------
            int CustomStringWidth = (this.GroupImage != null) ? 44 : 28;

            g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth, 5);
            //-----------------------------------

            //Draw GroupImage if there is one----
            if (this.GroupImage != null)
            {
                g.DrawImage(this.GroupImage, 28, 4, 16, 16);
            }
            //-----------------------------------

            //Destroy Graphic Objects------------
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderBrush.Dispose();
            }
            if (BorderPen != null)
            {
                BorderPen.Dispose();
            }
            if (BackgroundGradientBrush != null)
            {
                BackgroundGradientBrush.Dispose();
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
            if (TextColorBrush != null)
            {
                TextColorBrush.Dispose();
            }
            if (ShadowBrush != null)
            {
                ShadowBrush.Dispose();
            }
            if (ShadowPath != null)
            {
                ShadowPath.Dispose();
            }

            //-----------------------------------
        }
Beispiel #11
0
        /// <summary>
        /// Resets the path.
        /// </summary>
        private void ResetPath()
        {
            Point[] ps = null;
            switch (direction)
            {
            case ArrowDirection.Left:
                ps = new Point[]
                {
                    new Point(0, this.Height / 2),
                    new Point(40, 0),
                    new Point(40, this.Height / 4),
                    new Point(this.Width - 1, this.Height / 4),
                    new Point(this.Width - 1, this.Height - this.Height / 4),
                    new Point(40, this.Height - this.Height / 4),
                    new Point(40, this.Height),
                    new Point(0, this.Height / 2)
                };
                break;

            case ArrowDirection.Right:
                ps = new Point[]
                {
                    new Point(0, this.Height / 4),
                    new Point(this.Width - 40, this.Height / 4),
                    new Point(this.Width - 40, 0),
                    new Point(this.Width - 1, this.Height / 2),
                    new Point(this.Width - 40, this.Height),
                    new Point(this.Width - 40, this.Height - this.Height / 4),
                    new Point(0, this.Height - this.Height / 4),
                    new Point(0, this.Height / 4)
                };
                break;

            case ArrowDirection.Top:
                ps = new Point[]
                {
                    new Point(this.Width / 2, 0),
                    new Point(this.Width, 40),
                    new Point(this.Width - this.Width / 4, 40),
                    new Point(this.Width - this.Width / 4, this.Height - 1),
                    new Point(this.Width / 4, this.Height - 1),
                    new Point(this.Width / 4, 40),
                    new Point(0, 40),
                    new Point(this.Width / 2, 0),
                };
                break;

            case ArrowDirection.Bottom:
                ps = new Point[]
                {
                    new Point(this.Width - this.Width / 4, 0),
                    new Point(this.Width - this.Width / 4, this.Height - 40),
                    new Point(this.Width, this.Height - 40),
                    new Point(this.Width / 2, this.Height - 1),
                    new Point(0, this.Height - 40),
                    new Point(this.Width / 4, this.Height - 40),
                    new Point(this.Width / 4, 0),
                    new Point(this.Width - this.Width / 4, 0),
                };
                break;

            case ArrowDirection.Left_Right:
                ps = new Point[]
                {
                    new Point(0, this.Height / 2),
                    new Point(40, 0),
                    new Point(40, this.Height / 4),
                    new Point(this.Width - 40, this.Height / 4),
                    new Point(this.Width - 40, 0),
                    new Point(this.Width - 1, this.Height / 2),
                    new Point(this.Width - 40, this.Height),
                    new Point(this.Width - 40, this.Height - this.Height / 4),
                    new Point(40, this.Height - this.Height / 4),
                    new Point(40, this.Height),
                    new Point(0, this.Height / 2),
                };
                break;

            case ArrowDirection.Top_Bottom:
                ps = new Point[]
                {
                    new Point(this.Width / 2, 0),
                    new Point(this.Width, 40),
                    new Point(this.Width - this.Width / 4, 40),
                    new Point(this.Width - this.Width / 4, this.Height - 40),
                    new Point(this.Width, this.Height - 40),
                    new Point(this.Width / 2, this.Height - 1),
                    new Point(0, this.Height - 40),
                    new Point(this.Width / 4, this.Height - 40),
                    new Point(this.Width / 4, 40),
                    new Point(0, 40),
                    new Point(this.Width / 2, 0),
                };
                break;
            }
            m_path = new GraphicsPath();
            m_path.AddLines(ps);
            m_path.CloseAllFigures();
        }
Beispiel #12
0
        /// <summary>
        /// Creates donut-like path. Overrides the method defined in its base class -
        /// ElementShape.
        /// </summary>
        public override GraphicsPath  CreatePath(Rectangle bounds)
        {
            bool      isBorderPath = false;
            Rectangle rect         = new Rectangle(bounds.X + 10, bounds.Y, bounds.Width, bounds.Height);

            int   num1   = 12;
            int   num2   = 0x13;
            int   num3   = 0x19;
            int   num4   = (int)Math.Pow((double)num3, 2);
            Point point1 = new Point(rect.Left - num3, rect.Top + num2);

            Point[] pointArray1 = new Point[num1];
            byte[]  buffer1     = new byte[num1];
            int     num5        = (1 + rect.Left) - num1;

            for (int num6 = 0; num6 < pointArray1.Length; num6++)
            {
                int num7 = (num6 == 0) ? num5 : (1 + pointArray1[num6 - 1].X);
                int num8 = point1.Y - ((int)Math.Sqrt(num4 - Math.Pow((double)(num7 - point1.X), 2)));
                if (num8 < rect.Top)
                {
                    num8 = rect.Top;
                }
                pointArray1[num6] = new Point(num7, num8);
                buffer1[num6]     = 1;
            }
            if (!isBorderPath)
            {
                ArrayList list1 = new ArrayList();
                for (int num9 = 0; num9 < pointArray1.Length; num9++)
                {
                    list1.Add(pointArray1[num9]);
                    if (num9 != (pointArray1.Length - 1))
                    {
                        int num10 = pointArray1[num9 + 1].Y - pointArray1[num9].Y;
                        if (num10 > 1)
                        {
                            int num11 = (num10 > 4) ? ((int)Math.Round((double)(num10 / 2))) : 2;
                            for (int num12 = 1; num12 < num11; num12++)
                            {
                                list1.Add(new Point(pointArray1[num9].X, pointArray1[num9].Y + num12));
                            }
                        }
                    }
                }
                byte[] buffer2 = new byte[list1.Count];
                for (int num13 = 0; num13 < buffer2.Length; num13++)
                {
                    buffer2[num13] = 1;
                }
                pointArray1 = (Point[])list1.ToArray(typeof(Point));
                buffer1     = buffer2;
            }
            Point[]      pointArray2 = new Point[] { new Point(rect.Left, rect.Top), new Point(rect.Left - num1, rect.Top) };
            GraphicsPath path1       = new GraphicsPath();

            Point[] pointArray3 = new Point[pointArray1.Length];
            pointArray1[0] = pointArray1[1];
            for (int i = 0; i < pointArray1.Length; i++)
            {
                pointArray3[i] = pointArray1[pointArray1.Length - i - 1];
            }

            //windows 7 fix GDI+
            //p.p. 16/01/09
            GraphicsPath tempPath = new GraphicsPath();

            tempPath.AddLines(pointArray3);
            //end fix
            path1.AddPath(tempPath, true);

            path1.AddLine(bounds.Left + 10, bounds.Top, bounds.Right - 20, bounds.Top);
            if (rect.Height >= 15)
            {
                path1.AddArc(rect.Right - 20, rect.Top, 10, 20, -90, 90);
                //	path1.AddLine(rect.Right, rect.Top + 20, rect.Right, rect.Bottom - 20);

                path1.AddArc(rect.Right - 20, rect.Bottom - 20, 10, 20, 0, 90);
            }
            else
            {
                int height = rect.Height;
                if (height <= 0)
                {
                    height = 1;
                }
                path1.AddArc(rect.Right - 10, rect.Top, 10, height, 270, 180);
            }

            path1.AddLine(rect.Right - 20, rect.Bottom, rect.Left, rect.Bottom);
            path1.CloseAllFigures();
            return(path1);
        }
Beispiel #13
0
        internal static void MakeRoundedRectangularPath(GraphicsPath path, RectangleF rect, SizeF corner, int spots)
        {
            if (corner.Width > rect.Width / 2f)
            {
                corner.Width = rect.Width / 2f;
            }
            if (corner.Height > rect.Height / 2f)
            {
                corner.Height = rect.Height / 2f;
            }
            float num  = corner.Width * 2f;
            float num2 = corner.Height * 2f;

            if (num < 0.01f || num2 < 0.01f || spots == 0)
            {
                path.AddRectangle(rect);
            }
            else
            {
                float x     = rect.X;
                float y     = rect.Y;
                float num3  = x + num;
                float num4  = y + num2;
                float num5  = x + rect.Width - num;
                float num6  = y + rect.Height - num2;
                float num7  = x + rect.Width;
                float num8  = y + rect.Height;
                bool  flag  = (spots & 4) != 0;
                bool  flag2 = (spots & 8) != 0;
                bool  flag3 = (spots & 0x10) != 0;
                bool  flag4 = (spots & 2) != 0;
                if (flag)
                {
                    path.AddArc(num5, y, num, num2, 270f, 90f);
                }
                if (!flag || !flag2 || num4 < num6)
                {
                    path.AddLine(num7, flag ? num4 : y, num7, flag2 ? num6 : num8);
                }
                if (flag2)
                {
                    path.AddArc(num5, num6, num, num2, 0f, 90f);
                }
                if (!flag2 || !flag3 || num3 < num5)
                {
                    path.AddLine(flag2 ? num5 : num7, num8, flag3 ? num3 : x, num8);
                }
                if (flag3)
                {
                    path.AddArc(x, num6, num, num2, 90f, 90f);
                }
                if (!flag3 || !flag4 || num4 < num6)
                {
                    path.AddLine(x, flag3 ? num6 : num8, x, flag4 ? num4 : y);
                }
                if (flag4)
                {
                    path.AddArc(x, y, num, num2, 180f, 90f);
                }
            }
            path.CloseAllFigures();
        }
Beispiel #14
0
    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;
    }
Beispiel #15
0
    public Captcha(bool useNumbers, int LetterCount, Extension extension)
    {
        if (extension < 0 || extension > (Extension)3)
        {
            throw new Exception("Расширение должнобыть в диапазоне от 0 до 3");
        }
        _extension = extension;

        // Задаем паттерны пунктиров и промежутков для ручки
        _pen.DashStyle   = DashStyle.Custom;
        _pen.DashPattern = _myPattern;
        _useNumbers      = useNumbers;
        if (LetterCount < 4 || LetterCount > 7)
        {
            throw new Exception("Количество символов должно быть в диапазоне от 4 до 7");
        }
        _letterCount = LetterCount;

        // Сглаживаем
        _graphic.SmoothingMode = SmoothingMode.AntiAlias;
        //Заливаем белым фоном область изображения
        _graphic.FillRectangle(Brushes.White, new Rectangle(0, 0, 400, 150));
        // Формат строки выравнивание строки по центру и по высоте по центру
        StringFormat stringFormat = new StringFormat();

        stringFormat.Alignment     = StringAlignment.Center;
        stringFormat.LineAlignment = StringAlignment.Center;
        int index = 0;

        do
        {
            if (index == 0)
            {
                // Посев окружностей
                int randLines = rnd.Next(5, 11);
                for (int i = 0; i < randLines; i++)
                {
                    _path       = new GraphicsPath();
                    _layoutRect = CreatRectForCircle();

                    // Добавляем окружность в path
                    _path.StartFigure();
                    _path.AddEllipse(_layoutRect);
                    _path.CloseAllFigures();

                    // Вращаем path
                    RotatePath(_path, _layoutRect, -45, 46);

                    // Рандомно либо обводим инструментом Pen границы области Path либо заливаем сплошным цветом область path
                    if (rnd.Next(2) == 1)
                    {
                        _pen.Color = GetRandomColor(); _graphic.DrawPath(_pen, _path);
                    }
                    else
                    {
                        _graphic.FillPath(PickBrush(1), _path);
                    }
                }

                //Посев линий
                randLines = rnd.Next(10, 16);
                for (int i = 0; i < randLines; i++)
                {
                    _pen.Color = GetRandomColor();
                    if (rnd.Next(2) == 1)
                    {
                        _graphic.DrawLine(_pen, new Point(rnd.Next(5, 196), rnd.Next(5, 71)), new Point(rnd.Next(205, 396), rnd.Next(80, 146)));
                    }
                    else
                    {
                        { _graphic.DrawLine(_pen, new Point(rnd.Next(205, 396), rnd.Next(5, 71)), new Point(rnd.Next(5, 196), rnd.Next(80, 146))); }
                    }
                }

                //Посев точек
                randLines = rnd.Next(6000, 12000);
                for (int i = 0; i < randLines; i++)
                {
                    int temp = rnd.Next(4);
                    _pen.Color = GetRandomColor();

                    //изображение условно делится на 4 прямоугольника где рандомно проставляются точки глиф
                    if (temp == 0)
                    {
                        _graphic.FillRectangle(PickBrush(0), rnd.Next(5, 200), rnd.Next(5, 70), 1, 1);
                    }
                    else if (temp == 1)
                    {
                        _graphic.FillRectangle(PickBrush(0), rnd.Next(200, 396), rnd.Next(5, 70), 1, 1);
                    }
                    else if (temp == 2)
                    {
                        _graphic.FillRectangle(PickBrush(0), rnd.Next(5, 200), rnd.Next(70, 146), 1, 1);
                    }
                    else if (temp == 3)
                    {
                        _graphic.FillRectangle(PickBrush(0), rnd.Next(200, 396), rnd.Next(70, 146), 1, 1);
                    }
                }
            }
            #region Отрисовка символов
            _path = new GraphicsPath();
            if (!_useNumbers)
            {
                _imageStr = getRandomSymbol();
            }
            else
            {
                _imageStr = getRandomSymbol();
            }
            _layoutRect        = new Rectangle();
            _layoutRect.Width  = _image.Width / _letterCount;
            _layoutRect.Height = _image.Height;
            _layoutRect.X      = (_image.Width / _letterCount) * index + rnd.Next(-3, 3);
            _layoutRect.Y      = rnd.Next(-5, 5);

            //Добавляем string в path
            _path.StartFigure();
            _path.AddString(_imageStr, _family, (int)(FontStyle.Bold | FontStyle.Italic), rnd.Next(80, 90), _layoutRect, stringFormat);
            _path.CloseAllFigures();

            // Вращаем path
            RotatePath(_path, _layoutRect, -20, 21);

            // Заливаем сплошным цветом path
            _graphic.FillPath(PickBrush(1), _path);
            _pen.Color = GetRandomColor();
            _graphic.DrawPath(_pen, _path);
            #endregion
            index++;
        }while (index < _letterCount);

        //Сохранение изображения в файл
        _image.Save(@"C:\Users\llgiant\OneDrive\Dev\bitmap.bmp",
                    ImageFormat.Bmp);
    }
Beispiel #16
0
        public override void Draw(Graphics graphics, RenderMode renderMode)
        {
            if (TargetGripper == null)
            {
                return;
            }
            graphics.SmoothingMode      = SmoothingMode.HighQuality;
            graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.PixelOffsetMode    = PixelOffsetMode.None;
            graphics.TextRenderingHint  = TextRenderingHint.SystemDefault;

            Color lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            Color fillColor     = GetFieldValueAsColor(FieldType.FILL_COLOR);
            int   lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);

            bool      lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
            Rectangle rect        = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            if (Selected && renderMode == RenderMode.EDIT)
            {
                DrawSelectionBorder(graphics, rect);
            }

            int tailAngle  = 90 + (int)GeometryHelper.Angle2D(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2), TargetGripper.Left, TargetGripper.Top);
            int tailLength = GeometryHelper.Distance2D(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2), TargetGripper.Left, TargetGripper.Top);
            int tailWidth  = (Math.Abs(rect.Width) + Math.Abs(rect.Height)) / 20;

            GraphicsPath bubble = new GraphicsPath();

            Rectangle bubbleRect = GuiRectangle.GetGuiRectangle(0, 0, rect.Width, rect.Height);
            // adapt corner radius to small rectangle dimensions
            int smallerSideLength = Math.Min(bubbleRect.Width, bubbleRect.Height);
            int cornerRadius      = Math.Min(30, smallerSideLength / 2 - lineThickness);

            if (cornerRadius > 0)
            {
                bubble.AddArc(bubbleRect.X, bubbleRect.Y, cornerRadius, cornerRadius, 180, 90);
                bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y, cornerRadius, cornerRadius, 270, 90);
                bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 0, 90);
                bubble.AddArc(bubbleRect.X, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 90, 90);
            }
            else
            {
                bubble.AddRectangle(bubbleRect);
            }
            bubble.CloseAllFigures();

            GraphicsPath tail = new GraphicsPath();

            tail.AddLine(-tailWidth, 0, tailWidth, 0);
            tail.AddLine(tailWidth, 0, 0, -tailLength);
            tail.CloseFigure();

            GraphicsState state = graphics.Save();

            // draw the tail border where the bubble is not visible
            using (Region clipRegion = new Region(bubble))
            {
                clipRegion.Translate(rect.Left, rect.Top);
                graphics.SetClip(clipRegion, CombineMode.Exclude);
                graphics.TranslateTransform(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
                graphics.RotateTransform(tailAngle);
                using (Pen pen = new Pen(lineColor, lineThickness))
                {
                    graphics.DrawPath(pen, tail);
                }
            }
            graphics.Restore(state);

            if (Colors.IsVisible(fillColor))
            {
                //draw the bubbleshape
                state = graphics.Save();
                graphics.TranslateTransform(rect.Left, rect.Top);
                using (Brush brush = new SolidBrush(fillColor))
                {
                    graphics.FillPath(brush, bubble);
                }
                graphics.Restore(state);
            }

            if (lineVisible)
            {
                //draw the bubble border
                state = graphics.Save();
                // Draw bubble where the Tail is not visible.
                using (Region clipRegion = new Region(tail))
                {
                    using (Matrix transformMatrix = new Matrix())
                    {
                        transformMatrix.Rotate(tailAngle);
                        clipRegion.Transform(transformMatrix);
                    }
                    clipRegion.Translate(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
                    graphics.SetClip(clipRegion, CombineMode.Exclude);
                    graphics.TranslateTransform(rect.Left, rect.Top);
                    using (Pen pen = new Pen(lineColor, lineThickness))
                    {
                        //pen.EndCap = pen.StartCap = LineCap.Round;
                        graphics.DrawPath(pen, bubble);
                    }
                }
                graphics.Restore(state);
            }

            if (Colors.IsVisible(fillColor))
            {
                // Draw the tail border
                state = graphics.Save();
                graphics.TranslateTransform(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
                graphics.RotateTransform(tailAngle);
                using (Brush brush = new SolidBrush(fillColor))
                {
                    graphics.FillPath(brush, tail);
                }
                graphics.Restore(state);
            }

            // cleanup the paths
            bubble.Dispose();
            tail.Dispose();

            // Draw the text
            UpdateFormat();
            DrawText(graphics, rect, lineThickness, lineColor, false, StringFormat, Text, Font);
        }
Beispiel #17
0
        private GraphicsPath GetArrowPath(ChartGraphics graphics, RectangleF position)
        {
            RectangleF   absoluteRectangle = graphics.GetAbsoluteRectangle(position);
            PointF       location          = absoluteRectangle.Location;
            PointF       pointF            = new PointF(absoluteRectangle.Right, absoluteRectangle.Bottom);
            float        num          = pointF.X - location.X;
            float        num2         = pointF.Y - location.Y;
            float        num3         = (float)Math.Sqrt((double)(num * num + num2 * num2));
            GraphicsPath graphicsPath = new GraphicsPath();

            PointF[] array = null;
            float    num4  = 2.1f;

            if (this.ArrowStyle == ArrowStyle.Simple)
            {
                array = new PointF[7]
                {
                    location,
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y - (float)this.ArrowSize * num4),
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y - (float)this.ArrowSize),
                    new PointF(location.X + num3, location.Y - (float)this.ArrowSize),
                    new PointF(location.X + num3, location.Y + (float)this.ArrowSize),
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y + (float)this.ArrowSize),
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y + (float)this.ArrowSize * num4)
                };
                goto IL_0551;
            }
            if (this.ArrowStyle == ArrowStyle.DoubleArrow)
            {
                array = new PointF[10]
                {
                    location,
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y - (float)this.ArrowSize * num4),
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y - (float)this.ArrowSize),
                    new PointF(location.X + num3 - (float)this.ArrowSize * num4, location.Y - (float)this.ArrowSize),
                    new PointF(location.X + num3 - (float)this.ArrowSize * num4, location.Y - (float)this.ArrowSize * num4),
                    new PointF(location.X + num3, location.Y),
                    new PointF(location.X + num3 - (float)this.ArrowSize * num4, location.Y + (float)this.ArrowSize * num4),
                    new PointF(location.X + num3 - (float)this.ArrowSize * num4, location.Y + (float)this.ArrowSize),
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y + (float)this.ArrowSize),
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y + (float)this.ArrowSize * num4)
                };
                goto IL_0551;
            }
            if (this.ArrowStyle == ArrowStyle.Tailed)
            {
                float num5 = 2.1f;
                array = new PointF[8]
                {
                    location,
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y - (float)this.ArrowSize * num4),
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y - (float)this.ArrowSize),
                    new PointF(location.X + num3, location.Y - (float)this.ArrowSize * num5),
                    new PointF(location.X + num3 - (float)this.ArrowSize * num5, location.Y),
                    new PointF(location.X + num3, location.Y + (float)this.ArrowSize * num5),
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y + (float)this.ArrowSize),
                    new PointF(location.X + (float)this.ArrowSize * num4, location.Y + (float)this.ArrowSize * num4)
                };
                goto IL_0551;
            }
            throw new InvalidOperationException(SR.ExceptionAnnotationArrowStyleUnknown);
IL_0551:
            graphicsPath.AddLines(array);
            graphicsPath.CloseAllFigures();
            float num6 = (float)(Math.Atan((double)(num2 / num)) * 180.0 / 3.1415926535897931);

            if (num < 0.0)
            {
                num6 = (float)(num6 + 180.0);
            }
            using (Matrix matrix = new Matrix())
            {
                matrix.RotateAt(num6, location);
                graphicsPath.Transform(matrix);
                return(graphicsPath);
            }
        }
        /// <summary>This method will paint the control.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintBack(Graphics g)
        {
            //Set Graphics smoothing mode to Anit-Alias--
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //-------------------------------------------

            //Declare Variables------------------
            int                 ArcWidth                = this.RoundCorners * 2;
            int                 ArcHeight               = this.RoundCorners * 2;
            int                 ArcX1                   = 0;
            int                 ArcX2                   = (this.ShadowControl) ? (this.Width - (ArcWidth + 1)) - this.ShadowThickness : this.Width - (ArcWidth + 1);
            int                 ArcY1                   = 10;
            int                 ArcY2                   = (this.ShadowControl) ? (this.Height - (ArcHeight + 1)) - this.ShadowThickness : this.Height - (ArcHeight + 1);
            GraphicsPath        path                    = new GraphicsPath();
            Brush               BorderBrush             = new SolidBrush(this.BorderColor);
            Pen                 BorderPen               = new Pen(BorderBrush, this.BorderThickness);
            LinearGradientBrush BackgroundGradientBrush = null;
            Brush               BackgroundBrush         = new SolidBrush(this.BackgroundColor);
            SolidBrush          ShadowBrush             = null;
            GraphicsPath        ShadowPath              = null;

            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new GraphicsPath();
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle);
                // TopCount Left
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle);
                //TopCount Right
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle);
                //Bottom Right
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);
                //Bottom Left
                ShadowPath.CloseAllFigures();

                //Paint Rounded Rectangle------------
                g.FillPath(ShadowBrush, ShadowPath);
                //-----------------------------------
            }
            //-----------------------------------

            //Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle); // TopCount Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle); //TopCount Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle); //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);  //Bottom Left
            path.CloseAllFigures();
            //-----------------------------------

            //Check if Gradient Mode is enabled--
            if (this.BackgroundGradientMode == GroupBoxGradientMode.None)
            {
                //Paint Rounded Rectangle------------
                g.FillPath(BackgroundBrush, path);
                //-----------------------------------
            }
            else
            {
                BackgroundGradientBrush = new LinearGradientBrush(
                    new Rectangle(0, 0, this.Width, this.Height),
                    this.BackgroundColor,
                    this.BackgroundGradientColor,
                    (LinearGradientMode)this.BackgroundGradientMode);

                //Paint Rounded Rectangle------------
                g.FillPath(BackgroundGradientBrush, path);
                //-----------------------------------
            }
            //-----------------------------------

            //Paint Borded-----------------------
            g.DrawPath(BorderPen, path);
            //-----------------------------------

            //Destroy Graphic Objects------------
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderBrush.Dispose();
            }
            if (BorderPen != null)
            {
                BorderPen.Dispose();
            }
            if (BackgroundGradientBrush != null)
            {
                BackgroundGradientBrush.Dispose();
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
            if (ShadowBrush != null)
            {
                ShadowBrush.Dispose();
            }
            if (ShadowPath != null)
            {
                ShadowPath.Dispose();
            }
            //-----------------------------------
        }
 public void CloseAllFigures()
 {
     Changed();
     gdiPath.CloseAllFigures();
 }
Beispiel #20
0
        private static Region GetRegion(float x, float y, float width, float height, float r, Corner exclude)
        {
            GraphicsPath path = new GraphicsPath();

            //If radius is equal to zero,
            //than return a simple rectangle region.
            if (r == 0.0F)
            {
                path.AddRectangle(new RectangleF(x, y, width, height));
                return(new Region(path));
            }

            //Small corner square-rectangles width
            float w = r + r;

            //If 'w' is bigger than the smallest value of the whidth/height,
            //than assign the smallest value of the whidth/height to 'w'.
            if (height < width)
            {
                if (w > height)
                {
                    w = height;
                }
            }
            else
            {
                if (w > width)
                {
                    w = width;
                }
            }
            path.StartFigure();
            //Set top-left corner.
            if ((exclude & Corner.TopLeft) != Corner.TopLeft)
            {
                path.AddLine(x, y + r, x, y + r);
                path.AddArc(x, y, w - 1.0F, w - 1.0F, 180.0F, 90.0F);
                path.AddLine(x + r, y, x + r, y);
            }
            else
            {
                path.AddLine(x, y, x, y);
            }
            //Set top-right corner.
            if ((exclude & Corner.TopRight) != Corner.TopRight)
            {
                path.AddLine(x + width - r, y, x + width - r, y);
                path.AddArc(x + width - w, y, w - 1.0F, w - 1.0F, 270.0F, 90.0F);
                path.AddLine(x + width, y + r, x + width, y + r);
            }
            else
            {
                path.AddLine(x + width, y, x + width, y);
            }
            //Set bottom-right corner.
            if ((exclude & Corner.BottomRight) != Corner.BottomRight)
            {
                path.AddLine(x + width, y + height - r - 1.0F, x + width, y + height - r - 1.0F);
                path.AddArc(x + width - w, y + height - w, w - 1.0F, w - 1.0F, 0.0F, 90.0F);
                path.AddLine(x + width - r - 1.0F, y + height, x + width - r - 1.0F, y + height);
            }
            else
            {
                path.AddLine(x + width, y + height, x + width, y + height);
            }
            //Set bottom-left corner.
            if ((exclude & Corner.BottomLeft) != Corner.BottomLeft)
            {
                path.AddLine(x + r + 1.0F, y + height, x + r + 1.0F, y + height);
                path.AddArc(x, y + height - w, w - 1.0F, w - 1.0F, 90.0F, 90.0F);
                path.AddLine(x, y + height - r - 1.0F, x, y + height - r - 1.0F);
            }
            else
            {
                path.AddLine(x, y + height, x, y + height);
            }
            path.CloseAllFigures();
            return(new Region(path));
        }
Beispiel #21
0
        private static GraphicsPath GetSegment7(LEDSegment7 segment, PointF p, float size)
        {
            GraphicsPath graphicsPath = new GraphicsPath();
            SizeF        sizeF        = new SizeF(size * 0.618034f, size);
            float        num          = sizeF.Width * 0.142857149f;
            SizeF        s            = new SizeF(sizeF.Width - num, num);
            SizeF        s2           = new SizeF(sizeF.Height / 2f - num / 2f, num);

            s.Width  -= num / 3f;
            s2.Width -= num / 3f;
            switch (segment)
            {
            case LEDSegment7.Empty:
            case LEDSegment7.SA:
            case LEDSegment7.SB:
            case LEDSegment7.SA | LEDSegment7.SB:
            case LEDSegment7.SC:
            case LEDSegment7.SA | LEDSegment7.SC:
            case LEDSegment7.N1:
            case LEDSegment7.N7:
            case LEDSegment7.SD:
            case LEDSegment7.SA | LEDSegment7.SD:
            case LEDSegment7.SB | LEDSegment7.SD:
            case LEDSegment7.SA | LEDSegment7.SB | LEDSegment7.SD:
            case LEDSegment7.SC | LEDSegment7.SD:
            case LEDSegment7.SA | LEDSegment7.SC | LEDSegment7.SD:
            case LEDSegment7.SB | LEDSegment7.SC | LEDSegment7.SD:
            case LEDSegment7.SA | LEDSegment7.SB | LEDSegment7.SC | LEDSegment7.SD:
            case LEDSegment7.SE:
            {
                LEDSegment7 num2 = segment - 1;
                if (num2 <= (LEDSegment7.SA | LEDSegment7.SB))
                {
                    switch (num2)
                    {
                    case LEDSegment7.Empty:
                    {
                        graphicsPath.AddPolygon(GetSegment7(p, s));
                        graphicsPath.CloseAllFigures();
                        using (Matrix matrix6 = new Matrix())
                        {
                            matrix6.Translate(0f, (0f - sizeF.Height) / 2f + num / 2f);
                            graphicsPath.Transform(matrix6);
                            return(graphicsPath);
                        }
                    }

                    case LEDSegment7.SA | LEDSegment7.SB:
                    {
                        graphicsPath.AddPolygon(GetSegment7(p, s2));
                        graphicsPath.CloseAllFigures();
                        using (Matrix matrix5 = new Matrix())
                        {
                            matrix5.RotateAt(90f, p);
                            graphicsPath.Transform(matrix5);
                            matrix5.Reset();
                            matrix5.Translate(sizeF.Width / 2f - num / 2f, sizeF.Height / 4f - num / 4f);
                            graphicsPath.Transform(matrix5);
                            return(graphicsPath);
                        }
                    }

                    case LEDSegment7.SA:
                    {
                        graphicsPath.AddPolygon(GetSegment7(p, s2));
                        graphicsPath.CloseAllFigures();
                        using (Matrix matrix4 = new Matrix())
                        {
                            matrix4.RotateAt(90f, p);
                            graphicsPath.Transform(matrix4);
                            matrix4.Reset();
                            matrix4.Translate(sizeF.Width / 2f - num / 2f, (0f - sizeF.Height) / 4f + num / 4f);
                            graphicsPath.Transform(matrix4);
                            return(graphicsPath);
                        }
                    }

                    case LEDSegment7.SB:
                        goto end_IL_007f;
                    }
                }
                switch (segment)
                {
                case LEDSegment7.SD:
                {
                    graphicsPath.AddPolygon(GetSegment7(p, s));
                    graphicsPath.CloseAllFigures();
                    using (Matrix matrix8 = new Matrix())
                    {
                        matrix8.RotateAt(180f, p);
                        graphicsPath.Transform(matrix8);
                        matrix8.Reset();
                        matrix8.Translate(0f, sizeF.Height / 2f - num / 2f);
                        graphicsPath.Transform(matrix8);
                        return(graphicsPath);
                    }
                }

                case LEDSegment7.SE:
                {
                    graphicsPath.AddPolygon(GetSegment7(p, s2));
                    graphicsPath.CloseAllFigures();
                    using (Matrix matrix7 = new Matrix())
                    {
                        matrix7.RotateAt(90f, p);
                        graphicsPath.Transform(matrix7);
                        matrix7.Reset();
                        matrix7.Translate((0f - sizeF.Width) / 2f + num / 2f, sizeF.Height / 4f - num / 4f);
                        graphicsPath.Transform(matrix7);
                        return(graphicsPath);
                    }
                }
                }
                break;
            }

            case LEDSegment7.SG:
                graphicsPath.AddPolygon(GetSegment7(p, s));
                graphicsPath.CloseAllFigures();
                break;

            case LEDSegment7.SF:
            {
                graphicsPath.AddPolygon(GetSegment7(p, s2));
                graphicsPath.CloseAllFigures();
                using (Matrix matrix3 = new Matrix())
                {
                    matrix3.RotateAt(90f, p);
                    graphicsPath.Transform(matrix3);
                    matrix3.Reset();
                    matrix3.Translate((0f - sizeF.Width) / 2f + num / 2f, (0f - sizeF.Height) / 4f + num / 4f);
                    graphicsPath.Transform(matrix3);
                    return(graphicsPath);
                }
            }

            case LEDSegment7.SDP:
            {
                graphicsPath.AddEllipse(p.X, p.Y, num * 2f, num * 2f);
                using (Matrix matrix2 = new Matrix())
                {
                    matrix2.Translate(sizeF.Width / 2f + num / 2f, sizeF.Height / 2f - num * 2f);
                    graphicsPath.Transform(matrix2);
                    return(graphicsPath);
                }
            }

            case LEDSegment7.SComma:
            {
                graphicsPath.AddRectangle(new RectangleF(p.X, p.Y, num * 2f, num * 4f));
                using (Matrix matrix = new Matrix())
                {
                    matrix.Translate(sizeF.Width / 2f + num / 2f, sizeF.Height / 2f - num * 2f);
                    graphicsPath.Transform(matrix);
                    return(graphicsPath);
                }
            }
end_IL_007f:
                break;
            }
            return(graphicsPath);
        }
Beispiel #22
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.SetGDIHigh();
            if (m_value == '.')
            {
                Rectangle r2 = new Rectangle(m_drawRect.Left + (m_drawRect.Width - m_lineWidth) / 2, m_drawRect.Bottom - m_lineWidth * 2, m_lineWidth, m_lineWidth);
                e.Graphics.FillRectangle(new SolidBrush(ForeColor), r2);
            }
            else if (m_value == ':')
            {
                Rectangle r1 = new Rectangle(m_drawRect.Left + (m_drawRect.Width - m_lineWidth) / 2, m_drawRect.Top + (m_drawRect.Height / 2 - m_lineWidth) / 2, m_lineWidth, m_lineWidth);
                e.Graphics.FillRectangle(new SolidBrush(ForeColor), r1);
                Rectangle r2 = new Rectangle(m_drawRect.Left + (m_drawRect.Width - m_lineWidth) / 2, m_drawRect.Top + (m_drawRect.Height / 2 - m_lineWidth) / 2 + m_drawRect.Height / 2, m_lineWidth, m_lineWidth);
                e.Graphics.FillRectangle(new SolidBrush(ForeColor), r2);
            }
            else
            {
                int[] vs = m_nums[m_value];
                if (vs.Contains(1))
                {
                    GraphicsPath path = new GraphicsPath();
                    path.AddLines(new Point[]
                    {
                        new Point(m_drawRect.Left + 2, m_drawRect.Top),
                        new Point(m_drawRect.Right - 2, m_drawRect.Top),
                        new Point(m_drawRect.Right - m_lineWidth - 2, m_drawRect.Top + m_lineWidth),
                        new Point(m_drawRect.Left + m_lineWidth + 2, m_drawRect.Top + m_lineWidth),
                        new Point(m_drawRect.Left + 2, m_drawRect.Top)
                    });
                    path.CloseAllFigures();
                    e.Graphics.FillPath(new SolidBrush(ForeColor), path);
                }

                if (vs.Contains(2))
                {
                    GraphicsPath path = new GraphicsPath();
                    path.AddLines(new Point[]
                    {
                        new Point(m_drawRect.Right, m_drawRect.Top),
                        new Point(m_drawRect.Right, m_drawRect.Top + (m_drawRect.Height - m_lineWidth - 4) / 2),
                        new Point(m_drawRect.Right - m_lineWidth / 2, m_drawRect.Top + (m_drawRect.Height - m_lineWidth - 4) / 2 + m_lineWidth / 2),
                        new Point(m_drawRect.Right - m_lineWidth, m_drawRect.Top + (m_drawRect.Height - m_lineWidth - 4) / 2),
                        new Point(m_drawRect.Right - m_lineWidth, m_drawRect.Top + m_lineWidth),
                        new Point(m_drawRect.Right, m_drawRect.Top)
                    });
                    path.CloseAllFigures();
                    e.Graphics.FillPath(new SolidBrush(ForeColor), path);
                }

                if (vs.Contains(3))
                {
                    GraphicsPath path = new GraphicsPath();
                    path.AddLines(new Point[]
                    {
                        new Point(m_drawRect.Right, m_drawRect.Bottom - (m_drawRect.Height - m_lineWidth - 4) / 2),
                        new Point(m_drawRect.Right, m_drawRect.Bottom),
                        new Point(m_drawRect.Right - m_lineWidth, m_drawRect.Bottom - m_lineWidth),
                        new Point(m_drawRect.Right - m_lineWidth, m_drawRect.Bottom - (m_drawRect.Height - m_lineWidth - 4) / 2),
                        new Point(m_drawRect.Right - m_lineWidth / 2, m_drawRect.Bottom - (m_drawRect.Height - m_lineWidth - 4) / 2 - m_lineWidth / 2),
                        new Point(m_drawRect.Right, m_drawRect.Bottom - (m_drawRect.Height - m_lineWidth - 4) / 2),
                    });
                    path.CloseAllFigures();
                    e.Graphics.FillPath(new SolidBrush(ForeColor), path);
                }

                if (vs.Contains(4))
                {
                    GraphicsPath path = new GraphicsPath();
                    path.AddLines(new Point[]
                    {
                        new Point(m_drawRect.Left + 2, m_drawRect.Bottom),
                        new Point(m_drawRect.Right - 2, m_drawRect.Bottom),
                        new Point(m_drawRect.Right - m_lineWidth - 2, m_drawRect.Bottom - m_lineWidth),
                        new Point(m_drawRect.Left + m_lineWidth + 2, m_drawRect.Bottom - m_lineWidth),
                        new Point(m_drawRect.Left + 2, m_drawRect.Bottom)
                    });
                    path.CloseAllFigures();
                    e.Graphics.FillPath(new SolidBrush(ForeColor), path);
                }

                if (vs.Contains(5))
                {
                    GraphicsPath path = new GraphicsPath();
                    path.AddLines(new Point[]
                    {
                        new Point(m_drawRect.Left, m_drawRect.Bottom - (m_drawRect.Height - m_lineWidth - 4) / 2),
                        new Point(m_drawRect.Left, m_drawRect.Bottom),
                        new Point(m_drawRect.Left + m_lineWidth, m_drawRect.Bottom - m_lineWidth),
                        new Point(m_drawRect.Left + m_lineWidth, m_drawRect.Bottom - (m_drawRect.Height - m_lineWidth - 4) / 2),
                        new Point(m_drawRect.Left + m_lineWidth / 2, m_drawRect.Bottom - (m_drawRect.Height - m_lineWidth - 4) / 2 - m_lineWidth / 2),
                        new Point(m_drawRect.Left, m_drawRect.Bottom - (m_drawRect.Height - m_lineWidth - 4) / 2),
                    });
                    path.CloseAllFigures();
                    e.Graphics.FillPath(new SolidBrush(ForeColor), path);
                }


                if (vs.Contains(6))
                {
                    GraphicsPath path = new GraphicsPath();
                    path.AddLines(new Point[]
                    {
                        new Point(m_drawRect.Left, m_drawRect.Top),
                        new Point(m_drawRect.Left, m_drawRect.Top + (m_drawRect.Height - m_lineWidth - 4) / 2),
                        new Point(m_drawRect.Left + m_lineWidth / 2, m_drawRect.Top + (m_drawRect.Height - m_lineWidth - 4) / 2 + m_lineWidth / 2),
                        new Point(m_drawRect.Left + m_lineWidth, m_drawRect.Top + (m_drawRect.Height - m_lineWidth - 4) / 2),
                        new Point(m_drawRect.Left + m_lineWidth, m_drawRect.Top + m_lineWidth),
                        new Point(m_drawRect.Left, m_drawRect.Top)
                    });
                    path.CloseAllFigures();
                    e.Graphics.FillPath(new SolidBrush(ForeColor), path);
                }

                if (vs.Contains(7))
                {
                    GraphicsPath path = new GraphicsPath();
                    path.AddLines(new Point[]
                    {
                        new Point(m_drawRect.Left + m_lineWidth / 2, m_drawRect.Height / 2 + 1),
                        new Point(m_drawRect.Left + m_lineWidth, m_drawRect.Height / 2 - m_lineWidth / 2 + 1),
                        new Point(m_drawRect.Right - m_lineWidth, m_drawRect.Height / 2 - m_lineWidth / 2 + 1),
                        new Point(m_drawRect.Right - m_lineWidth / 2, m_drawRect.Height / 2 + 1),
                        new Point(m_drawRect.Right - m_lineWidth, m_drawRect.Height / 2 + m_lineWidth / 2 + 1),
                        new Point(m_drawRect.Left + m_lineWidth, m_drawRect.Height / 2 + m_lineWidth / 2 + 1),
                        new Point(m_drawRect.Left + m_lineWidth / 2, m_drawRect.Height / 2 + 1)
                    });
                    path.CloseAllFigures();
                    e.Graphics.FillPath(new SolidBrush(ForeColor), path);
                }
            }
        }
Beispiel #23
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            var g = pevent.Graphics;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            g.Clear(Parent.BackColor);
            //Hover
            Color c = Warning ? SkinManager.WaringColor : SkinManager.GetFlatButtonHoverBackgroundColor();

            //using (Brush b = new SolidBrush(Color.FromArgb((int)(_hoverAnimationManager.GetProgress() * c.A), c.RemoveAlpha())))
            //    g.FillRectangle(b, ClientRectangle);


            g.SmoothingMode = SmoothingMode.AntiAlias;

            GraphicsPath gp = new GraphicsPath();

            gp.AddArc(this.ClientRectangle.X, this.ClientRectangle.Y, Bounds.Height - 1, Bounds.Height - 1, 90, 180);
            gp.AddLine(new Point(this.ClientRectangle.X + Bounds.Height / 2, this.ClientRectangle.Y), new Point(this.ClientRectangle.X + Bounds.Width - Bounds.Height / 2, this.ClientRectangle.Y));
            gp.AddArc(this.ClientRectangle.X + Bounds.Width - Bounds.Height, this.ClientRectangle.Y, Bounds.Height - 1, Bounds.Height - 1, 270, 180);
            gp.CloseAllFigures();
            using (Pen pen = new Pen(SkinManager.RoundButtonBorderColor, 1.5f))
                g.DrawPath(pen, gp);

            using (Brush b = new SolidBrush(c /*Color.FromArgb((int)(_hoverAnimationManager.GetProgress() * c.A), c.RemoveAlpha())*/))
                g.FillPath(b, gp);
            gp.Dispose();

            //Ripple
            if (_animationManager.IsAnimating())
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;

                for (var i = 0; i < _animationManager.GetAnimationCount(); i++)
                {
                    var animationValue  = _animationManager.GetProgress(i);
                    var animationSource = _animationManager.GetSource(i);

                    using (Brush rippleBrush = new SolidBrush(Color.FromArgb((int)(101 - (animationValue * 100)), Color.Black)))
                    {
                        var rippleSize = (int)(animationValue * Width * 2);
                        g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
                    }
                }
                g.SmoothingMode = SmoothingMode.None;
            }
            //Icon
            var iconRect = new Rectangle(8, 6, 24, 24);

            if (string.IsNullOrEmpty(Text))
            {
                // Center Icon
                iconRect.X += 2;
            }

            if (Icon != null)
            {
                g.DrawImage(Icon, iconRect);
            }

            //Text
            var textRect = ClientRectangle;

            if (Icon != null)
            {
                //
                // Resize and move Text container
                //

                // First 8: left padding
                // 24: icon width
                // Second 4: space between Icon and Text
                // Third 8: right padding
                textRect.Width -= 8 + 24 + 4 + 8;

                // First 8: left padding
                // 24: icon width
                // Second 4: space between Icon and Text
                textRect.X += 8 + 24 + 4;
            }

            using (SolidBrush sb = new SolidBrush(SkinManager.GetLabelTextColor()))
                using (StringFormat sf = new StringFormat {
                    Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                })
                {
                    g.DrawString(Text, SkinManager.PINGFANG_MEDIUM_10, sb, textRect, sf);
                }
        }
Beispiel #24
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            // Create a GraphicsPath object.
            GraphicsPath myPath = new GraphicsPath();

            // Set up and call AddArc, and close the figure.
            Rectangle rect = new Rectangle(20, 20, 50, 100);

            myPath.StartFigure();
            myPath.AddArc(rect, 0, 180);
            myPath.CloseFigure();

            // Draw the path to screen.
            // gfx.DrawPath(new Pen(Color.Red, 3), myPath);

            // return;
            Pen DrawPen = new Pen(Color.FromArgb(70, Color.Black));

            CornerRadius = 10;
            int       strokeOffset = 1;
            Rectangle Bounds       = new Rectangle(strokeOffset, strokeOffset, Width - strokeOffset * 2, Height - strokeOffset * 2);

            Graphics gfx = e.Graphics;

            gfx.SmoothingMode = SmoothingMode.AntiAlias;


            DrawPen.Width  = 1;
            DrawPen.EndCap = DrawPen.StartCap = LineCap.Round;
            Color FillColor = Color.WhiteSmoke;

            int notch = CornerRadius + (CornerRadius >> 1);
            int along = 200;

            using (GraphicsPath gfxPath = new GraphicsPath())
            {
                // Top Left
                //gfxPath.AddArc(Bounds.X, Bounds.Y + notch, CornerRadius, CornerRadius, 180, 90);

                //// Notch Left
                ////gfxPath.AddArc(Bounds.X + along, Bounds.Y + notch - CornerRadius, CornerRadius, CornerRadius, 90, -90);

                ////gfxPath.AddArc(Bounds.X + along + CornerRadius, Bounds.Y - CornerRadius, CornerRadius, CornerRadius, 0, 90);

                //// Top Right
                //gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y, CornerRadius, CornerRadius, 270, 90);
                //gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y + notch + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
                //gfxPath.AddArc(Bounds.X, Bounds.Y + notch + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);

                int X      = Bounds.X;
                int radius = CornerRadius;
                int Y      = Bounds.Y + notch;
                int width  = Bounds.Width;
                int height = Bounds.Height - notch;


                // TOP LINE LEFT
                //gfxPath.AddLine(X + radius, Y, X + along - (radius * 4), Y);



                gfxPath.AddArc(X + along - (int)(radius * 3), Y - notch - radius * 0, radius * 2, radius * 2, 180 + 34, 34);


                // TOP LINE RIGHT
                //gfxPath.AddLine(X + along - (radius * 0), Y - notch, X + width - (radius*2), Y - notch);


                // TOP RIGHT
                gfxPath.AddArc(X + width - (radius * 2), Y - notch, radius * 2, radius * 2, 270, 90);

                // RIGHT LINE
                // gfxPath.AddLine(X + width, Y + (radius * 1), X + width, Y + height - (radius * 2));

                // BOTTOM RIGHT
                gfxPath.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);

                // BOTTOM LINE
                // gfxPath.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);

                // BOTTOM LEFT ?
                gfxPath.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);

                // LEFT LINE
                // gfxPath.AddLine(X, Y + height - (radius * 2), X, Y + radius + notch);

                // TOP LEFT
                gfxPath.AddArc(X, Y, radius * 2, radius * 2, 180, 90);



                gfxPath.AddArc(X + along - (radius * 5), Y - radius * 2, radius * 2, radius * 2, 90, -45);

                gfxPath.CloseAllFigures();

                gfx.FillPath(new SolidBrush(FillColor), gfxPath);
                gfx.DrawPath(DrawPen, gfxPath);
            }
        }
Beispiel #25
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;
            Rectangle    rectGuan = Rectangle.Empty;    //管道
            Rectangle    rectJK1  = Rectangle.Empty;    //接口1
            Rectangle    rectJK2  = Rectangle.Empty;    //接口2
            Rectangle    rectZ    = Rectangle.Empty;    //轴
            GraphicsPath linePath = new GraphicsPath(); //管道中心线
            GraphicsPath dzPath   = new GraphicsPath(); //轴底座
            GraphicsPath bsPath   = new GraphicsPath(); //开关把手

            switch (valveStyle)
            {
            case ValveStyle.Horizontal_Top:
                rectGuan = new Rectangle(0, this.Height / 2, this.Width, this.Height / 2 - this.Height / 8);
                rectJK1  = new Rectangle(this.Height / 8, rectGuan.Top - this.Height / 8, rectGuan.Height / 2, rectGuan.Height + this.Height / 4);
                rectJK2  = new Rectangle(rectGuan.Right - this.Height / 8 - rectGuan.Height / 2, rectGuan.Top - this.Height / 8, rectGuan.Height / 2, rectGuan.Height + this.Height / 4);
                linePath.AddLine(new Point(rectGuan.Left - 10, rectGuan.Top + rectGuan.Height / 2), new Point(rectGuan.Right + 10, rectGuan.Top + rectGuan.Height / 2));
                rectZ = new Rectangle(rectGuan.Left + (rectGuan.Width - rectGuan.Height / 4) / 2, 10, rectGuan.Height / 4, rectGuan.Top - 10);
                Point[] psTop = new Point[]
                {
                    new Point(rectGuan.Left + (rectGuan.Width - rectGuan.Height / 2) / 2, rectGuan.Top - this.Height / 8 - 5),
                    new Point(rectGuan.Right - (rectGuan.Width - rectGuan.Height / 2) / 2, rectGuan.Top - this.Height / 8 - 5),
                    new Point(rectGuan.Right - (rectGuan.Width - rectGuan.Height) / 2, rectGuan.Top + 2),
                    new Point(rectGuan.Left + (rectGuan.Width - rectGuan.Height) / 2, rectGuan.Top + 2),
                };
                dzPath.AddLines(psTop);
                dzPath.CloseAllFigures();
                if (opened)
                {
                    bsPath.AddLine(rectGuan.Left + (rectGuan.Width - rectGuan.Height - 10) / 2, 10 + (rectGuan.Height / 3) / 2, rectGuan.Left + (rectGuan.Width - rectGuan.Height - 10) / 2 + rectGuan.Height + 10, 10 + (rectGuan.Height / 3) / 2);
                }
                else
                {
                    bsPath.AddLine(new Point(rectGuan.Left + rectGuan.Width / 2 - 3, 1), new Point(rectGuan.Left + rectGuan.Width / 2 + 4, rectGuan.Height + 10));
                }
                break;

            case ValveStyle.Horizontal_Bottom:
                rectGuan = new Rectangle(0, this.Height / 8, this.Width, this.Height / 2 - this.Height / 8);
                rectJK1  = new Rectangle(this.Height / 8, rectGuan.Top - this.Height / 8, rectGuan.Height / 2, rectGuan.Height + this.Height / 4);
                rectJK2  = new Rectangle(rectGuan.Right - this.Height / 8 - rectGuan.Height / 2, rectGuan.Top - this.Height / 8, rectGuan.Height / 2, rectGuan.Height + this.Height / 4);
                linePath.AddLine(new Point(rectGuan.Left - 10, rectGuan.Top + rectGuan.Height / 2), new Point(rectGuan.Right + 10, rectGuan.Top + rectGuan.Height / 2));
                rectZ = new Rectangle(rectGuan.Left + (rectGuan.Width - rectGuan.Height / 4) / 2, rectGuan.Bottom + 10, rectGuan.Height / 4, this.Height - 10 - (rectGuan.Bottom + 10));
                Point[] psBottom = new Point[]
                {
                    new Point(rectGuan.Left + (rectGuan.Width - rectGuan.Height / 2) / 2, rectGuan.Bottom + this.Height / 8 + 5),
                    new Point(rectGuan.Right - (rectGuan.Width - rectGuan.Height / 2) / 2, rectGuan.Bottom + this.Height / 8 + 5),
                    new Point(rectGuan.Right - (rectGuan.Width - rectGuan.Height) / 2, rectGuan.Bottom - 2),
                    new Point(rectGuan.Left + (rectGuan.Width - rectGuan.Height) / 2, rectGuan.Bottom - 2),
                };
                dzPath.AddLines(psBottom);
                dzPath.CloseAllFigures();
                if (opened)
                {
                    bsPath.AddLine(rectGuan.Left + (rectGuan.Width - rectGuan.Height - 10) / 2, this.Height - (10 + (rectGuan.Height / 3) / 2), rectGuan.Left + (rectGuan.Width - rectGuan.Height - 10) / 2 + rectGuan.Height + 10, this.Height - (10 + (rectGuan.Height / 3) / 2));
                }
                else
                {
                    bsPath.AddLine(new Point(rectGuan.Left + rectGuan.Width / 2 - 3, this.Height - 1), new Point(rectGuan.Left + rectGuan.Width / 2 + 4, this.Height - (rectGuan.Height + 10)));
                }
                break;

            case ValveStyle.Vertical_Left:
                rectGuan = new Rectangle(this.Width / 8, 0, this.Width / 2 - this.Width / 8, this.Height);
                rectJK1  = new Rectangle(0, this.Width / 8, rectGuan.Width + this.Width / 4, rectGuan.Width / 2);
                rectJK2  = new Rectangle(0, this.Height - this.Width / 8 - rectGuan.Width / 2, rectGuan.Width + this.Width / 4, rectGuan.Width / 2);
                linePath.AddLine(new Point(rectGuan.Left + rectGuan.Width / 2, rectGuan.Top - 10), new Point(rectGuan.Left + rectGuan.Width / 2, rectGuan.Bottom + 10));
                rectZ = new Rectangle(rectGuan.Right, rectGuan.Top + (rectGuan.Height - rectGuan.Width / 4) / 2, rectGuan.Right - 10, rectGuan.Width / 4);
                Point[] psLeft = new Point[]
                {
                    new Point(rectGuan.Right + this.Width / 8 + 5, rectGuan.Top + (rectGuan.Height - rectGuan.Width / 2) / 2),
                    new Point(rectGuan.Right + this.Width / 8 + 5, rectGuan.Top + (rectGuan.Height - rectGuan.Width / 2) / 2 + rectGuan.Width / 2),
                    new Point(rectGuan.Right - 2, rectGuan.Top + (rectGuan.Height - rectGuan.Width) / 2 + rectGuan.Width),
                    new Point(rectGuan.Right - 2, rectGuan.Top + (rectGuan.Height - rectGuan.Width) / 2),
                };
                dzPath.AddLines(psLeft);
                dzPath.CloseAllFigures();
                if (opened)
                {
                    bsPath.AddLine(this.Width - (10 + (rectGuan.Width / 3) / 2), rectGuan.Top + (rectGuan.Height - rectGuan.Width - 10) / 2, this.Width - (10 + (rectGuan.Width / 3) / 2), rectGuan.Top + (rectGuan.Height - rectGuan.Width - 10) / 2 + rectGuan.Width + 10);
                }
                else
                {
                    bsPath.AddLine(new Point(this.Width - 1, rectGuan.Top + rectGuan.Height / 2 - 3), new Point(this.Width - (rectGuan.Width + 10), rectGuan.Top + rectGuan.Height / 2 + 4));
                }
                break;

            case ValveStyle.Vertical_Right:
                rectGuan = new Rectangle(this.Width - this.Width / 8 - (this.Width / 2 - this.Width / 8), 0, this.Width / 2 - this.Width / 8, this.Height);
                rectJK1  = new Rectangle(this.Width - (rectGuan.Width + this.Width / 4), this.Width / 8, rectGuan.Width + this.Width / 4, rectGuan.Width / 2);
                rectJK2  = new Rectangle(this.Width - (rectGuan.Width + this.Width / 4), this.Height - this.Width / 8 - rectGuan.Width / 2, rectGuan.Width + this.Width / 4, rectGuan.Width / 2);
                linePath.AddLine(new Point(rectGuan.Left + rectGuan.Width / 2, rectGuan.Top - 10), new Point(rectGuan.Left + rectGuan.Width / 2, rectGuan.Bottom + 10));
                rectZ = new Rectangle(10, rectGuan.Top + (rectGuan.Height - rectGuan.Width / 4) / 2, rectGuan.Left - 10, rectGuan.Width / 4);
                Point[] psRight = new Point[]
                {
                    new Point(rectGuan.Left - (this.Width / 8 + 5), rectGuan.Top + (rectGuan.Height - rectGuan.Width / 2) / 2),
                    new Point(rectGuan.Left - (this.Width / 8 + 5), rectGuan.Top + (rectGuan.Height - rectGuan.Width / 2) / 2 + rectGuan.Width / 2),
                    new Point(rectGuan.Left + 2, rectGuan.Top + (rectGuan.Height - rectGuan.Width) / 2 + rectGuan.Width),
                    new Point(rectGuan.Left + 2, rectGuan.Top + (rectGuan.Height - rectGuan.Width) / 2),
                };
                dzPath.AddLines(psRight);
                dzPath.CloseAllFigures();

                if (opened)
                {
                    bsPath.AddLine((10 + (rectGuan.Width / 3) / 2), rectGuan.Top + (rectGuan.Height - rectGuan.Width - 10) / 2, (10 + (rectGuan.Width / 3) / 2), rectGuan.Top + (rectGuan.Height - rectGuan.Width - 10) / 2 + rectGuan.Width + 10);
                }
                else
                {
                    bsPath.AddLine(new Point(1, rectGuan.Top + rectGuan.Height / 2 - 3), new Point((rectGuan.Width + 10), rectGuan.Top + rectGuan.Height / 2 + 4));
                }
                break;
            }

            //管道
            g.FillRectangle(new SolidBrush(valveColor), rectGuan);
            //接口
            g.FillRectangle(new SolidBrush(valveColor), rectJK1);
            g.FillRectangle(new SolidBrush(Color.FromArgb(40, Color.White)), rectJK1);
            g.FillRectangle(new SolidBrush(valveColor), rectJK2);
            g.FillRectangle(new SolidBrush(Color.FromArgb(40, Color.White)), rectJK2);


            //高亮
            int intCount = (valveStyle.ToString().StartsWith("H") ? rectGuan.Height : rectGuan.Width) / 2 / 4;

            for (int i = 0; i < intCount; i++)
            {
                int _penWidth = (valveStyle.ToString().StartsWith("H") ? rectGuan.Height : rectGuan.Width) / 2 - 4 * i;
                if (_penWidth <= 0)
                {
                    _penWidth = 1;
                }
                g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), linePath);
                if (_penWidth == 1)
                {
                    break;
                }
            }

            g.SetGDIHigh();
            //轴
            g.FillRectangle(new SolidBrush(axisColor), rectZ);

            //阀门底座
            g.FillPath(new SolidBrush(asisBottomColor), dzPath);
            g.FillPath(new SolidBrush(Color.FromArgb(50, Color.White)), dzPath);

            //把手
            g.DrawPath(new Pen(new SolidBrush(switchColor), (valveStyle.ToString().StartsWith("H") ? rectGuan.Height : rectGuan.Width) / 3), bsPath);

            //液体流动
            if (opened)
            {
                Pen p = new Pen(new SolidBrush(liquidColor), 4);
                p.DashPattern = new float[] { 6, 6 };
                p.DashOffset  = intLineLeft * (LiquidDirection == LiquidDirection.Forward ? -1 : 1);
                g.DrawPath(p, linePath);
            }
        }
        /// <summary>
        /// Draw this thing
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            TransInPaint(e.Graphics);

            base.OnPaint(e);

            GraphicsPath gp  = new GraphicsPath();
            Point        pt1 = new Point(0, 0);
            Point        pt2 = new Point(this.Width, 0);

            //Line across top
            gp.AddLine(pt1, pt2);

            //Side from top to arc
            pt1   = pt2;
            pt2.Y = this.Height - ArcRadiusRight;
            gp.AddLine(pt1, pt2);

            //Draw lower right arc
            _rightEar.EarBounds = new Rectangle(
                this.Width - ArcRadiusRight,
                this.Height - ArcRadiusRight,
                _arcRadiusRight,
                _arcRadiusRight);
            //TODO Need to check if radius inbounds?????
            _rightEar.DrawFooterRightEar(ref gp, _rightEar.EarBounds);


            //Line between arcs
            pt1.X = this.Width - ArcRadiusRight;
            pt1.Y = this.Height;
            pt2.X = ArcRadiusLeft;
            pt2.Y = this.Height;
            gp.AddLine(pt1, pt2);

            //Draw lower left ear
            _leftEar.EarBounds = new Rectangle(0,
                                               this.Height - ArcRadiusLeft,
                                               ArcRadiusLeft,
                                               ArcRadiusLeft);
            _leftEar.DrawFooterLeftEar(ref gp, _leftEar.EarBounds);

            //Line from arc to top
            pt1.X = 0;
            pt1.Y = this.Height - ArcRadiusLeft;
            pt2.X = 0;
            pt2.Y = 0;
            gp.AddLine(pt1, pt2);

            gp.CloseAllFigures();

            Region rgn = new Region(gp);

            this.Region = rgn;

            //Gradiate background
            LinearGradientBrush lgb = new LinearGradientBrush(
                this.DisplayRectangle,
                this._bckgndColor1,
                this._bckgndColor2,
                _gradientAngle,
                true);

            if (_twistColors)
            {
                lgb.SetBlendTriangularShape(.5f, .75f);
            }

            e.Graphics.FillRegion(lgb, rgn);

            rgn.Dispose();
            lgb.Dispose();

            DrawBorderStyle(e, gp);
            DrawImage(e);
            DrawCollapseImage(e);
            DrawText(e);
        }
Beispiel #27
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);
            Graphics g = e.Graphics;

            List <ArcEntity> lstArcs = new List <ArcEntity>();

            GraphicsPath   path     = new GraphicsPath();
            GraphicsPath   linePath = new GraphicsPath();
            List <Point[]> tileLine = new List <Point[]>();

            switch (conduitStyle)
            {
                #region H    English:H
            case ConduitStyle.Horizontal_None_None:
                path.AddLines(new PointF[]
                {
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height)
                });
                path.CloseAllFigures();
                linePath.AddLine(0, this.Height / 2, this.Width, this.Height / 2);
                break;

            case ConduitStyle.Horizontal_Up_None:
                path.AddLines(new PointF[]
                {
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0 + intPenWidth, this.Height)
                });
                path.AddArc(new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
                linePath.AddLine(intPenWidth, this.Height / 2, this.Width, this.Height / 2);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Down_None:
                path.AddLines(new PointF[]
                {
                    new PointF(intPenWidth, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height)
                });
                path.AddArc(new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, this.Height / 2, intPenWidth, intPenWidth), 179, 91);
                linePath.AddLine(intPenWidth + 1, this.Height / 2, this.Width, this.Height / 2);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_None_Up:
                path.AddLines(new PointF[]
                {
                    new PointF(this.ClientRectangle.Right - intPenWidth, this.Height),
                    new PointF(0, this.Height),
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right - intPenWidth, 0)
                });
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.CloseAllFigures();

                linePath.AddLine(0, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 91, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_None_Down:
                path.AddLines(new PointF[]
                {
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height),
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right - intPenWidth, 0)
                });
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.CloseAllFigures();

                linePath.AddLine(0, this.Height / 2, this.Width - intPenWidth - 1, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, intPenWidth / 2, intPenWidth, intPenWidth), 269, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Down_Up:
                path.AddLine(new Point(intPenWidth, 0), new Point(this.Width, 0));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.AddLine(new Point(this.Width - intPenWidth, this.Height), new Point(0, this.Height));
                path.AddArc(new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, this.Height / 2, intPenWidth, intPenWidth), 179, 91);
                //linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 91, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Up_Down:
                path.AddLine(new Point(0, 0), new Point(this.Width - intPenWidth, 0));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.AddLine(new Point(this.Width, this.Height), new Point(intPenWidth, this.Height));
                path.AddArc(new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
                linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth - 1, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, intPenWidth / 2, intPenWidth, intPenWidth), 269, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Up_Up:
                path.AddLine(new Point(0, 0), new Point(this.Width, 0));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.AddLine(new Point(this.Width - intPenWidth, this.Height), new Point(intPenWidth, this.Height));
                path.AddArc(new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
                //linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 91, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Down_Down:
                path.AddLine(new Point(intPenWidth, 0), new Point(this.Width - intPenWidth, 0));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.AddLine(new Point(this.Width, this.Height), new Point(0, this.Height));
                path.AddArc(new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, this.Height / 2, intPenWidth, intPenWidth), 179, 91);
                linePath.AddLine(intPenWidth + 1, this.Height / 2, this.Width - intPenWidth - 1, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, intPenWidth / 2, intPenWidth, intPenWidth), 269, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Tilt_Up:

                double angleUp = Math.Atan((this.ClientRectangle.Height - conduitWidth) / (double)this.ClientRectangle.Width);
                angleUp = angleUp / Math.PI * 180f;
                path.AddArc(new Rectangle(this.ClientRectangle.Left - conduitWidth, this.ClientRectangle.Bottom - conduitWidth * 2, conduitWidth * 2, conduitWidth * 2), 90, -1 * (float)angleUp);
                path.AddLine(new Point(this.ClientRectangle.Right, this.ClientRectangle.Top + conduitWidth), new Point(this.ClientRectangle.Right, this.ClientRectangle.Top));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Top, conduitWidth * 2, conduitWidth * 2), 270, -1 * (float)angleUp);
                path.AddLine(new Point(this.ClientRectangle.Left, this.ClientRectangle.Bottom - conduitWidth), new Point(this.ClientRectangle.Left, this.ClientRectangle.Bottom));
                path.CloseAllFigures();


                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth / 2, this.ClientRectangle.Top + conduitWidth / 2, conduitWidth, conduitWidth), 270, -1 * (float)angleUp);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Left - conduitWidth / 2, this.ClientRectangle.Bottom - 1 - conduitWidth - conduitWidth / 2, conduitWidth, conduitWidth), 95 - (float)angleUp, (float)angleUp + 5);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Left - conduitWidth, this.ClientRectangle.Bottom - conduitWidth * 2, conduitWidth * 2, conduitWidth * 2), startAngle = 90, sweepAngle = -1 * (float)angleUp
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Top, conduitWidth * 2, conduitWidth * 2), startAngle = 270, sweepAngle = -1 * (float)angleUp
                });

                tileLine.Add(new Point[]
                {
                    new Point((int)(this.ClientRectangle.Right + 1 - Math.Sin(Math.PI * (angleUp / 180.00F)) * conduitWidth), (int)(this.ClientRectangle.Top + conduitWidth - Math.Cos(Math.PI * (angleUp / 180.00F)) * conduitWidth)),
                    new Point(this.ClientRectangle.Left, this.ClientRectangle.Bottom - conduitWidth - 1)
                });
                tileLine.Add(new Point[]
                {
                    new Point((int)(this.ClientRectangle.Left + 1 + Math.Sin(Math.PI * (angleUp / 180.00F)) * conduitWidth), (int)(this.ClientRectangle.Bottom - conduitWidth + Math.Cos(Math.PI * (angleUp / 180.00F)) * conduitWidth)),
                    new Point(this.ClientRectangle.Right, this.ClientRectangle.Top + conduitWidth)
                });

                break;

            case ConduitStyle.Horizontal_Tilt_Down:
                double angleDown = Math.Atan((this.ClientRectangle.Height - conduitWidth) / (double)this.ClientRectangle.Width);
                angleDown = angleDown / Math.PI * 180f;
                path.AddArc(new Rectangle(this.ClientRectangle.Left - conduitWidth, this.ClientRectangle.Top, conduitWidth * 2, conduitWidth * 2), 270, (float)angleDown);
                path.AddLine(new Point(this.ClientRectangle.Right, this.ClientRectangle.Bottom - conduitWidth), new Point(this.ClientRectangle.Right, this.ClientRectangle.Bottom));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Bottom - conduitWidth * 2, conduitWidth * 2, conduitWidth * 2), 90, (float)angleDown);
                path.AddLine(new Point(this.ClientRectangle.Left, this.ClientRectangle.Top + conduitWidth), new Point(this.ClientRectangle.Left, this.ClientRectangle.Top));
                path.CloseAllFigures();


                linePath.AddArc(new Rectangle(this.ClientRectangle.Left - conduitWidth / 2, this.ClientRectangle.Top + conduitWidth / 2, conduitWidth, conduitWidth), 265, (float)angleDown + 5);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth / 2, this.ClientRectangle.Bottom - conduitWidth - conduitWidth / 2 - 1, conduitWidth, conduitWidth), 90 + (float)angleDown, -1 * (float)angleDown - 5);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Left - conduitWidth, this.ClientRectangle.Top, conduitWidth * 2, conduitWidth * 2), startAngle = 270, sweepAngle = (float)angleDown
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Bottom - conduitWidth * 2, conduitWidth * 2, conduitWidth * 2), startAngle = 90, sweepAngle = (float)angleDown
                });

                tileLine.Add(new Point[]
                {
                    new Point((int)(this.ClientRectangle.Left + Math.Sin(Math.PI * (angleDown / 180.00F)) * conduitWidth), (int)(this.ClientRectangle.Top + conduitWidth - Math.Cos(Math.PI * (angleDown / 180.00F)) * conduitWidth)),
                    new Point(this.ClientRectangle.Right - 1, this.ClientRectangle.Bottom - conduitWidth - 1)
                });
                tileLine.Add(new Point[]
                {
                    new Point((int)(this.ClientRectangle.Right - Math.Sin(Math.PI * (angleDown / 180.00F)) * conduitWidth), (int)(this.ClientRectangle.Bottom - conduitWidth + Math.Cos(Math.PI * (angleDown / 180.00F)) * conduitWidth)),
                    new Point(this.ClientRectangle.Left, this.ClientRectangle.Top + conduitWidth)
                });
                break;
                #endregion

                #region V    English:V
            case ConduitStyle.Vertical_None_None:
                path.AddLines(new PointF[]
                {
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height)
                });
                path.CloseAllFigures();
                linePath.AddLine(this.Width / 2, 0, this.Width / 2, this.Height);
                break;

            case ConduitStyle.Vertical_Left_None:
                path.AddLines(new PointF[]
                {
                    new PointF(this.ClientRectangle.Right, intPenWidth),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height),
                    new PointF(0, 0)
                });
                path.AddArc(new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 269, 91);
                linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Right_None:
                path.AddLines(new PointF[]
                {
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height),
                    new PointF(0, intPenWidth)
                });
                path.AddArc(new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 271, -91);
                linePath.AddLine(intPenWidth / 2, intPenWidth + 1, intPenWidth / 2, this.Height);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_None_Left:
                path.AddLines(new PointF[]
                {
                    new PointF(0, this.Height),
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height - intPenWidth),
                });
                path.AddArc(new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.CloseAllFigures();

                linePath.AddLine(this.Width / 2, 0, this.Width / 2, this.Height - intPenWidth);
                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), -1, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_None_Right:
                path.AddLines(new PointF[]
                {
                    new PointF(0, this.Height - intPenWidth),
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                });
                path.AddArc(new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.CloseAllFigures();

                linePath.AddLine(this.Width / 2, 0, this.Width / 2, this.Height - intPenWidth - 1);
                linePath.AddArc(new Rectangle(intPenWidth / 2, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Left_Right:
                path.AddLine(this.Width, intPenWidth, this.Width, this.Height);
                path.AddArc(new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.AddLine(0, this.Height - intPenWidth, 0, 0);
                path.AddArc(new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 269, 91);
                //linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
                linePath.AddArc(new Rectangle(intPenWidth / 2, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Right_Left:
                path.AddLine(this.Width, 0, this.Width, this.Height - intPenWidth);
                path.AddArc(new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.AddLine(0, this.Height, 0, intPenWidth);
                path.AddArc(new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 271, -91);
                //linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), -1, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Left_Left:
                path.AddLine(this.Width, intPenWidth, this.Width, this.Height - intPenWidth);
                path.AddArc(new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.AddLine(0, this.Height, 0, 0);
                path.AddArc(new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 269, 91);
                //linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), -1, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Right_Right:
                path.AddLine(this.Width, 0, this.Width, this.Height);
                path.AddArc(new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.AddLine(0, this.Height - intPenWidth, 0, intPenWidth);
                path.AddArc(new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 271, -91);
                //linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
                linePath.AddArc(new Rectangle(intPenWidth / 2, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), 180, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Tilt_Left:
                double angleLeft = Math.Atan((this.ClientRectangle.Width - conduitWidth) / (double)this.ClientRectangle.Height);
                angleLeft = angleLeft / Math.PI * 180f;
                path.AddArc(new Rectangle(this.ClientRectangle.Left - 1, ClientRectangle.Top - conduitWidth, conduitWidth * 2, conduitWidth * 2), 180, -1 * (float)angleLeft);
                path.AddLine(new Point(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Bottom), new Point(this.ClientRectangle.Right, this.ClientRectangle.Bottom));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth * 2, this.ClientRectangle.Bottom - conduitWidth, conduitWidth * 2, conduitWidth * 2), 0, -1 * (float)angleLeft);
                path.AddLine(new Point(this.ClientRectangle.Left + conduitWidth, this.ClientRectangle.Top), new Point(this.ClientRectangle.Left, this.ClientRectangle.Top));
                path.CloseAllFigures();


                linePath.AddArc(new Rectangle(this.ClientRectangle.Left + conduitWidth / 2, this.ClientRectangle.Top - conduitWidth / 2, conduitWidth, conduitWidth), 185, -1 * (float)angleLeft - 5);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth - conduitWidth / 2, this.ClientRectangle.Bottom - conduitWidth / 2, conduitWidth, conduitWidth), -1 * (float)angleLeft, (float)angleLeft);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Left - 1, ClientRectangle.Top - conduitWidth, conduitWidth * 2, conduitWidth * 2), startAngle = 180, sweepAngle = -1 * (float)angleLeft
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - conduitWidth * 2, this.ClientRectangle.Bottom - conduitWidth, conduitWidth * 2, conduitWidth * 2), startAngle = 0, sweepAngle = -1 * (float)angleLeft
                });

                tileLine.Add(new Point[]
                {
                    new Point((int)(this.ClientRectangle.Left + conduitWidth), this.ClientRectangle.Top),
                    new Point((int)(this.ClientRectangle.Right - conduitWidth + Math.Cos(Math.PI * (angleLeft / 180.00F)) * conduitWidth), (int)(this.ClientRectangle.Bottom - Math.Sin(Math.PI * (angleLeft / 180.00F)) * conduitWidth))
                });
                tileLine.Add(new Point[]
                {
                    new Point((int)(this.ClientRectangle.Left - 1 + conduitWidth - Math.Cos(Math.PI * (angleLeft / 180.00F)) * conduitWidth), (int)(this.ClientRectangle.Top + Math.Sin(Math.PI * (angleLeft / 180.00F)) * conduitWidth)),
                    new Point(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Bottom)
                });
                break;

            case ConduitStyle.Vertical_Tilt_Right:
                double angleRight = Math.Atan((this.ClientRectangle.Width - conduitWidth) / (double)this.ClientRectangle.Height);
                angleRight = angleRight / Math.PI * 180f;
                path.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth * 2, ClientRectangle.Top - conduitWidth, conduitWidth * 2, conduitWidth * 2), 0, (float)angleRight);
                path.AddLine(new Point(this.ClientRectangle.Left + conduitWidth, this.ClientRectangle.Bottom), new Point(this.ClientRectangle.Left, this.ClientRectangle.Bottom));
                path.AddArc(new Rectangle(this.ClientRectangle.Left - 1, this.ClientRectangle.Bottom - conduitWidth, conduitWidth * 2, conduitWidth * 2), 180, (float)angleRight);
                path.AddLine(new Point(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Top), new Point(this.ClientRectangle.Right, this.ClientRectangle.Top));
                path.CloseAllFigures();


                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth - conduitWidth / 2, this.ClientRectangle.Top - conduitWidth / 2, conduitWidth, conduitWidth), -5, (float)angleRight + 5);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Left + conduitWidth / 2, this.ClientRectangle.Bottom - conduitWidth / 2, conduitWidth, conduitWidth), 180 + (float)angleRight, -1 * (float)angleRight);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - conduitWidth * 2, ClientRectangle.Top - conduitWidth, conduitWidth * 2, conduitWidth * 2), startAngle = 0, sweepAngle = (float)angleRight
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Left - 1, this.ClientRectangle.Bottom - conduitWidth, conduitWidth * 2, conduitWidth * 2), startAngle = 180, sweepAngle = (float)angleRight
                });

                tileLine.Add(new Point[]
                {
                    new Point((int)(this.ClientRectangle.Right - conduitWidth), this.ClientRectangle.Top),
                    new Point((int)(this.ClientRectangle.Left + conduitWidth - Math.Cos(Math.PI * (angleRight / 180.00F)) * conduitWidth), (int)(this.ClientRectangle.Bottom - Math.Sin(Math.PI * (angleRight / 180.00F)) * conduitWidth))
                });
                tileLine.Add(new Point[]
                {
                    new Point((int)(this.ClientRectangle.Right - conduitWidth + Math.Cos(Math.PI * (angleRight / 180.00F)) * conduitWidth), (int)(this.ClientRectangle.Top + Math.Sin(Math.PI * (angleRight / 180.00F)) * conduitWidth)),
                    new Point(this.ClientRectangle.Left + conduitWidth, this.ClientRectangle.Bottom)
                });
                break;
                #endregion
            }
            base.Region = new Region(path);
            g.FillPath(new SolidBrush(conduitColor), path);

            //渐变色
            int _intPenWidth = intPenWidth;
            if (conduitStyle.ToString().Contains("Tilt"))
            {
                _intPenWidth = conduitWidth;
            }
            int intCount = _intPenWidth / 2 / 4;
            for (int i = 0; i < intCount; i++)
            {
                int _penWidth = _intPenWidth / 2 - 4 * i;
                if (_penWidth <= 0)
                {
                    _penWidth = 1;
                }
                g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), linePath);
                if (_penWidth == 1)
                {
                    break;
                }
            }

            g.SetGDIHigh();
            //使用抗锯齿画圆角
            foreach (var item in lstArcs)
            {
                g.DrawArc(new Pen(new SolidBrush(this.BackColor)), item.rect, item.startAngle, item.sweepAngle);
            }

            if (tileLine.Count > 0)
            {
                foreach (var item in tileLine)
                {
                    g.DrawLine(new Pen(new SolidBrush(this.BackColor)), item[0], item[1]);
                }
            }

            //液体流动
            if (LiquidDirection != LiquidDirection.None)
            {
                Pen p = new Pen(new SolidBrush(liquidColor), 4);
                p.DashPattern = new float[] { 6, 6 };
                p.DashOffset  = intLineLeft * (LiquidDirection == LiquidDirection.Forward ? -1 : 1);
                g.DrawPath(p, linePath);
            }
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            graphics.SmoothingMode     = SmoothingMode.HighQuality;
            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.Clear(Parent.BackColor);

            var tempColor = _isError ? ThemeColors.Danger : ThemeColors.PrimaryColor;

            switch (_style)
            {
            case Style.ToolTip:
                var x = _valueNumber * (Width - 32) / 100 + 16f;
                var y = 25;
                graphics.FillPolygon(new SolidBrush(_valueNumber == 100 && !_isError ? ThemeColors.Success : tempColor), new PointF[]
                {
                    new PointF(x, y), new PointF(x + 5, y - 5), new PointF(x + 16, y - 5), new PointF(x + 16, y - 25), new PointF(x - 16, y - 25), new PointF(x - 16, y - 5), new PointF(x - 5, y - 5)
                });
                graphics.DrawString(_valueNumber != 100 ? _valueNumber.ToString() + "%" : "ok!", Font, new SolidBrush(ThemeColors.FourLevelBorder), new RectangleF(x - 16, y - 25, 32, 20), StringAlign.Center);

                graphics.FillRectangle(new SolidBrush(ThemeColors.OneLevelBorder), new RectangleF(16, 25, Width - 32, Height - 25));
                graphics.FillRectangle(new SolidBrush(_valueNumber == 100 && !_isError ? ThemeColors.Success : tempColor), new RectangleF(16, 25, x - 16, Height - 25));
                break;

            case Style.ValueInSide:
                var path1 = new GraphicsPath();
                path1.AddArc(new RectangleF(0, 0, Height, Height), 90, 180);
                path1.AddArc(new RectangleF(Width - Height, 0, Height, Height), -90, 180);
                path1.CloseAllFigures();
                graphics.FillPath(new SolidBrush(ThemeColors.OneLevelBorder), path1);

                if (_valueNumber == 0)
                {
                    graphics.DrawString("0%", new Font("微软雅黑", 9f), new SolidBrush(ThemeColors.FourLevelBorder), new RectangleF(5, 0, 50, Height), StringAlign.Left);
                }
                else
                {
                    var path2 = new GraphicsPath();
                    path2.AddArc(new RectangleF(0, 0, Height, Height), 90, 180);
                    path2.AddArc(new RectangleF(_valueNumber * (Width - Height) / 100, 0, Height, Height), -90, 180);
                    path2.CloseAllFigures();
                    graphics.FillPath(new SolidBrush(_valueNumber == 100 && !_isError ? ThemeColors.Success : tempColor), path2);

                    graphics.DrawString(_valueNumber.ToString() + "%", new Font("微软雅黑", 9f), new SolidBrush(ThemeColors.FourLevelBorder), new RectangleF(_valueNumber * (Width - Height) / 100 - 33, 0, 45, Height), StringAlign.Right);
                }
                break;

            case Style.ValueOutSide:
                var path3 = new GraphicsPath();
                path3.AddArc(new RectangleF(0, 4, Height - 8, Height - 8), 90, 180);
                path3.AddArc(new RectangleF(Width - 50, 4, Height - 8, Height - 8), -90, 180);
                path3.CloseAllFigures();
                graphics.FillPath(new SolidBrush(ThemeColors.OneLevelBorder), path3);

                if (_valueNumber != 0)
                {
                    var path4 = new GraphicsPath();
                    path4.AddArc(new RectangleF(0, 4, Height - 8, Height - 8), 90, 180);
                    path4.AddArc(new RectangleF(_valueNumber * (Width - 50) / 100, 4, Height - 8, Height - 8), -90, 180);
                    path4.CloseAllFigures();
                    graphics.FillPath(new SolidBrush(_valueNumber == 100 && !_isError ? ThemeColors.Success : tempColor), path4);
                }

                if (_isError)
                {
                    graphics.FillEllipse(new SolidBrush(ThemeColors.Danger), new RectangleF(Width - 40, 0, Height, Height));
                    var a = Width - 40 + 4;
                    var b = Height - 4;
                    graphics.DrawLine(new Pen(ThemeColors.FourLevelBorder), a, b - 6, a + 6, b);
                    graphics.DrawLine(new Pen(ThemeColors.FourLevelBorder), a + 6, b - 6, a, b);
                }
                else
                {
                    if (_valueNumber == 100)
                    {
                        graphics.FillEllipse(new SolidBrush(ThemeColors.Success), new RectangleF(Width - 40, 0, Height, Height));
                        var a = Width - 40 + 4;
                        var b = Height - 4;
                        graphics.DrawLine(new Pen(ThemeColors.FourLevelBorder), a, b - 3, a + 3, b);
                        graphics.DrawLine(new Pen(ThemeColors.FourLevelBorder), a + 3, b, a + 6, b - 6);
                    }
                    else
                    {
                        graphics.DrawString(_valueNumber.ToString() + "%", new Font("微软雅黑", 10f), new SolidBrush(ThemeColors.MainText), new RectangleF(Width - 40, 0, 50, Height), StringAlign.Left);
                    }
                }
                break;
            }
        }
Beispiel #29
0
        public void Paint(ChartGraphics chartGraph)
        {
            if (this.IsVisible())
            {
                CommonElements common = this.chart.chartPicture.common;
                string         text   = this.Text;
                if (this.chart != null && this.chart.LocalizeTextHandler != null)
                {
                    text = this.chart.LocalizeTextHandler(this, text, 0, ChartElementType.Title);
                }
                RectangleF rectangleF = this.Position.ToRectangleF();
                if (!this.Position.Auto && this.chart != null && this.chart.chartPicture != null && (rectangleF.Width == 0.0 || rectangleF.Height == 0.0))
                {
                    SizeF sizeF = new SizeF((rectangleF.Width == 0.0) ? ((float)this.chart.chartPicture.Width) : rectangleF.Width, (rectangleF.Height == 0.0) ? ((float)this.chart.chartPicture.Height) : rectangleF.Height);
                    if (this.IsTextVertical)
                    {
                        float width = sizeF.Width;
                        sizeF.Width  = sizeF.Height;
                        sizeF.Height = width;
                    }
                    sizeF = chartGraph.GetAbsoluteSize(sizeF);
                    SizeF size = chartGraph.MeasureString(text.Replace("\\n", "\n"), this.Font, sizeF, new StringFormat(), this.GetTextOrientation());
                    if (this.BackGroundIsVisible)
                    {
                        size.Width  += (float)this.titleBorderSpacing;
                        size.Height += (float)this.titleBorderSpacing;
                    }
                    if (this.IsTextVertical)
                    {
                        float width2 = size.Width;
                        size.Width  = size.Height;
                        size.Height = width2;
                    }
                    size = chartGraph.GetRelativeSize(size);
                    if (rectangleF.Width == 0.0)
                    {
                        rectangleF.Width = size.Width;
                        if (this.Alignment == ContentAlignment.BottomRight || this.Alignment == ContentAlignment.MiddleRight || this.Alignment == ContentAlignment.TopRight)
                        {
                            rectangleF.X -= rectangleF.Width;
                        }
                        else if (this.Alignment == ContentAlignment.BottomCenter || this.Alignment == ContentAlignment.MiddleCenter || this.Alignment == ContentAlignment.TopCenter)
                        {
                            rectangleF.X -= (float)(rectangleF.Width / 2.0);
                        }
                    }
                    if (rectangleF.Height == 0.0)
                    {
                        rectangleF.Height = size.Height;
                        if (this.Alignment == ContentAlignment.BottomRight || this.Alignment == ContentAlignment.BottomCenter || this.Alignment == ContentAlignment.BottomLeft)
                        {
                            rectangleF.Y -= rectangleF.Height;
                        }
                        else if (this.Alignment == ContentAlignment.MiddleCenter || this.Alignment == ContentAlignment.MiddleLeft || this.Alignment == ContentAlignment.MiddleRight)
                        {
                            rectangleF.Y -= (float)(rectangleF.Height / 2.0);
                        }
                    }
                }
                RectangleF rectangleF2 = new RectangleF(rectangleF.Location, rectangleF.Size);
                rectangleF2 = chartGraph.GetAbsoluteRectangle(rectangleF2);
                if (this.BackGroundIsVisible && common.ProcessModePaint)
                {
                    chartGraph.StartHotRegion(this.href, this.toolTip);
                    chartGraph.StartAnimation();
                    chartGraph.FillRectangleRel(rectangleF, this.BackColor, this.BackHatchStyle, this.BackImage, this.BackImageMode, this.BackImageTransparentColor, this.BackImageAlign, this.BackGradientType, this.BackGradientEndColor, this.BorderColor, this.BorderWidth, this.BorderStyle, this.ShadowColor, this.ShadowOffset, PenAlignment.Inset);
                    chartGraph.StopAnimation();
                    chartGraph.EndHotRegion();
                }
                else
                {
                    chartGraph.StartHotRegion(this.href, this.toolTip);
                    SizeF absoluteSize = chartGraph.GetAbsoluteSize(rectangleF.Size);
                    SizeF size2        = chartGraph.MeasureString(text.Replace("\\n", "\n"), this.Font, absoluteSize, new StringFormat(), this.GetTextOrientation());
                    size2 = chartGraph.GetRelativeSize(size2);
                    RectangleF rectF = new RectangleF(rectangleF.X, rectangleF.Y, size2.Width, size2.Height);
                    if (this.Alignment == ContentAlignment.BottomCenter || this.Alignment == ContentAlignment.BottomLeft || this.Alignment == ContentAlignment.BottomRight)
                    {
                        rectF.Y = rectangleF.Bottom - rectF.Height;
                    }
                    else if (this.Alignment == ContentAlignment.MiddleCenter || this.Alignment == ContentAlignment.MiddleLeft || this.Alignment == ContentAlignment.MiddleRight)
                    {
                        rectF.Y = (float)(rectangleF.Y + rectangleF.Height / 2.0 - rectF.Height / 2.0);
                    }
                    if (this.Alignment == ContentAlignment.BottomRight || this.Alignment == ContentAlignment.MiddleRight || this.Alignment == ContentAlignment.TopRight)
                    {
                        rectF.X = rectangleF.Right - rectF.Width;
                    }
                    else if (this.Alignment == ContentAlignment.BottomCenter || this.Alignment == ContentAlignment.MiddleCenter || this.Alignment == ContentAlignment.TopCenter)
                    {
                        rectF.X = (float)(rectangleF.X + rectangleF.Width / 2.0 - rectF.Width / 2.0);
                    }
                    if (true)
                    {
                        chartGraph.FillRectangleRel(rectF, Color.FromArgb(0, Color.White), ChartHatchStyle.None, string.Empty, ChartImageWrapMode.Tile, this.BackImageTransparentColor, this.BackImageAlign, GradientType.None, this.BackGradientEndColor, Color.Transparent, 0, this.BorderStyle, Color.Transparent, 0, PenAlignment.Inset);
                    }
                    chartGraph.EndHotRegion();
                }
                if (this.BackGroundIsVisible)
                {
                    rectangleF2.Width  -= (float)this.titleBorderSpacing;
                    rectangleF2.Height -= (float)this.titleBorderSpacing;
                    rectangleF2.X      += (float)((float)this.titleBorderSpacing / 2.0);
                    rectangleF2.Y      += (float)((float)this.titleBorderSpacing / 2.0);
                }
                StringFormat stringFormat = new StringFormat();
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Center;
                if (this.Alignment == ContentAlignment.BottomCenter || this.Alignment == ContentAlignment.BottomLeft || this.Alignment == ContentAlignment.BottomRight)
                {
                    stringFormat.LineAlignment = StringAlignment.Far;
                }
                else if (this.Alignment == ContentAlignment.TopCenter || this.Alignment == ContentAlignment.TopLeft || this.Alignment == ContentAlignment.TopRight)
                {
                    stringFormat.LineAlignment = StringAlignment.Near;
                }
                if (this.Alignment == ContentAlignment.BottomLeft || this.Alignment == ContentAlignment.MiddleLeft || this.Alignment == ContentAlignment.TopLeft)
                {
                    stringFormat.Alignment = StringAlignment.Near;
                }
                else if (this.Alignment == ContentAlignment.BottomRight || this.Alignment == ContentAlignment.MiddleRight || this.Alignment == ContentAlignment.TopRight)
                {
                    stringFormat.Alignment = StringAlignment.Far;
                }
                Color     gradientColor = ChartGraphics.GetGradientColor(this.Color, Color.Black, 0.8);
                int       num           = 1;
                TextStyle textStyle     = this.Style;
                if ((textStyle == TextStyle.Default || textStyle == TextStyle.Shadow) && !this.BackGroundIsVisible && this.ShadowOffset != 0)
                {
                    textStyle     = TextStyle.Shadow;
                    gradientColor = this.ShadowColor;
                    num           = this.ShadowOffset;
                }
                text = text.Replace("\\n", "\n");
                Matrix matrix = null;
                if (this.IsTextVertical)
                {
                    if (this.GetTextOrientation() == TextOrientation.Rotated270)
                    {
                        stringFormat.FormatFlags |= (StringFormatFlags.DirectionRightToLeft | StringFormatFlags.DirectionVertical);
                        matrix = chartGraph.Transform.Clone();
                        PointF empty = PointF.Empty;
                        empty.X = (float)(rectangleF2.X + rectangleF2.Width / 2.0);
                        empty.Y = (float)(rectangleF2.Y + rectangleF2.Height / 2.0);
                        Matrix matrix2 = chartGraph.Transform.Clone();
                        matrix2.RotateAt(180f, empty);
                        chartGraph.Transform = matrix2;
                    }
                    else if (this.GetTextOrientation() == TextOrientation.Rotated90)
                    {
                        stringFormat.FormatFlags |= (StringFormatFlags.DirectionRightToLeft | StringFormatFlags.DirectionVertical);
                    }
                }
                if (text.Length > 0)
                {
                    chartGraph.StartAnimation();
                    switch (textStyle)
                    {
                    case TextStyle.Default:
                        chartGraph.StartHotRegion(this.href, this.toolTip);
                        chartGraph.DrawString(text, this.Font, new SolidBrush(this.Color), rectangleF2, stringFormat, this.GetTextOrientation());
                        chartGraph.EndHotRegion();
                        break;

                    case TextStyle.Frame:
                    {
                        GraphicsPath graphicsPath = new GraphicsPath();
                        graphicsPath.AddString(ChartGraphics.GetStackedText(text), this.Font.FontFamily, (int)this.Font.Style, (float)(this.Font.Size * 1.2999999523162842), rectangleF2, stringFormat);
                        graphicsPath.CloseAllFigures();
                        chartGraph.StartHotRegion(this.href, this.toolTip);
                        chartGraph.DrawPath(new Pen(this.Color, 1f), graphicsPath);
                        chartGraph.EndHotRegion();
                        break;
                    }

                    case TextStyle.Embed:
                    {
                        RectangleF rect3 = new RectangleF(rectangleF2.Location, rectangleF2.Size);
                        rect3.X -= 1f;
                        rect3.Y -= 1f;
                        chartGraph.DrawString(text, this.Font, new SolidBrush(gradientColor), rect3, stringFormat, this.GetTextOrientation());
                        rect3.X += 2f;
                        rect3.Y += 2f;
                        Color gradientColor3 = ChartGraphics.GetGradientColor(Color.White, this.Color, 0.3);
                        chartGraph.DrawString(text, this.Font, new SolidBrush(gradientColor3), rect3, stringFormat, this.GetTextOrientation());
                        chartGraph.StartHotRegion(this.href, this.toolTip);
                        chartGraph.DrawString(text, this.Font, new SolidBrush(this.Color), rectangleF2, stringFormat, this.GetTextOrientation());
                        chartGraph.EndHotRegion();
                        break;
                    }

                    case TextStyle.Emboss:
                    {
                        RectangleF rect2 = new RectangleF(rectangleF2.Location, rectangleF2.Size);
                        rect2.X += 1f;
                        rect2.Y += 1f;
                        chartGraph.DrawString(text, this.Font, new SolidBrush(gradientColor), rect2, stringFormat, this.GetTextOrientation());
                        rect2.X -= 2f;
                        rect2.Y -= 2f;
                        Color gradientColor2 = ChartGraphics.GetGradientColor(Color.White, this.Color, 0.3);
                        chartGraph.DrawString(text, this.Font, new SolidBrush(gradientColor2), rect2, stringFormat, this.GetTextOrientation());
                        chartGraph.StartHotRegion(this.href, this.toolTip);
                        chartGraph.DrawString(text, this.Font, new SolidBrush(this.Color), rectangleF2, stringFormat, this.GetTextOrientation());
                        chartGraph.EndHotRegion();
                        break;
                    }

                    case TextStyle.Shadow:
                    {
                        RectangleF rect = new RectangleF(rectangleF2.Location, rectangleF2.Size);
                        rect.X += (float)num;
                        rect.Y += (float)num;
                        chartGraph.DrawString(text, this.Font, new SolidBrush(gradientColor), rect, stringFormat, this.GetTextOrientation());
                        chartGraph.StartHotRegion(this.href, this.toolTip);
                        chartGraph.DrawString(text, this.Font, new SolidBrush(this.Color), rectangleF2, stringFormat, this.GetTextOrientation());
                        chartGraph.EndHotRegion();
                        break;
                    }

                    default:
                        throw new InvalidOperationException(SR.ExceptionTitleTextDrawingStyleUnknown);
                    }
                    chartGraph.StopAnimation();
                }
                if (matrix != null)
                {
                    chartGraph.Transform = matrix;
                }
                if (common.ProcessModeRegions)
                {
                    common.HotRegionsList.AddHotRegion(chartGraph, rectangleF, this.ToolTip, this.Href, this.MapAreaAttributes, this, ChartElementType.Title, string.Empty);
                }
            }
        }
Beispiel #30
0
        private GraphicsPath GetButtonPath(MapGraphics g)
        {
            GraphicsPath graphicsPath = new GraphicsPath();

            switch (Style)
            {
            case PanelButtonStyle.Rectangle:
                graphicsPath.AddRectangle(g.GetAbsoluteRectangle(Bounds));
                break;

            case PanelButtonStyle.Circle:
                graphicsPath.AddEllipse(g.GetAbsoluteRectangle(Bounds));
                break;

            case PanelButtonStyle.RoundedRectangle:
            {
                RectangleF absoluteRectangle = g.GetAbsoluteRectangle(Bounds);
                if (absoluteRectangle.Width < 1f || absoluteRectangle.Height < 1f)
                {
                    return(graphicsPath);
                }
                float   num          = absoluteRectangle.Width / 8f;
                float[] cornerRadius = new float[8]
                {
                    num,
                    num,
                    num,
                    num,
                    num,
                    num,
                    num,
                    num
                };
                graphicsPath.AddPath(g.CreateRoundedRectPath(absoluteRectangle, cornerRadius), connect: false);
                break;
            }

            case PanelButtonStyle.Triangle:
                switch (Type)
                {
                case PanelButtonType.NavigationButton:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(Bounds.Left, Bounds.Bottom)),
                        g.GetAbsolutePoint(new PointF((Bounds.Left + Bounds.Right) / 2f, Bounds.Top)),
                        g.GetAbsolutePoint(new PointF(Bounds.Right, Bounds.Bottom))
                    });
                    graphicsPath.CloseAllFigures();
                    break;

                case PanelButtonType.NaviagateSouth:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(Bounds.Left, Bounds.Top)),
                        g.GetAbsolutePoint(new PointF((Bounds.Left + Bounds.Right) / 2f, Bounds.Bottom)),
                        g.GetAbsolutePoint(new PointF(Bounds.Right, Bounds.Top))
                    });
                    graphicsPath.CloseAllFigures();
                    break;

                case PanelButtonType.NaviagateEast:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(Bounds.Left, Bounds.Top)),
                        g.GetAbsolutePoint(new PointF(Bounds.Right, (Bounds.Top + Bounds.Bottom) / 2f)),
                        g.GetAbsolutePoint(new PointF(Bounds.Left, Bounds.Bottom))
                    });
                    graphicsPath.CloseAllFigures();
                    break;

                case PanelButtonType.NaviagateWest:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(Bounds.Right, Bounds.Top)),
                        g.GetAbsolutePoint(new PointF(Bounds.Left, (Bounds.Top + Bounds.Bottom) / 2f)),
                        g.GetAbsolutePoint(new PointF(Bounds.Right, Bounds.Bottom))
                    });
                    graphicsPath.CloseAllFigures();
                    break;
                }
                break;
            }
            return(graphicsPath);
        }
Beispiel #31
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);
            Graphics g = e.Graphics;

            List <ArcEntity> lstArcs = new List <ArcEntity>();

            GraphicsPath path     = new GraphicsPath();
            GraphicsPath linePath = new GraphicsPath();

            switch (conduitStyle)
            {
                #region H    English:H
            case ConduitStyle.Horizontal_None_None:
                path.AddLines(new PointF[]
                {
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height)
                });
                path.CloseAllFigures();
                linePath.AddLine(0, this.Height / 2, this.Width, this.Height / 2);
                break;

            case ConduitStyle.Horizontal_Up_None:
                path.AddLines(new PointF[]
                {
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0 + intPenWidth, this.Height)
                });
                path.AddArc(new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
                linePath.AddLine(intPenWidth, this.Height / 2, this.Width, this.Height / 2);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Down_None:
                path.AddLines(new PointF[]
                {
                    new PointF(intPenWidth, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height)
                });
                path.AddArc(new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, this.Height / 2, intPenWidth, intPenWidth), 179, 91);
                linePath.AddLine(intPenWidth + 1, this.Height / 2, this.Width, this.Height / 2);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_None_Up:
                path.AddLines(new PointF[]
                {
                    new PointF(this.ClientRectangle.Right - intPenWidth, this.Height),
                    new PointF(0, this.Height),
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right - intPenWidth, 0)
                });
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.CloseAllFigures();

                linePath.AddLine(0, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 91, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_None_Down:
                path.AddLines(new PointF[]
                {
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height),
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right - intPenWidth, 0)
                });
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.CloseAllFigures();

                linePath.AddLine(0, this.Height / 2, this.Width - intPenWidth - 1, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, intPenWidth / 2, intPenWidth, intPenWidth), 269, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Down_Up:
                path.AddLine(new Point(intPenWidth, 0), new Point(this.Width, 0));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.AddLine(new Point(this.Width - intPenWidth, this.Height), new Point(0, this.Height));
                path.AddArc(new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, this.Height / 2, intPenWidth, intPenWidth), 179, 91);
                //linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 91, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Up_Down:
                path.AddLine(new Point(0, 0), new Point(this.Width - intPenWidth, 0));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.AddLine(new Point(this.Width, this.Height), new Point(intPenWidth, this.Height));
                path.AddArc(new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
                linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth - 1, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, intPenWidth / 2, intPenWidth, intPenWidth), 269, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Up_Up:
                path.AddLine(new Point(0, 0), new Point(this.Width, 0));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.AddLine(new Point(this.Width - intPenWidth, this.Height), new Point(intPenWidth, this.Height));
                path.AddArc(new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
                //linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 91, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Horizontal_Down_Down:
                path.AddLine(new Point(intPenWidth, 0), new Point(this.Width - intPenWidth, 0));
                path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.AddLine(new Point(this.Width, this.Height), new Point(0, this.Height));
                path.AddArc(new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, this.Height / 2, intPenWidth, intPenWidth), 179, 91);
                linePath.AddLine(intPenWidth + 1, this.Height / 2, this.Width - intPenWidth - 1, this.Height / 2);
                linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, intPenWidth / 2, intPenWidth, intPenWidth), 269, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                break;
                #endregion

                #region V    English:V
            case ConduitStyle.Vertical_None_None:
                path.AddLines(new PointF[]
                {
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height)
                });
                path.CloseAllFigures();
                linePath.AddLine(this.Width / 2, 0, this.Width / 2, this.Height);
                break;

            case ConduitStyle.Vertical_Left_None:
                path.AddLines(new PointF[]
                {
                    new PointF(this.ClientRectangle.Right, intPenWidth),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height),
                    new PointF(0, 0)
                });
                path.AddArc(new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 269, 91);
                linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Right_None:
                path.AddLines(new PointF[]
                {
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                    new PointF(0, this.Height),
                    new PointF(0, intPenWidth)
                });
                path.AddArc(new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 271, -91);
                linePath.AddLine(intPenWidth / 2, intPenWidth + 1, intPenWidth / 2, this.Height);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_None_Left:
                path.AddLines(new PointF[]
                {
                    new PointF(0, this.Height),
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height - intPenWidth),
                });
                path.AddArc(new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.CloseAllFigures();

                linePath.AddLine(this.Width / 2, 0, this.Width / 2, this.Height - intPenWidth);
                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), -1, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_None_Right:
                path.AddLines(new PointF[]
                {
                    new PointF(0, this.Height - intPenWidth),
                    new PointF(0, 0),
                    new PointF(this.ClientRectangle.Right, 0),
                    new PointF(this.ClientRectangle.Right, this.Height),
                });
                path.AddArc(new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.CloseAllFigures();

                linePath.AddLine(this.Width / 2, 0, this.Width / 2, this.Height - intPenWidth - 1);
                linePath.AddArc(new Rectangle(intPenWidth / 2, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Left_Right:
                path.AddLine(this.Width, intPenWidth, this.Width, this.Height);
                path.AddArc(new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.AddLine(0, this.Height - intPenWidth, 0, 0);
                path.AddArc(new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 269, 91);
                //linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
                linePath.AddArc(new Rectangle(intPenWidth / 2, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Right_Left:
                path.AddLine(this.Width, 0, this.Width, this.Height - intPenWidth);
                path.AddArc(new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.AddLine(0, this.Height, 0, intPenWidth);
                path.AddArc(new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 271, -91);
                //linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), -1, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Left_Left:
                path.AddLine(this.Width, intPenWidth, this.Width, this.Height - intPenWidth);
                path.AddArc(new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 0, 90);
                path.AddLine(0, this.Height, 0, 0);
                path.AddArc(new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), 270, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 269, 91);
                //linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
                linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), -1, 91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90
                });
                break;

            case ConduitStyle.Vertical_Right_Right:
                path.AddLine(this.Width, 0, this.Width, this.Height);
                path.AddArc(new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 90, 90);
                path.AddLine(0, this.Height - intPenWidth, 0, intPenWidth);
                path.AddArc(new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), 180, 90);
                path.CloseAllFigures();

                linePath.AddArc(new Rectangle(intPenWidth / 2, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 271, -91);
                //linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
                linePath.AddArc(new Rectangle(intPenWidth / 2, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), 180, -91);

                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90
                });
                lstArcs.Add(new ArcEntity()
                {
                    rect = new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90
                });
                break;
                #endregion
            }
            g.FillPath(new SolidBrush(conduitColor), path);

            //渐变色
            int intCount = intPenWidth / 2 / 4;
            int intSplit = (255 - 100) / intCount;
            for (int i = 0; i < intCount; i++)
            {
                int _penWidth = intPenWidth / 2 - 4 * i;
                if (_penWidth <= 0)
                {
                    _penWidth = 1;
                }
                g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), linePath);
                if (_penWidth == 1)
                {
                    break;
                }
            }

            g.SetGDIHigh();
            //使用抗锯齿画圆角
            foreach (var item in lstArcs)
            {
                g.DrawArc(new Pen(new SolidBrush(this.BackColor)), item.rect, item.startAngle, item.sweepAngle);
            }

            //液体流动
            if (LiquidDirection != Conduit.LiquidDirection.None)
            {
                Pen p = new Pen(new SolidBrush(liquidColor), 4);
                p.DashPattern = new float[] { 6, 6 };
                p.DashOffset  = intLineLeft * (LiquidDirection == Conduit.LiquidDirection.Forward ? -1 : 1);
                g.DrawPath(p, linePath);
            }
        }
Beispiel #32
0
        internal override void Draw(System.Drawing.Graphics g, DrawStyle style)
        {
            List <Point> points = new List <Point>();

            for (int i = 0; i < GraphArea.Width; i++)
            {
                double xValue =
                    ValueDimension.MinimumX +
                    (ValueDimension.XDifference / GraphArea.Width) * i;
                double yValue = Function(xValue);
                int    yPixel = (int)Math.Abs(
                    (ValueDimension.MinimumY + yValue) *
                    GraphArea.Height / ValueDimension.YDifference);

                if (ValueDimension.IsBetweenYBorders(yValue))
                {   //Add point to list
                    points.Add(new Point(GraphArea.Left + i, GraphArea.Top + yPixel));
                }
                else if (yValue < ValueDimension.MinimumY)
                {
                    points.Add(new Point(GraphArea.Left + i, GraphArea.Bottom));
                }
                else if (yValue > ValueDimension.MaximumY)
                {
                    points.Add(new Point(GraphArea.Left + i, GraphArea.Top));
                }
                //else if (points.Count > 0)
                //{
                //    //Draw all points...
                //    g.DrawLines(LineStyle, points.ToArray());
                //    //...and clear list for next draw point in list
                //    points.Clear();
                //}
            }

            if ((style == DrawStyle.Both) || (style == DrawStyle.Lines))
            {
                if (points.Count > 0)
                {
                    g.DrawLines(LineStyle, points.ToArray());
                }
            }

            //****************************************************************

            points.Add(GraphArea.GetBottomRight());
            points.Add(new Point(GraphArea.Left, GraphArea.Bottom));

            byte[] types = new byte[points.Count];
            for (int i = 0; i < types.Length; i++)
            {
                types[i] = (byte)PathPointType.Line;
            }

            GraphicsPath path = new GraphicsPath(points.ToArray(), types);

            path.CloseAllFigures();

            if ((style == DrawStyle.Both) || (style == DrawStyle.Faces))
            {
                g.FillPath(FillStyle, path);
            }
        }
Beispiel #33
0
 public static GraphicsPath RoundRect(Rectangle rect, int slope)
 {
     GraphicsPath gp = new GraphicsPath();
     int arcWidth = slope * 2;
     gp.AddArc(new Rectangle(rect.X, rect.Y, arcWidth, arcWidth), -180, 90);
     gp.AddArc(new Rectangle(rect.Width - arcWidth + rect.X, rect.Y, arcWidth, arcWidth), -90, 90);
     gp.AddArc(new Rectangle(rect.Width - arcWidth + rect.X, rect.Height - arcWidth + rect.Y, arcWidth, arcWidth), 0, 90);
     gp.AddArc(new Rectangle(rect.X, rect.Height - arcWidth + rect.Y, arcWidth, arcWidth), 90, 90);
     gp.CloseAllFigures();
     return gp;
 }
Beispiel #34
0
        private void PaintPieces(PaintEventArgs e)
        {
            Graphics   g = e.Graphics;
            SolidBrush m = new SolidBrush(Color.FromArgb(255, 180, 0, 0));
            Pen        p = new Pen(Color.FromArgb(255, 0, 0, 0), lineWidth);

            foreach (KulaLevel.MapTile t in lvlGrid.Values.ToList <KulaLevel.MapTile>())
            {
                m.Color = EditorUtils.AssociateToTile(t.TileType.ToString(), TileConverter.FromByteSpecificType(t.TileType, t.Type));
                int w = cellSize;
                int h = cellSize;
                int x = lineWidth + t.X * (lineWidth + cellSize);
                int y = lineWidth + t.Y * (lineWidth + cellSize);
                g.FillRectangle(m, new Rectangle(x, y, w, h));

                #region Nel caso in cui il tile sia un blocco: disegno le superfici.
                if (t.TileType == KulaLevel.TileType.Block)
                {
                    int               lw = w + lineWidth;
                    int               lh = h + lineWidth;
                    int               lx = x - lineWidth / 2;
                    int               ly = y - lineWidth / 2;
                    KulaLevel.Block   b  = (KulaLevel.Block)t;
                    KulaLevel.Surface s;
                    s       = b.GetSurfaceAtFace(KulaLevel.Orientation.Down);
                    p.Color = EditorUtils.AssociateToSurface(s.Type);
                    g.DrawLine(p, new Point(lx, ly + lh), new Point(lx + lw, ly + lh));

                    s       = b.GetSurfaceAtFace(KulaLevel.Orientation.Up);
                    p.Color = EditorUtils.AssociateToSurface(s.Type);
                    g.DrawLine(p, new Point(lx, ly), new Point(lx + lw, ly));

                    s       = b.GetSurfaceAtFace(KulaLevel.Orientation.Left);
                    p.Color = EditorUtils.AssociateToSurface(s.Type);
                    g.DrawLine(p, new Point(lx, ly), new Point(lx, ly + lh));

                    s       = b.GetSurfaceAtFace(KulaLevel.Orientation.Right);
                    p.Color = EditorUtils.AssociateToSurface(s.Type);
                    g.DrawLine(p, new Point(lx + lw, ly), new Point(lx + lw, ly + lh));
                }
                #endregion
                #region Caso in cui gli oggetti non siano blocchi, ne evidenzio la direzione.
                else
                {
                    #region Sistemo la freccia che mi indica la direzione.
                    float unit = ((float)cellSize) / 4.0f;
                    float lw   = (float)lineWidth;

                    float startX = t.X * (lw + 4.0f * unit);
                    float startY = t.Y * (lw + 4.0f * unit);

                    PointF[] pts =
                    {
                        new PointF(startX + lw + unit,        startY + lw + unit * 2.0f),
                        new PointF(startX + lw + 3.0f * unit, startY + lw + unit * 2.0f),
                        new PointF(startX + lw + 2.0f * unit, startY + lw + unit * 4.0f),
                        new PointF(startX + lw + 2.0f * unit, startY + lw + unit * 2.0f),
                    };

                    Matrix trans = new Matrix();
                    if (t.Orientation == KulaLevel.Orientation.Up)
                    {
                        trans.RotateAt(180.0f, pts[3], MatrixOrder.Append);
                    }
                    else if (t.Orientation == KulaLevel.Orientation.Left)
                    {
                        trans.RotateAt(90.0f, pts[3], MatrixOrder.Append);
                    }
                    else if (t.Orientation == KulaLevel.Orientation.Right)
                    {
                        trans.RotateAt(-90.0f, pts[3], MatrixOrder.Append);
                    }
                    trans.TransformPoints(pts);

                    GraphicsPath gp = new GraphicsPath();
                    gp.AddLine(pts[0], pts[1]);
                    gp.AddLine(pts[1], pts[2]);
                    gp.AddLine(pts[2], pts[0]);
                    gp.CloseAllFigures();

                    g.FillPath(Brushes.White, gp);
                    g.DrawPath(Pens.DarkRed, gp);
                    gp.Dispose();
                    trans.Dispose();
                    #endregion
                }
                #endregion
            }
            m.Dispose();
            p.Dispose();
        }