CloseAllFigures() public method

public CloseAllFigures ( ) : void
return void
Exemplo n.º 1
0
        // 圆角代码 第一个参数是该元素的宽,第二个参数是元素的高,第三个参数是圆角半径
        public Region Round(int width, int height, int _Radius)
        {
            System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath();
            int x          = 1;
            int y          = 1;
            int thisWidth  = width;
            int thisHeight = height;
            int angle      = _Radius;

            if (angle > 0)
            {
                System.Drawing.Graphics g = CreateGraphics();
                oPath.AddArc(x, y, angle, angle, 180, 90);                                // 左上角
                oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90);                // 右上角
                oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90); // 右下角
                oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90);                // 左下角

                oPath.CloseAllFigures();
                return(new System.Drawing.Region(oPath));
            }
            // -----------------------------------------------------------------------------------------------
            else
            {
                oPath.AddLine(x + angle, y, thisWidth - angle, y);                   // 顶端
                oPath.AddLine(thisWidth, y + angle, thisWidth, thisHeight - angle);  // 右边
                oPath.AddLine(thisWidth - angle, thisHeight, x + angle, thisHeight); // 底边
                oPath.AddLine(x, y + angle, x, thisHeight - angle);                  // 左边
                oPath.CloseAllFigures();
                return(new System.Drawing.Region(oPath));
            }
        }
Exemplo n.º 2
0
        // 圆角代码
        public GraphicsPath BuildPath()
        {
            // -----------------------------------------------------------------------------------------------
            // 已经是.net提供给我们的最容易的改窗体的属性了(以前要自己调API)
            System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath();
            int x          = this.BorderWidth; //(int)Math.Ceiling((this.BorderWidth - 1) / 2.0);
            int y          = this.BorderWidth; //(int)Math.Ceiling((this.BorderWidth - 1) / 2.0);
            int thisWidth  = this.Width - 2 * this.BorderWidth - 1;
            int thisHeight = this.Height - 2 * this.BorderWidth - 1;
            int angle      = _radius;

            if (angle > 0)
            {
                System.Drawing.Graphics g = CreateGraphics();
                oPath.AddArc(x, y, angle, angle, 180, 90);                                 // 左上角
                oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90);                 // 右上角
                oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90);  // 右下角
                oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90);                 // 左下角
                oPath.CloseAllFigures();
                //this.Region = new System.Drawing.Region(oPath);
            }
            // -----------------------------------------------------------------------------------------------
            else
            {
                oPath.AddLine(x + angle, y, thisWidth - angle, y);                         // 顶端
                oPath.AddLine(thisWidth, y + angle, thisWidth, thisHeight - angle);        // 右边
                oPath.AddLine(thisWidth - angle, thisHeight, x + angle, thisHeight);       // 底边
                oPath.AddLine(x, y + angle, x, thisHeight - angle);                        // 左边
                oPath.CloseAllFigures();
                //this.Region = new System.Drawing.Region(oPath);
            }

            return(oPath);
        }
        protected virtual void RecalcBrushes(Rectangle position, Painter.State state)
        {
            if (_lastPosition == null || _lastPosition.Value != position || _lastState == null ||_lastState.Value != state)
            {
                _lastState = state;
                if (state == State.Hover)
                    _borderPen = new Pen(Color.FromArgb(0x3c, 0x7f, 0xb1), 1);
                else if (state == State.Pressed)
                    _borderPen = new Pen(Color.FromArgb(0x18, 0x59, 0x8a), 1);
                else
                    _borderPen = new Pen(Color.FromArgb(0x9a, 0x9a, 0x9a), 1);

                _leftBounds = new Rectangle(position.X, position.Y, 8, position.Height);
                _leftBrush = CreateLeftBrush(_leftBounds, state);

                _middleBounds = new Rectangle(_leftBounds.Right, _leftBounds.Y, (int)((float)position.Width - 16), position.Height);
                _middleBrush = CreateMiddleBrush(_middleBounds, state);

                _rightBounds = new Rectangle(_middleBounds.Right, _leftBounds.Y, 8, position.Height);
                _rightBrush = CreateRightBrush(_rightBounds, state);

                _upperGradientPath = new GraphicsPath();
                _upperGradientPath.AddLine(position.X + 8, position.Y + 1, position.X + 8, position.Y + 5);
                _upperGradientPath.AddLine(position.X + 8, position.Y + 5, _middleBounds.Right, position.Y + 5);
                _upperGradientPath.AddLine(_middleBounds.Right, position.Y + 5, _rightBounds.Right - 1, position.Y + 1);
                _upperGradientPath.CloseAllFigures();

                _upperGradientRect = new Rectangle(position.X + 8, position.Y + 1, 10, 4);
                _upperGradientBrush = new LinearGradientBrush(_upperGradientRect, Color.FromArgb(0xed, 0xed, 0xed), Color.FromArgb(0xdd, 0xdd, 0xe0), LinearGradientMode.Vertical);

                _lastPosition = position;
            }
        }
Exemplo n.º 4
0
        public void DrawMarker(DragDropMarkerRendererEventArgs e)
        {
            Graphics g = e.Graphics;
            Rectangle bounds = e.Bounds;
            if (bounds.IsEmpty || _MarkerColor.IsEmpty) return;

            if (bounds.Width == AdvTree.DragInsertMarkSize) // Vertical insert mark
            {
                using (SolidBrush brush = new SolidBrush(_MarkerColor))
                {
                    using (Pen pen = new Pen(brush, 1))
                    {
                        Point p = new Point(bounds.X + 4, bounds.Y);
                        g.DrawLine(pen, p.X, p.Y, p.X, bounds.Bottom - 1);
                    }

                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddLine(bounds.X, bounds.Y, bounds.X + 8, bounds.Y );
                        path.AddLine(bounds.X + 8, bounds.Y, bounds.X + 4, bounds.Y + 4);
                        path.CloseAllFigures();
                        g.FillPath(brush, path);
                    }
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddLine(bounds.X, bounds.Bottom, bounds.X + 8, bounds.Bottom);
                        path.AddLine(bounds.X + 8, bounds.Bottom, bounds.X + 4, bounds.Bottom - 4);
                        path.CloseAllFigures();
                        g.FillPath(brush, path);
                    }
                }
            }
            else
            {
                // Horizontal insert mark
                using (SolidBrush brush = new SolidBrush(_MarkerColor))
                {
                    using (Pen pen = new Pen(brush, 1))
                    {
                        Point p = new Point(bounds.X, bounds.Y + 4);
                        g.DrawLine(pen, p.X, p.Y, bounds.Right - 1, p.Y);
                    }

                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddLine(bounds.X, bounds.Y, bounds.X, bounds.Y + 8);
                        path.AddLine(bounds.X, bounds.Y + 8, bounds.X + 4, bounds.Y + 4);
                        path.CloseAllFigures();
                        g.FillPath(brush, path);
                    }
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddLine(bounds.Right, bounds.Y, bounds.Right, bounds.Y + 8);
                        path.AddLine(bounds.Right, bounds.Y + 8, bounds.Right - 4, bounds.Y + 4);
                        path.CloseAllFigures();
                        g.FillPath(brush, path);
                    }
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes the <see cref="T:LinePenStyle"/> class.
 /// </summary>
 static LinePenStyle()
 {
     Point[] ps = new Point[3] { new Point(-2, 0), new Point(0, 4), new Point(2, 0) };
     GraphicsPath gpath = new GraphicsPath();
     gpath.AddPolygon(ps);
     gpath.CloseAllFigures();
     mGeneralizationCap = new CustomLineCap(null, gpath);
 }
Exemplo n.º 6
0
		public virtual void DrawCommandButton(NodeCommandPartRendererEventArgs info)
		{
			bool mouseOver = (info.Node.MouseOverNodePart == eMouseOverNodePart.Command);
			CommandColors c=new CommandColors();
			if(mouseOver)
			{
				c.BackColor = info.MouseOverBackColor;
				c.BackColor2 = info.MouseOverBackColor2;
				c.BackColorGradientAngle = info.MouseOverBackColorGradientAngle;
				c.ForeColor = info.MouseOverForeColor;
			}
			else
			{
				c.BackColor = info.BackColor;
				c.BackColor2 = info.BackColor2;
				c.BackColorGradientAngle = info.BackColorGradientAngle;
				c.ForeColor = info.ForeColor;
			}
			
			Rectangle fillBounds = info.CommandPartBounds;
			fillBounds.Width--;
			fillBounds.Height--;
			
			Region oldRegion = info.Graphics.Clip.Clone() as Region;
			info.Graphics.SetClip(fillBounds,CombineMode.Intersect);
			
			if(c.BackColor2.IsEmpty)
			{
				if(!c.BackColor.IsEmpty)
				{
					using(SolidBrush brush=new SolidBrush(c.BackColor))
						info.Graphics.FillRectangle(brush,fillBounds);
				}
			}
			else
			{
				using(LinearGradientBrush brush=DisplayHelp.CreateLinearGradientBrush(info.CommandPartBounds, c.BackColor, c.BackColor2, c.BackColorGradientAngle))
					info.Graphics.FillRectangle(brush,fillBounds);
			}

			if(c.ForeColor.IsEmpty) return;

			int width=6;
			int height=3;
			GraphicsPath path=new GraphicsPath();
			Point p=new Point(info.CommandPartBounds.X+(info.CommandPartBounds.Width-width)/2,info.CommandPartBounds.Y+(info.CommandPartBounds.Height-height)/2);
			path.AddLine(p.X, p.Y, p.X+width,p.Y);
			path.AddLine(p.X+width,p.Y,p.X+width/2,p.Y+height);
			path.AddLine(p.X, p.Y,p.X+width/2,p.Y+height);
			path.CloseAllFigures();
			
			using(SolidBrush brush=new SolidBrush(c.ForeColor))
				info.Graphics.FillPath(brush,path);

			path.Dispose();
			
			info.Graphics.Clip = oldRegion;
		}
Exemplo n.º 7
0
		/// <summary>
		/// Gets the graphics path that represents triangle.
		/// </summary>
		/// <param name="p">Top left position of the triangle.</param>
		/// <param name="size">Size of the triangle.</param>
		/// <param name="direction">Pointing direction of the triangle.</param>
		/// <returns>Returns graphics path for the triangle of given size and pointing in given direction.</returns>
		public static GraphicsPath GetTrianglePath(Point p, int size, eTriangleDirection direction)
		{
			GraphicsPath path=new GraphicsPath();
			switch(direction)
			{
				case eTriangleDirection.Left:
				{
					p.X--;
					path.AddLine(p.X+size/2,p.Y,p.X+size/2,p.Y+size);
					path.AddLine(p.X,p.Y+size/2,p.X+size/2,p.Y);
					path.CloseAllFigures();
					break;
				}
				case eTriangleDirection.Right:
				{
					path.AddLine(p.X,p.Y,p.X,p.Y+size);
					path.AddLine(p.X+size/2,p.Y+size/2,p.X,p.Y);
					path.CloseAllFigures();
					break;
				}
				case eTriangleDirection.Top:
				{
                    int midY = (int)Math.Ceiling(p.Y + (float)size / 2);
                    int midX = (int)Math.Ceiling(p.X + (float)size / 2);
                    path.AddLine(p.X, midY, p.X + size, midY);
                    path.AddLine(midX, p.Y, p.X, midY);
					path.CloseAllFigures();
					break;
				}
				case eTriangleDirection.Bottom:
				{
                    int midY = (int)Math.Floor(p.Y + (float)size / 2);
                    int midX = (int)Math.Floor(p.X + (float)size / 2);
                    path.AddLine(p.X, p.Y, p.X + size - 1, p.Y); // -1 hack for GDI+ FillPath bug
                    path.AddLine(midX, midY, p.X, p.Y);
					path.CloseAllFigures();
					break;
				}
			}

			return path;
		}
Exemplo n.º 8
0
        public static GraphicsPath ToRoundedCorneredGraphicsPath(this RectangleF rect, float radius)
        {
            var lGraphicsPath = new GraphicsPath();
            lGraphicsPath.AddArc(rect.Left, rect.Top, radius, radius, 180, 90);
            lGraphicsPath.AddArc(rect.Left + rect.Width - radius, rect.Top, radius, radius, 270, 90);
            lGraphicsPath.AddArc(rect.Left + rect.Width - radius, rect.Top + rect.Height - radius, radius, radius, 0, 90);
            lGraphicsPath.AddArc(rect.Left, rect.Top + rect.Height - radius, radius, radius, 90, 90);
            lGraphicsPath.CloseAllFigures();

            return lGraphicsPath;
        }
Exemplo n.º 9
0
        public static void DrawRoundedRectangle(this Graphics g, Pen pen, RectangleF bounds, float cornerRadius)
        {
            var lGraphicsPath = new GraphicsPath();
            lGraphicsPath.AddArc(bounds.Left, bounds.Top, cornerRadius, cornerRadius, 180, 90);
            lGraphicsPath.AddArc(bounds.Right - cornerRadius - 1, bounds.Top, cornerRadius, cornerRadius, 270, 90);
            lGraphicsPath.AddArc(bounds.Right - cornerRadius - 1, bounds.Bottom - cornerRadius - 1, cornerRadius, cornerRadius, 0, 90);
            lGraphicsPath.AddArc(bounds.Left, bounds.Bottom - cornerRadius - 1, cornerRadius, cornerRadius, 90, 90);
            lGraphicsPath.CloseAllFigures();

            g.DrawPath(pen, lGraphicsPath);
        }
Exemplo n.º 10
0
        public static void FillRoundedRectangle(this Graphics g, Brush brush, RectangleF bounds, float cornerRadius)
        {
            var lGraphicsPath = new GraphicsPath();
            lGraphicsPath.AddArc(bounds.Left, bounds.Top, cornerRadius, cornerRadius, 180, 90);
            lGraphicsPath.AddArc(bounds.Right - cornerRadius - 1, bounds.Top, cornerRadius, cornerRadius, 270, 90);
            lGraphicsPath.AddArc(bounds.Right - cornerRadius - 1, bounds.Bottom - cornerRadius - 1, cornerRadius, cornerRadius, 0, 90);
            lGraphicsPath.AddArc(bounds.Left, bounds.Bottom - cornerRadius - 1, cornerRadius, cornerRadius, 90, 90);
            lGraphicsPath.CloseAllFigures();

            g.FillPath(brush, lGraphicsPath);
        }
 protected override void OnLoad(EventArgs e)
 {
     int R = 100;                                        //圆角半径
     GraphicsPath path = new GraphicsPath();             //图形路径
     path.AddArc(this.Width - R, this.Height - R, R, R, 0, 90);//添加右下圆角
     path.AddArc(0, this.Height - R, R, R, 90, 90);      //添加左下圆角
     path.AddArc(0, 0, R, R, 180, 90);                   //添加左上圆角
     path.AddArc(this.Width - R, 0, R, R, 270, 90);      //添加右上圆角
     path.CloseAllFigures();                             //闭合路径
     this.Region = new Region(path);                     //设置窗体有效区域
 }
Exemplo n.º 12
0
        private GraphicsPath BuildTriangleUp(Rectangle bounds)
        {
            int xPadding = bounds.Width / 10;
            int yPadding = bounds.Height / 10;
            int triangleHalf = Math.Max(0, bounds.Width / 2 - xPadding);

            GraphicsPath triangle = new GraphicsPath();
            triangle.AddLine(bounds.Left + xPadding, bounds.Bottom - yPadding, bounds.Left + xPadding + 2 * triangleHalf, bounds.Bottom - yPadding);
            triangle.AddLine(bounds.Left + xPadding + 2 * triangleHalf, bounds.Bottom - yPadding, bounds.Left + xPadding + triangleHalf, bounds.Top + yPadding);
            triangle.CloseAllFigures();
            return triangle;
        }
Exemplo n.º 13
0
        private void DrawRectangle(Graphics gfx, Rectangle Bounds, Pen DrawPen, Brush FillBrush)
        {
            using (GraphicsPath gfxPath = new GraphicsPath())
            {
                DrawPen.EndCap = DrawPen.StartCap = LineCap.Flat;
                gfxPath.AddRectangle(Bounds);
                gfxPath.CloseAllFigures();

                gfx.FillPath(FillBrush, gfxPath);
                gfx.DrawPath(DrawPen, gfxPath);
            }
        }
Exemplo n.º 14
0
        public static void RoundBorderForm(Form frm)
        {
            var bounds = new Rectangle(0, 0, frm.Width, frm.Height);
            const int cornerRadius = 18;
            var path = new GraphicsPath();
            path.AddArc(bounds.X, bounds.Y, cornerRadius, cornerRadius, 180, 90);
            path.AddArc(bounds.X + bounds.Width - cornerRadius, bounds.Y, cornerRadius, cornerRadius, 270, 90);
            path.AddArc(bounds.X + bounds.Width - cornerRadius, bounds.Y + bounds.Height - cornerRadius, cornerRadius, cornerRadius, 0, 90);
            path.AddArc(bounds.X, bounds.Y + bounds.Height - cornerRadius, cornerRadius, cornerRadius, 90, 90);
            path.CloseAllFigures();

            frm.Region = new Region(path);
        }
 public override void DrawGlyph(PaintEventArgs e, Rectangle bounds)
 {
     GraphicsPath path;
     int num = Math.Max(0, (bounds.Width - bounds.Height) / 2);
     int num2 = Math.Max(0, (bounds.Height - bounds.Width) / 2);
     bounds.Inflate(-num, -num2);
     if ((bounds.Width % 2) == 1)
     {
         bounds.Width--;
     }
     if ((bounds.Height % 2) == 1)
     {
         bounds.Height--;
     }
     if (bounds.Width > bounds.Height)
     {
         bounds.Width = bounds.Height;
     }
     if (bounds.Height > bounds.Width)
     {
         bounds.Height = bounds.Width;
     }
     bounds.Inflate(-2, -2);
     int width = bounds.Width;
     int num4 = width / 3;
     int num5 = width / 4;
     int num6 = bounds.X + (bounds.Width / 2);
     float x = bounds.X + (0.5f * (bounds.Width + 3));
     float num8 = x - 3f;
     SmoothingMode smoothingMode = e.Graphics.SmoothingMode;
     e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
     using (path = new GraphicsPath())
     {
         Point[] points = new Point[] { new Point(bounds.Left + num4, bounds.Bottom), new Point(bounds.Right - num4, bounds.Bottom), new Point(bounds.Right, bounds.Bottom - num4), new Point(bounds.Right, bounds.Top + num4), new Point(bounds.Right - num4, bounds.Top), new Point(bounds.Left + num4, bounds.Top), new Point(bounds.Left, bounds.Top + num4), new Point(bounds.Left, bounds.Bottom - num4) };
         path.AddLines(points);
         path.CloseAllFigures();
         e.Graphics.FillPath(Brushes.Red, path);
         e.Graphics.DrawPath(Pens.DarkGray, path);
     }
     using (path = new GraphicsPath())
     {
         PointF[] tfArray = new PointF[] { new PointF(num8, (float) ((bounds.Top + num5) - 1)), new PointF(x, (float) ((bounds.Top + num5) - 1)), new PointF(num6 + 1.2f, (-0.5f + bounds.Top) + ((bounds.Height * 2f) / 3f)), new PointF(num6 - 1.2f, (-0.5f + bounds.Top) + ((bounds.Height * 2f) / 3f)) };
         path.AddLines(tfArray);
         path.CloseAllFigures();
         e.Graphics.FillPath(Brushes.White, path);
     }
     RectangleF rect = new RectangleF((float) num6, (float) (bounds.Bottom - num5), 0f, 0f);
     rect.Inflate(1.5f, 1.5f);
     e.Graphics.FillEllipse(Brushes.White, rect);
     e.Graphics.SmoothingMode = smoothingMode;
 }
Exemplo n.º 16
0
        private void frmMain_Paint(object sender, PaintEventArgs e)
        {
            Rectangle Bounds       = new Rectangle(0, 0, this.Width, this.Height);
            int       CornerRadius = 20;

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddArc(Bounds.X, Bounds.Y, CornerRadius, CornerRadius, 180, 90);
            path.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y, CornerRadius, CornerRadius, 270, 90);
            path.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
            path.AddArc(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
            path.CloseAllFigures();

            this.Region = new Region(path);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            float BorderThickness = 2;
            Size  tSize           = e.Graphics.MeasureString(this.Text, this.Font).ToSize();
            int   ArcWidth        = this.RoundCorners * 2;
            int   ArcHeight       = this.RoundCorners * 2;
            int   ArcX1           = 0;
            int   ArcX2           = this.Width - (ArcWidth + 1);
            int   ArcY1           = tSize.Height / 2;
            int   ArcY2           = this.Height - (ArcHeight + 1);

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

            System.Drawing.Drawing2D.GraphicsPath path       = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.GraphicsPath pathString = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BackgroundBrush             = new SolidBrush(this.BackColor);
            System.Drawing.Brush BorderBrush = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen   = new Pen(BorderBrush, BorderThickness);



            Rectangle r = new Rectangle(this.ClientRectangle.Left, this.ClientRectangle.Top, this.ClientRectangle.Width, this.ClientRectangle.Height);

            try
            {
                //Create Rounded Rectangle Path------
                path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, 90); // Top Left
                path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, 90); //Top Right
                path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, 90); //Bottom Right
                path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, 90);  //Bottom Left
                path.CloseAllFigures();
            }
            catch (Exception ex) { }



            int offset = 1;

            pathString.AddLine(RoundCorners + offset, 0, RoundCorners + tSize.Width, 0);
            pathString.AddLine(RoundCorners + offset + tSize.Width, 0, RoundCorners + offset + tSize.Width, tSize.Height);
            pathString.AddLine(tSize.Width, tSize.Height, RoundCorners + offset, tSize.Height);
            pathString.AddLine(RoundCorners + offset, tSize.Height, RoundCorners + offset, 0);

            e.Graphics.FillPath(BackgroundBrush, path);
            e.Graphics.DrawPath(BorderPen, path);
            e.Graphics.FillPath(new SolidBrush(this.BackColor), pathString);
            e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), RoundCorners + offset, 0);
        }
Exemplo n.º 18
0
        private void UpdateRegion()
        {
            FindDiameter();

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

            FormRegion.AddArc(0, 0, m_fDiameter, m_fDiameter, -90, -180);
            FormRegion.AddLine(m_fRadius, this.Height - 1, this.Width - m_fDiameter, this.Height - 1);
            FormRegion.AddArc(this.Width, 0, m_fDiameter, m_fDiameter, 90, -180);
            FormRegion.AddLine(m_fRadius, 0, this.Width - m_fDiameter, 0);

            FormRegion.CloseAllFigures();

            this.Region = new System.Drawing.Region(FormRegion);
        }
Exemplo n.º 19
0
        private void button1_Paint_1(object sender, PaintEventArgs e)
        {
            Rectangle Bounds       = new Rectangle(0, 0, btnNext.Width, btnNext.Height);
            int       CornerRadius = 50;

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddArc(Bounds.X, Bounds.Y, CornerRadius, CornerRadius, 180, 90);
            path.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y, CornerRadius, CornerRadius, 270, 90);
            path.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
            path.AddArc(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
            path.CloseAllFigures();

            btnNext.Region     = new Region(path);
            btnPrevious.Region = new Region(path);
        }
Exemplo n.º 20
0
 private void AddToDoForm_Paint(object sender, PaintEventArgs e)
 {
     Graphics graphics = e.Graphics;
     int CornerRadius = 10;
     Pen pen = new Pen(Color.Black, 2);
     pen.EndCap = pen.StartCap = LineCap.Round;
     System.Drawing.Drawing2D.GraphicsPath gfxPath = new System.Drawing.Drawing2D.GraphicsPath();
     gfxPath.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90);
     gfxPath.AddArc(0 + this.Width - CornerRadius, 0, CornerRadius, CornerRadius, 270, 90);
     gfxPath.AddArc(0 + this.Width - CornerRadius, 0 + this.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
     gfxPath.AddArc(0, 0 + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
     gfxPath.CloseAllFigures();
     graphics.DrawPath(pen,gfxPath);
     this.Region = new Region(gfxPath);
 }
Exemplo n.º 21
0
        // Returns a percentage of the ErrorArea circle trespassing on the zone.
        // If anyone knows calculus better than me I'd welcome you to clean up this function =)
        public float TrespassArea(Point3D pntLocation, float flErrorRadius) {

            float flReturnPercentage = 0.0F;
            float flErrorArea = (float)(flErrorRadius * flErrorRadius * Math.PI);

            GraphicsPath gpLocationError = new GraphicsPath();
            gpLocationError.AddEllipse(new RectangleF(pntLocation.X - flErrorRadius, pntLocation.Y - flErrorRadius, flErrorRadius * 2, flErrorRadius * 2));
            gpLocationError.CloseAllFigures();

            Region regZone = new Region(this.ZoneGraphicsPath);
            regZone.Intersect(gpLocationError);
            RectangleF[] a_recScans = regZone.GetRegionScans(new Matrix());
            Rectangle recIntersection = new Rectangle(int.MaxValue, int.MaxValue, 0, 0);

            int iPixelCount = 0;

            if (a_recScans.Length > 0) {

                for (int i = 0; i < a_recScans.Length; i++) {
                    recIntersection.X = a_recScans[i].X < recIntersection.X ? (int)a_recScans[i].X : recIntersection.X;
                    recIntersection.Y = a_recScans[i].Y < recIntersection.Y ? (int)a_recScans[i].Y : recIntersection.Y;

                    recIntersection.Width = a_recScans[i].Right > recIntersection.Right ? (int)a_recScans[i].Right - recIntersection.X : recIntersection.Width;
                    recIntersection.Height = a_recScans[i].Bottom > recIntersection.Bottom ? (int)a_recScans[i].Bottom - recIntersection.Y : recIntersection.Height;
                }

                //recIntersection = this.RecFtoRec(regZone.GetBounds(this.CreateGraphics()));
                Point pntVisible = new Point(recIntersection.X, recIntersection.Y);

                for (pntVisible.X = recIntersection.X; pntVisible.X <= recIntersection.Right; pntVisible.X++) {
                    for (pntVisible.Y = recIntersection.Y; pntVisible.Y <= recIntersection.Bottom; pntVisible.Y++) {
                        if (regZone.IsVisible(pntVisible) == true) {
                            iPixelCount++;
                        }
                    }
                }
            }

            flReturnPercentage = (float)iPixelCount / flErrorArea;

            // Accounts for low error when using this method. (98.4% should be 100%)
            // but using regZone.GetRegionScans is slightly lossy.
            if (flReturnPercentage > 0.0F) {
                flReturnPercentage = (float)Math.Min(1.0F, flReturnPercentage + 0.02);
            }

            return flReturnPercentage;
        }
Exemplo n.º 22
0
        private void DrawRoundedRectangle(Graphics gfx, Rectangle Bounds, int CornerRadius, Pen DrawPen, Brush FillBrush)
        {
            using (GraphicsPath gfxPath = new GraphicsPath())
            {
                DrawPen.EndCap = DrawPen.StartCap = LineCap.Round;

                gfxPath.AddArc(Bounds.X, Bounds.Y, CornerRadius, CornerRadius, 180, 90);
                gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y, CornerRadius, CornerRadius, 270, 90);
                gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
                gfxPath.AddArc(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
                gfxPath.CloseAllFigures();

                gfx.FillPath(FillBrush, gfxPath);
                gfx.DrawPath(DrawPen, gfxPath);
            }
        }
Exemplo n.º 23
0
        public void DrawLeadHeadArrow(Graphics.Rectangle bounds, SolidColor startColor, SolidColor endColor)
        {
            using (System.Drawing.Drawing2D.GraphicsPath leadHeadPath = new System.Drawing.Drawing2D.GraphicsPath())
            {
                leadHeadPath.AddLines(new System.Drawing.PointF[] { new Point(bounds.Right - 4, bounds.Y + 4),
                                                                    new Point(bounds.Right - 4, bounds.Bottom - 4),
                                                                    new Point(bounds.Right - bounds.Height + 4, bounds.Bottom - 4) });

                leadHeadPath.CloseAllFigures();

                using (System.Drawing.Drawing2D.LinearGradientBrush lgb
                           = new System.Drawing.Drawing2D.LinearGradientBrush(bounds, startColor, endColor, 90f))
                {
                    base.PlatformGraphics.FillPath(lgb, leadHeadPath);
                }
            }
        }
Exemplo n.º 24
0
        private void DrawRoundedRectangle(Graphics gfx, Rectangle Bounds, int CornerRadius, Pen DrawPen)
        {
            int strokeOffset = Convert.ToInt32(Math.Ceiling(DrawPen.Width));
            Bounds = Rectangle.Inflate(Bounds, -strokeOffset, -strokeOffset);

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

            GraphicsPath gfxPath = new GraphicsPath();
            gfxPath.AddArc(Bounds.X, Bounds.Y, CornerRadius, CornerRadius, 180, 90);
            gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y, CornerRadius, CornerRadius, 270, 90);
            gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
            gfxPath.AddArc(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
            gfxPath.CloseAllFigures();

            //gfx.FillPath(new SolidBrush(FillColor), gfxPath);
            gfx.DrawPath(DrawPen, gfxPath);
        }
Exemplo n.º 25
0
        private void pnlForm_Paint(object sender, PaintEventArgs e)
        {
            Rectangle Bounds       = new Rectangle(0, 0, pnlForm.Width, pnlForm.Height);
            int       CornerRadius = 20;

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddArc(Bounds.X, Bounds.Y, CornerRadius, CornerRadius, 180, 90);
            path.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y, CornerRadius, CornerRadius, 270, 90);
            path.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
            path.AddArc(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
            path.CloseAllFigures();

            pnlForm.Region         = new Region(path);
            pnlPaiement.Region     = new Region(path);
            pnlTaches.Region       = new Region(path);
            pnlConsultation.Region = new Region(path);
        }
Exemplo n.º 26
0
        public override void PaintButtonImage(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle imagebounds)
        {
            if (imagebounds.Width <= 0 || imagebounds.Height <= 0) return;

            // Paint image background
            RibbonOverflowButtonItem overflow = button as RibbonOverflowButtonItem;
            if (overflow == null || overflow.RibbonBar==null)
            {
                base.PaintButtonImage(button, pa, image, imagebounds);
                return;
            }
            ElementStyle backStyle = overflow.RibbonBar.GetPaintBackgroundStyle();
            ElementStyle titleStyle = overflow.RibbonBar.TitleStyle;

            int cornerSize = 3;

            if (backStyle.BackColorBlend.Count > 0)
                DisplayHelp.FillRoundedRectangle(pa.Graphics, imagebounds, cornerSize, backStyle.BackColorBlend[0].Color, backStyle.BackColorBlend[backStyle.BackColorBlend.Count-1].Color, overflow.RibbonBar.BackgroundStyle.BackColorGradientAngle);
            else
                DisplayHelp.FillRoundedRectangle(pa.Graphics, imagebounds, cornerSize, backStyle.BackColor, backStyle.BackColor2, backStyle.BackColorGradientAngle);
            if(!button.Expanded)
                DisplayHelp.FillRectangle(pa.Graphics, new Rectangle(imagebounds.X+1, imagebounds.Bottom - 8, imagebounds.Width-2, 7), titleStyle.BackColor, titleStyle.BackColor2, titleStyle.BackColorGradientAngle);
            
            if (!backStyle.BorderColor.IsEmpty)
            {
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddLine(imagebounds.X, imagebounds.Bottom - 8, imagebounds.Right, imagebounds.Bottom - 8);
                    ElementStyleDisplay.AddCornerArc(path, imagebounds, cornerSize, eCornerArc.BottomRight);
                    ElementStyleDisplay.AddCornerArc(path, imagebounds, cornerSize, eCornerArc.BottomLeft);
                    path.CloseAllFigures();
                    using (SolidBrush brush = new SolidBrush(Color.FromArgb(192, backStyle.BorderColor)))
                        pa.Graphics.FillPath(brush, path);
                }
            }

            DisplayHelp.DrawRoundGradientRectangle(pa.Graphics, imagebounds, backStyle.BorderColor, backStyle.BorderColor2, backStyle.BorderGradientAngle, 1, cornerSize);

            imagebounds.X += (imagebounds.Width - image.Width) / 2;
            imagebounds.Y += 4;
            imagebounds.Width = image.Width;
            imagebounds.Height = image.Height;

            image.DrawImage(pa.Graphics, imagebounds);
        }
 public override void DrawGlyph(PaintEventArgs e, Rectangle bounds)
 {
     GraphicsPath path;
     Point[] pointArray;
     SolidBrush brush;
     int num = Math.Max(0, (bounds.Height - bounds.Width) / 2);
     bounds.Inflate(0, -num);
     bounds.Inflate(-2, -2);
     int num2 = Math.Min(bounds.Width, bounds.Height);
     int num3 = 2;
     int num4 = num2 / 4;
     int x = bounds.X + (bounds.Width / 2);
     int num6 = bounds.X + ((bounds.Width + 2) / 2);
     int num7 = num6 - 2;
     SmoothingMode smoothingMode = e.Graphics.SmoothingMode;
     e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
     using (path = new GraphicsPath())
     {
         pointArray = new Point[] { new Point(bounds.Left + num3, bounds.Bottom), new Point(bounds.Right - num3, bounds.Bottom), new Point(bounds.Right, bounds.Bottom - num3), new Point(num6, bounds.Top), new Point(num7, bounds.Top), new Point(bounds.Left, bounds.Bottom - num3) };
         path.AddLines(pointArray);
         path.CloseAllFigures();
         using (brush = new SolidBrush(Color.FromArgb(120, Color.Gold)))
         {
             using (Pen pen = new Pen(Color.FromArgb(150, Color.Goldenrod)))
             {
                 e.Graphics.FillPath(brush, path);
                 e.Graphics.DrawPath(pen, path);
             }
         }
     }
     using (path = new GraphicsPath())
     {
         pointArray = new Point[] { new Point(num7, bounds.Top + num4), new Point(num6, bounds.Top + num4), new Point(x, bounds.Top + ((bounds.Height * 2) / 3)) };
         path.AddLines(pointArray);
         path.CloseAllFigures();
         using (brush = new SolidBrush(Color.FromArgb(40, 40, 40)))
         {
             e.Graphics.FillPath(brush, path);
         }
     }
     Rectangle rect = new Rectangle(x, bounds.Bottom - num4, 0, 0);
     rect.Inflate(1, 1);
     e.Graphics.FillEllipse(Brushes.Black, rect);
     e.Graphics.SmoothingMode = smoothingMode;
 }
Exemplo n.º 28
0
        private void button1_Paint(object sender, PaintEventArgs e)
        {
            Rectangle Bounds       = new Rectangle(0, 0, btnEnregistrer.Width, btnEnregistrer.Height);
            int       CornerRadius = 5;

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddArc(Bounds.X, Bounds.Y, CornerRadius, CornerRadius, 180, 90);
            path.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y, CornerRadius, CornerRadius, 270, 90);
            path.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
            path.AddArc(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
            path.CloseAllFigures();

            btnEnregistrer.Region  = new Region(path);
            btnModifier.Region     = new Region(path);
            btnSupprimer.Region    = new Region(path);
            btnAjouterTache.Region = new Region(path);
            btnSaveTaches.Region   = new Region(path);
        }
Exemplo n.º 29
0
 private System.Drawing.Drawing2D.GraphicsPath CreateGlarePath(System.Drawing.Rectangle bounds, int radius)
 {
     System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
     if (radius == 0)
     {
         graphicsPath.AddLine(bounds.X, bounds.Y, bounds.Right - 1, bounds.Y);
         graphicsPath.AddLine(bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 1);
     }
     else
     {
         graphicsPath.AddLine(bounds.X + radius, bounds.Y, bounds.Right - radius - 1, bounds.Y);
         graphicsPath.AddArc(bounds.Right - radius - 1, bounds.Y, radius, radius, 270.0F, 90.0F);
         graphicsPath.AddLine(bounds.Right - 1, bounds.Y + radius, bounds.Right - 1, bounds.Bottom - radius);
     }
     graphicsPath.AddBezier(bounds.Right - 1, bounds.Bottom - 1, bounds.Right, bounds.Y + (bounds.Height / 2), bounds.X + (bounds.Width / 2), bounds.Y, bounds.X, bounds.Y);
     graphicsPath.CloseAllFigures();
     return(graphicsPath);
 }
Exemplo n.º 30
0
        protected void DrawFilledPath(List <SeriesFigure> figures, System.Drawing.Pen gdiPen, System.Drawing.SolidBrush gdiBrush)
        {
            var path = new System.Drawing.Drawing2D.GraphicsPath();

            foreach (var figure in figures) // could do parallel For loop here...
            {
                path.StartFigure();

                var points     = figure.Points;
                var pointCount = figure.Points.Count;
                for (int i = 0; i < pointCount - 1; i++)
                {
                    path.AddLine(points[i], points[i + 1]);
                }
            }
            path.CloseAllFigures();
            GdiGraphics.FillPath(gdiBrush, path);
            GdiGraphics.DrawPath(gdiPen, path);
        }
Exemplo n.º 31
0
		public static void DrawFrame(Graphics dc, RectangleF r, float cornerRadius, Color color)
		{
			Pen pen = new Pen(color);
			if (cornerRadius <= 0)
			{
				dc.DrawRectangle(pen, Rect(r));
				return;
			}
			cornerRadius = (float)Math.Min(cornerRadius, Math.Floor(r.Width) - 2);
			cornerRadius = (float)Math.Min(cornerRadius, Math.Floor(r.Height) - 2);

			GraphicsPath path = new GraphicsPath();
			path.AddArc(r.X,r.Y, cornerRadius, cornerRadius, 180, 90);
			path.AddArc(r.Right-cornerRadius,r.Y, cornerRadius, cornerRadius, 270, 90);
			path.AddArc(r.Right-cornerRadius,r.Bottom-cornerRadius, cornerRadius, cornerRadius, 0, 90);
			path.AddArc(r.X,r.Bottom-cornerRadius, cornerRadius, cornerRadius, 90, 90);
			path.CloseAllFigures();
			dc.DrawPath(pen, path);
		}
Exemplo n.º 32
0
		public override GraphicsPath CreatePath(Rectangle rectangle )
		{
			//http://stackoverflow.com/questions/628261/how-to-draw-rounded-rectangle-with-variable-width-border-inside-of-specific-bound
		
			GraphicsPath gfxPath = new GraphicsPath();
			if (CornerRadius == 0)
			{
				gfxPath.AddRectangle(rectangle);
			}
			else
			{
				gfxPath.AddArc(rectangle.X, rectangle.Y,CornerRadius , CornerRadius, 180, 90);
				gfxPath.AddArc(rectangle.X + rectangle.Width - CornerRadius, rectangle.Y, CornerRadius, CornerRadius, 270, 90);
				gfxPath.AddArc(rectangle.X + rectangle.Width - CornerRadius, rectangle.Y + rectangle.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
				gfxPath.AddArc(rectangle.X, rectangle.Y + rectangle.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
			}
			gfxPath.CloseAllFigures();
			return gfxPath;
		}
Exemplo n.º 33
0
        public override void DrawRoundedRect( Color colour, float radius, float x, float y, float width, float height )
        {
            GraphicsPath path = new GraphicsPath();
            float x1 = x, y1 = y, x2 = x + width, y2 = y + height;

            float r = radius, dia = radius * 2;
            path.AddArc( x1, y1, dia, dia, 180, 90 );
            path.AddLine( x1 + r, y1, x2 - r, y1 );
            path.AddArc( x2 - dia, y1, dia, dia, 270, 90 );
            path.AddLine( x2, y1 + r, x2, y2 - r );
            path.AddArc( x2 - dia, y2 - dia, dia, dia, 0, 90 );
            path.AddLine( x1 + r, y2, x2 - r, y2 );
            path.AddArc( x1, y2 - dia, dia, dia, 90, 90 );
            path.AddLine( x1, y1 + r, x1, y2 - r );
            path.CloseAllFigures();

            using( Brush brush = new SolidBrush( colour ) )
                g.FillPath( brush, path );
            path.Dispose();
        }
        /// <summary>
        /// Draw triangular type expand button.
        /// </summary>
        /// <param name="e">Expand button context information.</param>
        public override void DrawExpandButton(NodeExpandPartRendererEventArgs e)
        {
            if (e.ExpandPartBounds.IsEmpty)
                return;

            SmoothingMode sm = e.Graphics.SmoothingMode;
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle r = new Rectangle(e.ExpandPartBounds.X , e.ExpandPartBounds.Y + (e.ExpandPartBounds.Height - 8) / 2, 5, 8);

            GraphicsPath path = null;
            if (e.Node.Expanded)
            {
                path = new GraphicsPath();
                path.AddLine(r.X, r.Y + 5, r.X + 5, r.Y);
                path.AddLine(r.X + 5, r.Y, r.X + 5, r.Y + 5);
                path.CloseAllFigures();
            }
            else
            {
                path = new GraphicsPath();
                path.AddLine(r.X, r.Y, r.X, r.Bottom);
                path.AddLine(r.X, r.Bottom, r.X + 4, r.Y + r.Height / 2);
                path.CloseAllFigures();
            }

            Brush brush = GetBackgroundBrush(e);
            if (brush != null)
            {
                e.Graphics.FillPath(brush, path);
                brush.Dispose();
            }

            Pen pen = GetBorderPen(e);
            if(pen!=null)
            {
                e.Graphics.DrawPath(pen, path);
                pen.Dispose();
            }
            e.Graphics.SmoothingMode = sm;
            if(path!=null) path.Dispose();
        }
            /// <summary>
            /// Builds the rounded rectangle.
            /// </summary>
            /// <param name="bounds">The bounds.</param>
            /// <param name="roundness">The roundness.</param>
            /// <returns>GraphicsPath.</returns>
            /// <exception cref="System.ArgumentException">Roundess value must be greater than -1!</exception>
            internal GraphicsPath BuildRoundedRectangle(Rectangle bounds, byte roundness)
            {
                System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
                if (roundness < 0)
                {
                    throw new ArgumentException("Roundess value must be greater than -1!");
                }
                if (roundness == 0)
                {
                    gp.AddRectangle(bounds);
                }
                else
                {
                    gp.AddArc(bounds.Right - roundness, bounds.Top, roundness, roundness, 270, 90);
                    gp.AddArc(bounds.Right - roundness, bounds.Bottom - roundness, roundness, roundness, 0, 90);
                    gp.AddArc(bounds.Left, bounds.Bottom - roundness, roundness, roundness, 90, 90);
                    gp.AddArc(bounds.Left, bounds.Top, roundness, roundness, 180, 90);
                    gp.CloseAllFigures();
                }

                return(gp);
            }
Exemplo n.º 36
0
        public void Draw(Graphics g)
        {
            GraphicsPath path = new GraphicsPath();
            path.AddPolygon(m_HexagonPoints);
            path.CloseAllFigures();

            using (SolidBrush brush = new SolidBrush(m_Color))
            {
                g.FillPath(brush, path);
            }

            if (m_MouseOver || m_Selected)
            {
                SmoothingMode sm = g.SmoothingMode;
                g.SmoothingMode = SmoothingMode.AntiAlias;
                using (Pen pen = new Pen(Color.FromArgb(41, 92, 150), 2))
                    g.DrawPath(pen, path);
                using (Pen pen = new Pen(Color.FromArgb(149, 178, 239), 1))
                    g.DrawPath(pen, path);
                g.SmoothingMode = sm;
            }

            path.Dispose();
        }
Exemplo n.º 37
0
		protected internal void DrawInsertMarker(System.Drawing.Graphics g)
		{
            IOwner owner = GetOwner() as IOwner;
            if (m_DesignInsertMarker == eDesignInsertPosition.None || !this.Visible || !this.Displayed || !(owner != null && owner.DragInProgress || this.DesignMode))
                return;

            Color lineColor = ColorScheme.GetColor("834DD5");
            Color fillColor = ColorScheme.GetColor("CCCFF8");

            int size = 4;
            int lineThickness = 1;
            int padding = 2;

			if(IsDesignMarkHorizontal)
			{
                Point start = new Point(m_Rect.X, m_Rect.Y + padding), end = new Point(m_Rect.X, m_Rect.Bottom - (padding + 1));
                if (m_DesignInsertMarker == eDesignInsertPosition.After)
                {
                    start = new Point(m_Rect.Right - size * 2, m_Rect.Y + padding);
                    end = new Point(m_Rect.Right - size * 2, m_Rect.Bottom - (padding+1));
                }

                using (SolidBrush fillBrush = new SolidBrush(fillColor))
                {
                    using (Pen pen = new Pen(lineColor, 1))
                    {
                        using (GraphicsPath path = new GraphicsPath())
                        {
                            path.AddLine(start.X, start.Y + size, start.X + size, start.Y);
                            path.AddLine(start.X + size * 2, start.Y + size, start.X + (size * 2 - (size - lineThickness)), start.Y + size);
                            path.AddLine(end.X + (size * 2 - (size - lineThickness)), end.Y - size, end.X + size * 2, end.Y - size);
                            path.AddLine(end.X + size, end.Y, end.X, end.Y - size);
                            path.AddLine(end.X + (size - lineThickness), end.Y - size, start.X + (size - lineThickness), start.Y + size);
                            path.CloseAllFigures();

                            g.FillPath(fillBrush, path);
                            g.DrawPath(pen, path);
                        }
                    }
                }
			}
			else
			{
                Point start = new Point(m_Rect.X + padding, m_Rect.Y), end = new Point(m_Rect.Right - (padding+1), m_Rect.Y);
                if (m_DesignInsertMarker == eDesignInsertPosition.After)
                {
                    start = new Point(m_Rect.X + padding, m_Rect.Bottom - (size * 2 + 1));
                    end = new Point(m_Rect.Right - (padding + 1), m_Rect.Bottom - (size * 2 + 1));
                }

                using (SolidBrush fillBrush = new SolidBrush(fillColor))
                {
                    using (Pen pen = new Pen(lineColor, 1))
                    {
                        using (GraphicsPath path = new GraphicsPath())
                        {
                            path.AddLine(start.X, start.Y + size, start.X + size, start.Y);
                            path.AddLine(start.X + size, start.Y + (size - lineThickness), end.X - size, end.Y + (size - lineThickness));
                            path.AddLine(end.X - size, end.Y, end.X, end.Y + size);
                            path.AddLine(end.X - size, end.Y + size * 2, end.X - size, end.Y + (size*2 - (size-padding)));
                            path.AddLine(start.X + size, start.Y + (size * 2 - (size - padding)), start.X + size, start.Y + size * 2);

                            path.CloseAllFigures();

                            g.FillPath(fillBrush, path);
                            g.DrawPath(pen, path);
                        }
                    }
                }
                //if(m_DesignInsertMarker==eDesignInsertPosition.Before)
                //{
                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Top;
                //    p[1].X=m_Rect.Left+1;
                //    p[1].Y=m_Rect.Top+4;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Top+2;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Top+2;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Right-1;
                //    p[0].Y=m_Rect.Top;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Top+4;
                //    g.DrawLines(pen,p);
                //}
                //else
                //{
                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Bottom-4;
                //    p[1].X=m_Rect.Left+1;
                //    p[1].Y=m_Rect.Bottom;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Bottom-2;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Bottom-2;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Right-1;
                //    p[0].Y=m_Rect.Bottom-4;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Bottom;
                //    g.DrawLines(pen,p);
                //}
			}
            //g.SmoothingMode = sm;
		}
Exemplo n.º 38
0
        /// <summary>This method will paint the group title.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintGroupText(System.Drawing.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 arcWidth  = this.HeaderRoundCorners;
            int arcHeight = this.HeaderRoundCorners;
            //int intX1 = 0;
            //int intX2 = 0;

            //int ArcX1 = 10;
            //int ArcX2 = (StringSize2.Width + 34) - (ArcWidth + 1);
            int ArcX1 = 20;
            int ArcX2 = (stringSize2.Width + 34) - (arcWidth + 1);
            int ArcY1 = 2;
            int ArcY2 = 22 - (arcHeight + 1);

            //Add by WZW 2008-12-16 增加GroupTitleBox对齐方式 ===Start
            int intMidX           = this.Size.Width / 2;
            int intMidX1          = (ArcX2 - ArcX1) / 2;
            int CustomStringWidth = (this.GroupImage != null) ? 44 : 28;

            _vXTrans = intMidX - intMidX1 - ArcX1;//X坐标平移距离
            int intTitleTextSpace = CustomStringWidth - ArcX1;

            //中间对齐
            if (this._vGroupBoxAlignMode == GroupBoxAlignMode.Center)
            {
                ArcX1             = intMidX - intMidX1;
                ArcX2             = intMidX + intMidX1;
                CustomStringWidth = ArcX1 + intTitleTextSpace;
            }
            else if (this._vGroupBoxAlignMode == GroupBoxAlignMode.Right)
            {
                ArcX1             = intMidX + intMidX - ArcX2;
                ArcX2             = ArcX1 + intMidX1 + intMidX1;
                CustomStringWidth = ArcX1 + intTitleTextSpace;
            }
            //标题与左边线距离
            ArcX1 -= this.TitleLeftSpace;
            ArcX2 -= this.TitleLeftSpace;

            //Add by WZW 2008-12-16 增加GroupTitleBox对齐方式 ===End
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             TextColorBrush  = new SolidBrush(this.ForeColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), arcWidth, arcHeight, 180, GroupBoxConstants.SweepAngle); // Top Left
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), arcWidth, arcHeight, 270, GroupBoxConstants.SweepAngle); //Top 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(new SolidBrush(Color.Transparent), ShadowPath);
                //g.FillPath(ShadowBrush, ShadowPath);
                //-----------------------------------
            }
            //-----------------------------------
            //Edit BY WZW 2008-12-16
            //是否显示标题边框------
            if (this._vShowTileRectangle)
            {
                //创建title边框路径
                path.AddArc(ArcX1, ArcY1, arcWidth, arcHeight, 180, GroupBoxConstants.SweepAngle); // Top Left
                path.AddArc(ArcX2, ArcY1, arcWidth, arcHeight, 270, GroupBoxConstants.SweepAngle); //Top 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();
                //画Title边框
                g.DrawPath(BorderPen, path);
            }

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

            //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);
                    //-----------------------------------
                }
            }
            //-----------------------------------

            //绘制title文字-------------------------
            //int CustomStringWidth = (this.GroupImage != null) ? 44 : 28;
            //if(this.GroupImage!=null)
            //{
            //    CustomStringWidth += 2;
            //}

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

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

            //Draw GroupImage if there is one----
            if (this.GroupImage != null)
            {
                //因增加了标题对齐功能,需修改X坐标值 By  WZW 2008-12-17
                g.DrawImage(this.GroupImage, ArcX1 + 5, 4, 16, 16);
            }

            //释放资源------------
            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();
            }
        }
Exemplo n.º 39
0
		/// <summary>This method will paint the control.</summary>
		/// <param name="g">The paint event graphics object.</param>
		private void PaintBack(System.Drawing.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);
			System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
			System.Drawing.Brush BorderBrush = new SolidBrush(this.BorderColor);
			System.Drawing.Pen BorderPen = new Pen(BorderBrush, this.BorderThickness);
			System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
			System.Drawing.Brush BackgroundBrush = new SolidBrush(this.BackgroundColor);
			System.Drawing.SolidBrush ShadowBrush = null;
			System.Drawing.Drawing2D.GraphicsPath ShadowPath  = null;
			//-----------------------------------

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

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

			//Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, Tools.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();}
			//-----------------------------------
		}
Exemplo n.º 40
0
		/// <summary>This method will paint the group title.</summary>
		/// <param name="g">The paint event graphics object.</param>
		private void PaintGroupText(System.Drawing.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);
			System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
			System.Drawing.Brush BorderBrush = new SolidBrush(this.BorderColor);
			System.Drawing.Pen BorderPen = new Pen(BorderBrush, this.BorderThickness);
			System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
			System.Drawing.Brush BackgroundBrush = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
			System.Drawing.SolidBrush TextColorBrush = new SolidBrush(this.ForeColor);
			System.Drawing.SolidBrush ShadowBrush = null;
			System.Drawing.Drawing2D.GraphicsPath ShadowPath  = null;
			//-----------------------------------

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

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

			//Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, Tools.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();}
			//-----------------------------------
		}
Exemplo n.º 41
0
        protected override void OnResize(System.EventArgs e)
        {
            base.OnResize(e);

            Shape = new GraphicsPath();
            Shape.AddArc(0, 0, 10, 10, 180, 90);
            Shape.AddArc(Width - 11, 0, 10, 10, -90, 90);
            Shape.AddArc(Width - 11, Height - 11, 10, 10, 0, 90);
            Shape.AddArc(0, Height - 11, 10, 10, 90, 90);
            Shape.CloseAllFigures();
        }
Exemplo n.º 42
0
        private void groupBoxFrame_Paint(object sender, PaintEventArgs e)
        {
            if (this.FormBorderStyle != FormBorderStyle.None)
            {
                return;
            }

            using (Graphics g = e.Graphics)
            {
                g.SmoothingMode      = SmoothingMode.HighQuality;
                g.CompositingQuality = CompositingQuality.HighQuality;
                g.InterpolationMode  = InterpolationMode.HighQualityBilinear;
                System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;

                //Declare Variables
                int ArcWidth  = 21;
                int ArcHeight = 21;
                int ArcX1     = 0;
                int ArcX2     = this.Width - 23;
                int ArcY1     = 0;
                int ArcY2     = this.Height - 23;

                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
                System.Drawing.Brush      BorderBrush = new SolidBrush(this.panelPainter.BackColor);
                System.Drawing.Pen        BorderPen = new Pen(BorderBrush, 7);
                System.Drawing.Brush      BackgroundBrush = new SolidBrush(this.panelPainter.BackColor);
                System.Drawing.SolidBrush ShadowBrush = null; System.Drawing.Drawing2D.GraphicsPath ShadowPath = null;

                float SweepAngle = 90f;
                path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, SweepAngle);
                // Top Left
                path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, SweepAngle);
                //Top Right
                path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, SweepAngle);
                //Bottom Right
                path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, SweepAngle);
                //Bottom Left
                path.CloseAllFigures();


                this.Region = new Region(path);

                BackgroundGradientBrush = new LinearGradientBrush(
                    new Rectangle(0, 0, this.Width, this.Height),
                    this.ForeColor, this.BackColor,
                    (LinearGradientMode)LinearGradientMode.Vertical);
                //Paint Rounded Rectangle
                g.FillPath(BackgroundGradientBrush, path);

                g.DrawPath(BorderPen, path);

                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();
                }
            }
        }
Exemplo n.º 43
0
        public void Draw(Graphics g)
        {
            g.SmoothingMode = SmoothingMode.AntiAlias;

            int ArcWidth  = this.C_RoundCorners * 2;
            int ArcHeight = this.C_RoundCorners * 2;
            int ArcX1     = Rect.Left;
            int ArcX2     = (this.ShadowControl) ? (Rect.Left + Rect.Width - (ArcWidth + 1)) - this.ShadowThickness : Rect.Left + Rect.Width - (ArcWidth + 1);
            int ArcY1     = Rect.Top;
            int ArcY2     = (this.ShadowControl) ? (Rect.Top + Rect.Height - (ArcHeight + 1)) - this.ShadowThickness : Rect.Top + Rect.Height - (ArcHeight + 1);

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(Color.Orange);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, 2.0f);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = new SolidBrush(Color.White);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;

            //画出阴影效果
            if (this.ShadowControl)
            {
                Color shadowColor = Color.FromArgb(192, this.ShadowColor);
                //说明:1-(128/255)=1-0.5=0.5 透明度为0.5,即50%
                ShadowBrush = new SolidBrush(shadowColor);
                //ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 180, SweepAngle); //顶端的左角
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 270, SweepAngle); //顶端右角
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 360, SweepAngle); //底部右角
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 90, SweepAngle);  //底部左角
                ShadowPath.CloseAllFigures();

                g.FillPath(ShadowBrush, ShadowPath);
            }

            //画出图形
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, SweepAngle);
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, SweepAngle);
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, SweepAngle);
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, SweepAngle);
            path.CloseAllFigures();

            if (this.C_BackgroundGradientMode == DutBoxGradientMode.None)
            {
                BackgroundBrush = new SolidBrush(this.BackgroundGradientColor);
                g.FillPath(BackgroundBrush, path);
            }
            else
            {
                Color startColor = Color.FromArgb(192, Color.White);
                BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(Rect.Left, Rect.Top, Rect.Width, Rect.Height), startColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);

                g.FillPath(BackgroundGradientBrush, path);
            }
            //画边框
            if (Focus)
            {
                g.DrawPath(BorderPen, path);
            }
            else
            {
                System.Drawing.Brush defaultBrush = new SolidBrush(this.BorderColor);
                System.Drawing.Pen   defaultPen   = new Pen(defaultBrush, this.BorderThickness);
                g.DrawPath(defaultPen, path);

                if (defaultBrush != null)
                {
                    defaultBrush.Dispose();
                }
                if (defaultPen != null)
                {
                    defaultPen.Dispose();
                }
            }
            //画内容 ID
            Font font = new Font("Arial", 14.25F, System.Drawing.FontStyle.Bold);

            g.DrawString((ID + 1).ToString(), font, Brushes.Black, Rect.Left + 6, Rect.Top + 6);
            if (Connected)
            {
                //画状态
                if (!string.IsNullOrEmpty(Status))
                {
                    font = new Font("Arial", 11.25F, FontStyle.Bold);
                    g.DrawString(Status, font, Brushes.Black, Rect.Left + 6 + 56, Rect.Top + 6 + 2);
                }
                //画进度条

                Rectangle bar = new Rectangle(Rect.Left + 6, Rect.Top + 28, Rect.Width - 10, 14);
                ProgressBar.Rect = bar;
                g.SmoothingMode  = SmoothingMode.Default;
                ProgressBar.Draw(g);
                g.SmoothingMode = SmoothingMode.AntiAlias;

                /* Button but = new Button( );
                 * but.Text = "打印";
                 * but.Location = new Point(Rect.Width - 5,14);*/

                //画打印图标 20161223 bonnie
                string haarXmlPath = @"../../打印图标.png";

                FileInfo file     = new FileInfo(haarXmlPath);
                string   fullName = file.FullName;

                //画SN
                if (!string.IsNullOrEmpty(SerialNumber))
                {
                    font = new Font("Arial", 10.25F);
                    g.DrawString("SN:" + SerialNumber, font, Brushes.Black, Rect.Left + 6, Rect.Top + 6 + 40);
                }
                //画IMEI
                if (!string.IsNullOrEmpty(IMEI))
                {
                    font = new Font("Arial", 10.25F);
                    g.DrawString("IMEI:" + IMEI, font, Brushes.Black, Rect.Left + 6, Rect.Top + 6 + 60);
                }
                font = new Font("Arial", 10.25F, FontStyle.Bold);
                //画time
                if (ElapsedTime > 0.0f)
                {
                    g.DrawString((int)ElapsedTime + "/" + (int)EstimateTime, font, Brushes.Black, Rect.Left + 6, Rect.Top + 6 + 80);
                }
                //画测试方式
                switch (Way)
                {
                case TestWay.TW_AUTO:
                    g.DrawString("Auto", font, Brushes.DarkGreen, Rect.Left + 6 + 90, Rect.Top + 6 + 80);
                    break;

                case TestWay.TW_MANUAL:
                    g.DrawString("Manual", font, Brushes.Red, Rect.Left + 6 + 80, Rect.Top + 6 + 80);
                    break;

                case TestWay.TW_NONE:
                    break;
                }
                //画Model
                if (!string.IsNullOrEmpty(Model))
                {
                    font = new Font("Arial", 10.25F);
                    g.DrawString(Model, font, Brushes.Black, Rect.Left + 6, Rect.Top + 6 + 100);
                }
                //画QRCode 48 x 48
                if (QRCode != null)
                {
                    bar = new Rectangle(Rect.Right - 58, Rect.Top + 84, 48, 48);
                    //g.FillRectangle(Brushes.Red, bar);
                    g.SmoothingMode = SmoothingMode.None;
                    g.DrawImageUnscaled(QRCode, bar);
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                }

                if (QRCode != null)
                {
                    FileInfo image_file = new FileInfo($@"./pictures/打印图标.png");
                    if (image_file.Exists)
                    {
                        PrintIocnImage  = Image.FromFile(image_file.FullName);
                        g.SmoothingMode = SmoothingMode.None;
                        g.DrawImage(PrintIocnImage, Rect.Right - 98, Rect.Top + 104);
                        g.SmoothingMode = SmoothingMode.AntiAlias;
                    }
                }
            }
            else // disconnected - TESTING & FAIL
            {
                if (Result == ItemResult.IR_TESTING)
                {
                    StringFormat stringFormat = new StringFormat();
                    stringFormat.LineAlignment = StringAlignment.Center;
                    stringFormat.Alignment     = StringAlignment.Center;
                    stringFormat.FormatFlags   = StringFormatFlags.LineLimit;
                    stringFormat.Trimming      = StringTrimming.EllipsisCharacter;
                    font = new Font("Arial", 16.25F, FontStyle.Bold);

                    g.DrawString("OFFLINE", font, Brushes.White, Rect, stringFormat);
                }
            }
            //画对号
            if (Checked)
            {
                //g.DrawLine(BorderPen, 10, 10, 20, 20);
                int x   = Rect.Left + Rect.Width - 30;
                int y   = Rect.Top + 8;
                Pen pen = new Pen(new SolidBrush(Color.DarkOrange), this.BorderThickness);
                for (int i = 0; i < 6; i++)
                {
                    g.DrawLine(pen, x, y, x, y + 6);
                    x++; y++;
                }
                for (int i = 0; i < 11; i++)
                {
                    g.DrawLine(pen, x, y, x, y + 6);
                    x++; y--;
                }
                if (pen != null)
                {
                    pen.Dispose();
                }
            }
            //销毁Graphic 对象
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderPen.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();
            }
        }
Exemplo n.º 44
0
        /// <summary>This method will paint the control.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintBack(System.Drawing.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);

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle);            // Top Left
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle);            //Top 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);            // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle);            //Top 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();
            }
            //-----------------------------------
        }
Exemplo n.º 45
0
        /// <summary>This method will paint the group title.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintGroupText(System.Drawing.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);

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             TextColorBrush  = new SolidBrush(this.ForeColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle);        // Top Left
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle);        //Top 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);            // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle);            //Top 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();
            }
            //-----------------------------------
        }
Exemplo n.º 46
0
        /// <summary>This method will paint the control.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintBack(System.Drawing.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);

            int intXEnd = 20;

            if (GroupBoxAlignMode.Center == this._vGroupBoxAlignMode)
            {
                intXEnd += _vXTrans;
            }
            else if (GroupBoxAlignMode.Right == this._vGroupBoxAlignMode)
            {
                intXEnd += _vXTrans * 2;
            }
            int intTextLength = g.MeasureString(this.GroupTitle, this.Font).ToSize().Width + 34 - (ArcWidth + 1) - 20;
            int intXStart     = intXEnd + intTextLength + ArcWidth;
            int X1            = intXEnd;
            int X2            = intXStart;

            if (this.GroupImage != null)
            {
                if (this.ShowTileRectangle)
                {
                    X2 += 18;
                }
                else
                {
                    X2 += 10;
                }
            }
            else
            {
                if (!this.ShowTileRectangle)
                {
                    X1 += 8 - this.TextLineSpace;
                    X2 -= 8 - this.TextLineSpace;
                }
            }
            X1 -= this.TitleLeftSpace;
            X2 -= this.TitleLeftSpace;

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle); // Top Left
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle); //Top 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);
                //-----------------------------------
            }
            //-----------------------------------
            //Edit BY WZW 2008-12-16
            //Create Rounded Rectangle Path------
            //path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle); // Top Left
            //path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle); //Top 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();
            //g.DrawPath(BorderPen, path);
            //-----------------------------------
            //g.DrawArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle);

            //绘制标题外边框-----------------------


            //左上角
            g.DrawArc(BorderPen, ArcX1, ArcY1, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle);
            //左上至右上分两段画线,两段之间为标题外框
            BorderPen = new Pen(BorderBrush, this.BorderThickness);
            g.DrawLine(BorderPen, new Point(ArcX1 + this.RoundCorners, ArcY1), new Point(X1, ArcY1)); //左边一段直线
            BorderPen = new Pen(BorderBrush, this.BorderThickness);
            g.DrawLine(BorderPen, new Point(X2, ArcY1), new Point(ArcX2 + this.RoundCorners, ArcY1)); //右边一段直线

            //右上角
            g.DrawArc(BorderPen, ArcX2, ArcY1, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle);

            if (!_vBorderTopOnly)
            {
                //右上至右下
                g.DrawLine(BorderPen, new Point(ArcX2 + ArcWidth, ArcY1 + this.RoundCorners), new Point(ArcX2 + ArcHeight, ArcY2 + this.RoundCorners));
                //右下角

                g.DrawArc(BorderPen, ArcX2, ArcY2, ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle);
                //右下至左下

                g.DrawLine(BorderPen, new Point(ArcX2 + this.RoundCorners, ArcY2 + ArcWidth), new Point(ArcX1 + this.RoundCorners, ArcY2 + ArcWidth));
                //左下角
                g.DrawArc(BorderPen, ArcX1, ArcY2, ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);
                //左下只左上
                g.DrawLine(BorderPen, new Point(ArcX1, ArcY2 + this.RoundCorners), new Point(ArcX1, ArcY1 + this.RoundCorners));
                //g.DrawPath(BorderPen, path);
            }

            //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);
                //-----------------------------------
            }
            //-----------------------------------

            //Delete BY WZW
            //Paint Borded-----------------------
            //g.DrawPath(BorderPen, path);
            //g.DrawLine(SystemPens.Control, 10, 10, 100, 10);
            //-----------------------------------

            //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();
            }
            //-----------------------------------
        }
Exemplo n.º 47
0
        private void DrawBackground(System.Drawing.Graphics g)
        {
            //Graphics g = bg.Graphics;
            g.SmoothingMode = SmoothingMode.AntiAlias;

            int ArcWidth  = this.C_RoundCorners * 2;
            int ArcHeight = this.C_RoundCorners * 2;
            int ArcX1     = 0;
            int ArcX2     = (this.ShadowControl) ? (this.Width - (ArcWidth + 1)) - this.ShadowThickness : this.Width - (ArcWidth + 1);
            int ArcY1     = 0;
            int ArcY2     = (this.ShadowControl) ? (this.Height - (ArcHeight + 1)) - this.ShadowThickness : this.Height - (ArcHeight + 1);

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(_colorFrame);        //this.BorderColor
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, _frameBorder); //this.BorderThickness
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;

            //画出阴影效果
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 180, SweepAngle); //顶端的左角
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 270, SweepAngle); //顶端右角
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 360, SweepAngle); //底部右角
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 90, SweepAngle);  //底部左角
                ShadowPath.CloseAllFigures();

                g.FillPath(ShadowBrush, ShadowPath);
            }

            //画出图形
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, SweepAngle);
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, SweepAngle);
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, SweepAngle);
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, SweepAngle);
            path.CloseAllFigures();

            if (this.C_BackgroundGradientMode == DutBoxGradientMode.None)
            {
                g.FillPath(BackgroundBrush, path);
            }
            else
            {
                BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), this.BackgroundColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);

                g.FillPath(BackgroundGradientBrush, path);
            }
            //画对号
            if (IsActivedDut && ManualChecked)
            {
                //g.DrawLine(BorderPen, 10, 10, 20, 20);
                int x = Width - 30;
                int y = 12;

                /*
                 * x--; y++;
                 * g.DrawLine(pen, x, y, x, y + 4);
                 * x--; y++;
                 * g.DrawLine(pen, x, y, x, y + 2);
                 * x--; y++;
                 * x = Width - 30;
                 * y = 12;
                 * */
                for (int i = 0; i < 6; i++)
                {
                    g.DrawLine(CheckedPen, x, y, x, y + 6);
                    x++; y++;
                }
                for (int i = 0; i < 12; i++)
                {
                    g.DrawLine(CheckedPen, x, y, x, y + 6);
                    x++; y--;
                }

                /*
                 * g.DrawLine(pen, x, y + 2, x, y + 6);
                 * x++; y++;
                 * g.DrawLine(pen, x, y + 2, x, y + 4);
                 * x++; y++;
                 * */
            }
            //画边框
            if (IsActivedDut)
            {
                g.DrawPath(BorderPen, path);
            }
            else
            {
                System.Drawing.Brush defaultBrush = new SolidBrush(this.BorderColor);
                System.Drawing.Pen   defaultPen   = new Pen(defaultBrush, this.BorderThickness);
                g.DrawPath(defaultPen, path);
            }
            //销毁Graphic 对象
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderPen.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();
            }
        }
Exemplo n.º 48
0
 public static GraphicsPath Triangle(this Rectangle rectangle, float angle = 90)
 {
     using (var matrix = new Matrix())
     {
         matrix.RotateAt(angle, new Point(rectangle.X + (rectangle.Width / 2), rectangle.Y + (rectangle.Height / 2)));
         var graphicsPath = new GraphicsPath();
         graphicsPath.AddLine(new Point(rectangle.X, rectangle.Y + (rectangle.Height / 2)), new Point(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height));
         graphicsPath.AddLine(new Point(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height), new Point(rectangle.X + rectangle.Width, rectangle.Y));
         graphicsPath.CloseAllFigures();
         graphicsPath.Transform(matrix);
         return graphicsPath;
     }
 }
Exemplo n.º 49
0
        /// <summary>This method will paint the control.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintBack(System.Drawing.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;

            //Check if string has something-------------
            if (this.GroupTitle == string.Empty)
            {
                ArcY1 = 0;
            }
            //------------------------------------------
            int ArcY2 = (this.ShadowControl) ? (this.Height - (ArcHeight + 1)) - this.ShadowThickness : this.Height - (ArcHeight + 1);

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

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

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

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

            //Check if Gradient Mode is enabled--
            if (this.BackgroundGradientMode == GroupBoxGradientMode.None)
            {
                //Paint Rounded Rectangle------------

                if (this.GroupBoxDrawStyle == GroupBoxDrawType.SingleLine)
                {
                    g.FillPath(BackgroundBrush, path);
                }
                else
                {
                    Brush brush1 = null;
                    Brush brush2 = null;
                    if (this.GroupBoxDrawStyle == GroupBoxDrawType.TwoLine)
                    {
                        brush1 = BackgroundBrush;
                        brush2 = new SolidBrush(BackgroundColor2);
                    }
                    else if (this.GroupBoxDrawStyle == GroupBoxDrawType.TwoLineReversed)
                    {
                        brush1 = new SolidBrush(BackgroundColor2);
                        brush2 = BackgroundBrush;
                    }

                    int          dis         = ArcY2 - ArcY1;
                    int          num         = dis / TwoLineDistance;
                    int          curY        = TwoLineStartOffset;
                    GraphicsPath twoLinePath = new GraphicsPath();

                    for (int i = 0; i < num; ++i)
                    {
                        if (i % 2 == 0)
                        {
                            g.FillRectangle(brush1, ArcX1 + 1, curY, ArcX2 + 2, TwoLineDistance);
                        }
                        else if (i % 2 == 1)
                        {
                            g.FillRectangle(brush2, ArcX1 + 1, curY, ArcX2 + 2, TwoLineDistance);
                        }

                        curY += TwoLineDistance;
                    }
                }

                //-----------------------------------
            }
            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();
            }
            //-----------------------------------
        }
Exemplo n.º 50
0
        private const int MinItemRadialAngle = 18; // Minimum space in angles that can be occupied by single item. 18 gives 20 items on radial menu.
        public override void RecalcSize()
        {
            if (_RecalcSizeInProgress) return; // Prevent re-entrancy
            _RecalcSizeInProgress = true;

            try
            {
                DisposeSubItemsInfo();

                m_Rect = new Rectangle(0, 0, _Diameter, _Diameter);
                //this.WidthInternal = _Diameter;
                //this.HeightInternal = _Diameter;

                Rectangle bounds = new Rectangle(this.LeftInternal, this.TopInternal, _Diameter, _Diameter);
                bounds.Width--;
                bounds.Height--;
                Rectangle radialMenuBounds = bounds;

                Rectangle centerBounds = bounds;
                centerBounds.Inflate(-((_Diameter - _CenterButtonDiameter) / 2 + 1), -((_Diameter - _CenterButtonDiameter) / 2 + 1));

                if (_MenuType == eRadialMenuType.Segment)
                {
                    bounds.Inflate(-_SubMenuEdgeWidth, -_SubMenuEdgeWidth);
                    bounds.Inflate(-_SubMenuEdgeItemSpacing, -_SubMenuEdgeItemSpacing);
                }

                SubItemsCollection displayCollection = GetDisplayCollection();

                int visibleCount = GetVisibleItemsCount(displayCollection);
                if (visibleCount > 0)
                {
                    int maxItemRadialAngle = _MaxItemRadialAngle;
                    if (maxItemRadialAngle == 0) maxItemRadialAngle = 180;
                    int itemPieAngle = Math.Max(MinItemRadialAngle, Math.Min(maxItemRadialAngle, 360 / visibleCount));
                    if (itemPieAngle > _MaxItemPieAngle) itemPieAngle = _MaxItemPieAngle; // Single item can consume at most half of the circle
                    int currentAngle = -90 - itemPieAngle / 2;

                    _SubItemsInfo = new RadialSubItemInfo[displayCollection.Count];
                    for (int i = 0; i < displayCollection.Count; i++)
                    {
                        BaseItem item = displayCollection[i];
                        if (!item.Visible) continue;
                        RadialMenuItem menuItem = item as RadialMenuItem;
                        if (menuItem != null)
                        {
                            menuItem.RecalcSize();
                            GraphicsPath path = new GraphicsPath();
                            path.AddArc(bounds, currentAngle, itemPieAngle);
                            Rectangle cb = centerBounds;
                            cb.Inflate(4, 4);
                            path.AddArc(cb, currentAngle + itemPieAngle, -itemPieAngle);
                            path.CloseAllFigures();
                            menuItem.DisplayPath = path;
                            menuItem.OutterBounds = bounds;
                            menuItem.CenterBounds = centerBounds;
                            menuItem.ItemAngle = currentAngle;
                            menuItem.ItemPieAngle = itemPieAngle;
                            menuItem.Bounds = Rectangle.Round(path.GetBounds());
                        }
                        else
                        {
                            item.RecalcSize();
                            // Position item along the imaginary inner circle
                            Rectangle innerCircle = bounds;
                            innerCircle.Width -= item.WidthInternal;
                            innerCircle.Height -= item.HeightInternal;
                            if (innerCircle.Width < centerBounds.Width) innerCircle.Inflate((centerBounds.Width - innerCircle.Width) / 2, 0);
                            if (innerCircle.Height < centerBounds.Height) innerCircle.Inflate(0, (centerBounds.Height - innerCircle.Height) / 2);
                            Point p = new Point(innerCircle.X + (int)((innerCircle.Width / 2) * Math.Cos((currentAngle + itemPieAngle / 2) * (Math.PI / 180))),
                                innerCircle.Y + (int)((innerCircle.Height / 2) * Math.Sin((currentAngle + itemPieAngle / 2) * (Math.PI / 180))));
                            p.Offset(innerCircle.Width / 2, innerCircle.Height / 2);

                            item.TopInternal = p.Y;
                            item.LeftInternal = p.X;
                        }

                        if (item != null && AnyVisibleSubItems(item))
                        {
                            Rectangle outerBounds = bounds;
                            outerBounds.Inflate(_SubMenuEdgeItemSpacing, _SubMenuEdgeItemSpacing);
                            GraphicsPath subPath = new GraphicsPath();
                            int expandAngle = currentAngle + 1;
                            int expandPieAngle = itemPieAngle - 1;
                            subPath.AddArc(outerBounds, expandAngle, expandPieAngle);
                            subPath.AddArc(radialMenuBounds, expandAngle + expandPieAngle, -expandPieAngle);
                            subPath.CloseAllFigures();
                            Rectangle signPathBounds = radialMenuBounds;
                            signPathBounds.Inflate(-4, -4);
                            Point p = new Point(signPathBounds.X + (int)((signPathBounds.Width / 2) * Math.Cos((currentAngle + itemPieAngle / 2) * (Math.PI / 180))),
                                signPathBounds.Y + (int)((signPathBounds.Height / 2) * Math.Sin((currentAngle + itemPieAngle / 2) * (Math.PI / 180))));
                            p.Offset(signPathBounds.Width / 2, signPathBounds.Height / 2);
                            GraphicsPath signPath = UIGraphics.GetTrianglePath(new Point(-6, -6), 12, eTriangleDirection.Right);
                            Matrix m = new Matrix();
                            if (currentAngle + itemPieAngle / 2 != 0)
                            {
                                m.Rotate(currentAngle + itemPieAngle / 2);
                                m.Translate(p.X, p.Y, MatrixOrder.Append);
                            }
                            else
                                m.Translate(p.X, p.Y);
                            signPath.Transform(m);
                            _SubItemsInfo[i] = new RadialSubItemInfo(subPath, signPath, currentAngle, itemPieAngle);
                        }

                        currentAngle += itemPieAngle;
                        item.Displayed = true;
                    }
                }
            }
            finally
            {
                _RecalcSizeInProgress = false;
            }

            base.RecalcSize();
        }
Exemplo n.º 51
0
        /// <summary>This method will paint the group title.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintGroupText(System.Drawing.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     = 28 + GroupTitleOffset.X - 4;
            int ArcX2     = (StringSize2.Width + 34) - (ArcWidth + 1) + GroupTitleOffset.X;
            int ArcY1     = GroupTitleOffset.Y + 3;
            int ArcY2     = 24 - (ArcHeight + 1) + GroupTitleOffset.Y - 2;

            if (this.GroupTitleType == GroupTitleRenderType.Fill)
            {
                ArcX1 = 0 + GroupTitleOffset.X;                    // 20;
                ArcX2 = this.Width - 3 + GroupTitleOffset.X;       // (StringSize2.Width + 34) - (ArcWidth + 1);
                ArcY1 = GroupTitleOffset.Y;                        // 0
                ArcY2 = 24 - (ArcHeight + 7) + GroupTitleOffset.Y; // + 1
            }
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             TextColorBrush  = new SolidBrush(this.ForeColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

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

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

            //Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, SweepAngle);            // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, SweepAngle);            //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, SweepAngle);            //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, 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-----------------------
            if (this.GroupBoxBorder == GroupBoxBorderType.Full)
            {
                g.DrawPath(BorderPen, path);
            }
            else if (this.GroupBoxBorder == GroupBoxBorderType.HalfTop)
            {
                System.Drawing.Drawing2D.GraphicsPath halfPath2 = new System.Drawing.Drawing2D.GraphicsPath();
                halfPath2.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, SweepAngle);                          // Top Left
                halfPath2.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, SweepAngle);                          //Top Right
                halfPath2.AddArc(ArcX2, ArcY1 + (ArcY2 - ArcY1) * 0.5f, ArcWidth, ArcHeight, 360, SweepAngle); //Bottom Right
                halfPath2.AddArc(ArcX1, ArcY1 + (ArcY2 - ArcY1) * 0.5f, ArcWidth, ArcHeight, 90, SweepAngle);  //Bottom Left
                halfPath2.CloseAllFigures();

                g.DrawPath(BorderPen, halfPath2);
                g.FillRectangle(BackgroundBrush, ArcX1 - 1, ArcY1 + (ArcY2 - ArcY1) * 0.5f + 1, ArcX2, this.BorderThickness + 2);
            }
            //-----------------------------------

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

            if (this.GroupTitleType == GroupTitleRenderType.Fill)
            {
                g.DrawString(this.GroupTitle, this.Font, TextColorBrush, (int)((this.Width * 0.5) - (StringSize2.Width * 0.5)) + GroupTitleOffset.X, 1 + GroupTitleOffset.Y); // 5
            }
            else if (this.GroupTitleType == GroupTitleRenderType.Standard)
            {
                g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth + GroupTitleOffset.X, 5 + GroupTitleOffset.Y - 1);
            }
            //-----------------------------------

            //Draw GroupImage if there is one----
            if (this.GroupImage != null)
            {
                g.DrawImage(this.GroupImage, 30 + GroupTitleOffset.X, 4 + GroupTitleOffset.Y, 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();
            }
            //-----------------------------------
        }