예제 #1
0
        public void UpdateGrid()
        {
            myGridPen = new Pen(Image.GridColour)
            {
                DashStyle = System.Drawing.Drawing2D.DashStyle.Dash
            };

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

            int xDiff = (int)(Image.GridWidth * Image.ZoomScale);
            int yDiff = (int)(Image.GridHeight * Image.ZoomScale);

            if (xDiff > 1)
            {
                for (int x = Image.GridHorizontalOffset; x <= Image.Width; x += Image.GridWidth)
                {
                    myGrid.StartFigure();
                    myGrid.AddLine(x * Image.ZoomScale, 0,
                                   x * Image.ZoomScale, myDisplaySize.Height);
                }
            }

            if (yDiff > 1)
            {
                for (int y = Image.GridVerticalOffset; y <= Image.Height; y += Image.GridHeight)
                {
                    myGrid.StartFigure();
                    myGrid.AddLine(0, y * Image.ZoomScale,
                                   myDisplaySize.Width, y * Image.ZoomScale);
                }
            }

            Invalidate();
        }
예제 #2
0
        private void DoRegion()
        {
            Region r = new Region(Rectangle.FromLTRB(0, 0, this.ClientSize.Width, this.ClientSize.Height));

            //r.Exclude(Rectangle.FromLTRB(10,10,50,50));

            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            //gp.AddRectangle(Rectangle.FromLTRB(15,15,this.ClientSize.Width - 15,this.ClientSize.Height - 15));
            gp.StartFigure();
            gp.AddLine(0, 0, 15, 0);
            gp.AddLine(0, 0, 0, 15);
            gp.AddArc(0, 0, 31, 31, 180, 90);
            gp.CloseFigure();

            gp.StartFigure();
            gp.AddArc(0, this.ClientSize.Height - 30, 31, 31, 90, 90);
            gp.AddLine(0, this.ClientSize.Height, 0, this.ClientSize.Height - 15);
            gp.AddLine(0, this.ClientSize.Height, 15, this.ClientSize.Height);
            gp.CloseFigure();

            gp.StartFigure();
            gp.AddArc(this.ClientSize.Width - 30, this.ClientSize.Height - 30, 30, 30, 0, 90);
            gp.AddLine(this.ClientSize.Width, this.ClientSize.Height, this.ClientSize.Width, this.ClientSize.Height);
            gp.CloseFigure();

            gp.StartFigure();
            gp.AddArc(this.ClientSize.Width - 30, 0, 30, 30, 270, 90);
            gp.AddLine(this.ClientSize.Width, 0, this.ClientSize.Width, 0);
            gp.CloseFigure();

            r.Exclude(gp);

            this.Region = r;
        }
예제 #3
0
        public static Region DoRegion(int width, int height)
        {
            Region r = new Region(Rectangle.FromLTRB(0, 0, width, height));

            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            gp.StartFigure();
            gp.AddLine(0, 0, 15, 0);
            gp.AddLine(0, 0, 0, 15);
            gp.AddArc(0, 0, 31, 31, 180, 90);
            gp.CloseFigure();

            gp.StartFigure();
            gp.AddArc(0, height - 30, 31, 31, 90, 90);
            gp.AddLine(0, height, 0, height - 15);
            gp.AddLine(0, height, 15, height);
            gp.CloseFigure();

            gp.StartFigure();
            gp.AddArc(width - 30, height - 30, 30, 30, 0, 90);
            gp.AddLine(width, height, width, height);
            gp.CloseFigure();

            gp.StartFigure();
            gp.AddArc(width - 30, 0, 30, 30, 270, 90);
            gp.AddLine(width, 0, width, 0);
            gp.CloseFigure();

            r.Exclude(gp);

            return(r);
        }
예제 #4
0
 public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath)
 {
     if (this.Start != this.End)
     {
         graphicsPath.StartFigure();
     }
 }
예제 #5
0
        private void DrawFilledPath(SeriesBase series, System.Drawing.Pen pen,System.Drawing.Brush brush)
        {
            var path = new System.Drawing.Drawing2D.GraphicsPath();

            if (series is AreaSeries)
            {
                path.StartFigure();
                AreaSeries areaSeries = series as AreaSeries;
                var points = areaSeries.AreaPoints;
                var pointCount = areaSeries.AreaPoints.Count;
                for (int i = 0; i < pointCount - 1; i++)
                {
                    System.Drawing.PointF startPoint = points[i].AsDrawingPointF();
                    System.Drawing.PointF endPoint = points[i + 1].AsDrawingPointF();
                    path.AddLine(startPoint, endPoint);
                }

                path.CloseAllFigures();

                switch (RenderingMode)
                {
                    case RenderingMode.GDIRendering:
                        GDIGraphics.FillPath(brush, path);
                        break;
                    case RenderingMode.Default:
                        break;
                    case RenderingMode.WritableBitmap:
                        WritableBitmapGraphics.FillPath(brush, path);
                        break;
                    default:
                        break;
                }
            }
        }
예제 #6
0
        private void roundObject(Form obj)
        {
            System.Drawing.Drawing2D.GraphicsPath DGP = new System.Drawing.Drawing2D.GraphicsPath();
            DGP.StartFigure();
            //'top left corner
            DGP.AddArc(new Rectangle(0, 0, 40, 40), 180, 90);
            DGP.AddLine(40, 0, obj.Width - 40, 0);


            //'top right corner
            DGP.AddArc(new Rectangle(obj.Width - 40, 0, 40, 40), -90, 90);
            DGP.AddLine(obj.Width, 40, obj.Width, obj.Height - 40);


            //'buttom right corner
            DGP.AddArc(new Rectangle(obj.Width - 40, obj.Height - 40, 40, 40), 0, 90);
            DGP.AddLine(obj.Width - 40, obj.Height, 40, obj.Height);


            //'buttom left corner
            DGP.AddArc(new Rectangle(0, obj.Height - 40, 40, 40), 90, 90);
            DGP.CloseFigure();

            obj.Region = new Region(DGP);
        }
예제 #7
0
        public void fillShapes(short[] xy, int pointCnt)
        {
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding);

            System.Drawing.Drawing2D.SmoothingMode oldSmoothMode = mGraphics.SmoothingMode;
            mGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            if (pointCnt > xy.Length / 2)
            {
                pointCnt = xy.Length / 2;
            }

            int i = 0;
            int x0, y0, x, y;

            path.StartFigure();
            x0 = xy[0];
            y0 = xy[1];
            for (i = 1; i < pointCnt; i++)
            {
                x = xy[2 * i];
                y = xy[2 * i + 1];
                path.AddLine(x0, y0, x, y);
                x0 = x;
                y0 = y;
            }
            path.CloseFigure();
            mGraphics.FillPath(mPen.Brush, path);

            mGraphics.SmoothingMode = oldSmoothMode;
        }
예제 #8
0
        public static System.Drawing.Drawing2D.GraphicsPath CreateRoundedRectPath(float x, float y, float width, float height, float radius)
        {
            var xw   = x + width;
            var yh   = y + height;
            var xwr  = xw - radius;
            var yhr  = yh - radius;
            var xr   = x + radius;
            var yr   = y + radius;
            var r2   = radius * 2;
            var xwr2 = xw - r2;
            var yhr2 = yh - r2;

            var p = new System.Drawing.Drawing2D.GraphicsPath();

            p.StartFigure();

            p.AddArc(x, y, r2, r2, 180, 90);

            p.AddLine(xr, y, xwr, y);

            p.AddArc(xwr2, y, r2, r2, 270, 90);

            p.AddLine(xw, yr, xw, yhr);

            p.AddArc(xwr2, yhr2, r2, r2, 0, 90);

            p.AddLine(xwr, yh, xr, yh);

            p.AddArc(x, yhr2, r2, r2, 90, 90);
            p.AddLine(x, yhr, x, yr);

            p.CloseFigure();
            return(p);
        }
예제 #9
0
        private void DrawTextBox(ref Bitmap bmp)
        {
            Graphics g = Graphics.FromImage(bmp);

            int       cRadius   = bmp.Width * 5 / 400;
            int       boxWidth  = bmp.Width;
            int       boxHeight = bmp.Height / 6;
            Rectangle rect      = new Rectangle(cRadius / 2, cRadius / 2, boxWidth - cRadius, boxHeight - cRadius);

            // 指定图形路径, 有一系列 直线/曲线 组成
            System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath();
            myPath.StartFigure();
            myPath.AddArc(new Rectangle(new Point(rect.X, rect.Y), new Size(2 * cRadius, 2 * cRadius)), 180, 90);
            myPath.AddLine(new Point(rect.X + cRadius, rect.Y), new Point(rect.Right - cRadius, rect.Y));
            myPath.AddArc(new Rectangle(new Point(rect.Right - 2 * cRadius, rect.Y), new Size(2 * cRadius, 2 * cRadius)), 270, 90);
            myPath.AddLine(new Point(rect.Right, rect.Y + cRadius), new Point(rect.Right, rect.Bottom - cRadius));
            myPath.AddArc(new Rectangle(new Point(rect.Right - 2 * cRadius, rect.Bottom - 2 * cRadius), new Size(2 * cRadius, 2 * cRadius)), 0, 90);
            myPath.AddLine(new Point(rect.Right - cRadius, rect.Bottom), new Point(rect.X + cRadius, rect.Bottom));
            myPath.AddArc(new Rectangle(new Point(rect.X, rect.Bottom - 2 * cRadius), new Size(2 * cRadius, 2 * cRadius)), 90, 90);
            myPath.AddLine(new Point(rect.X, rect.Bottom - cRadius), new Point(rect.X, rect.Y + cRadius));
            myPath.CloseFigure();

            int opacity = 50;
            int alpha   = (opacity * 255) / 100;

            g.FillPath(new SolidBrush(Color.FromArgb(alpha, Color.AliceBlue)), myPath);

            float fontSize = boxHeight * 25 / 80;
            int   stringX  = bmp.Width * 5 / 400;
            int   stringY  = (int)((boxHeight - fontSize / 72 * 96) / 3);

            g.DrawString(DateTime.Now.ToString("hh:mm:ss"), new Font("Segoe UI", fontSize),
                         new SolidBrush(Color.Green), stringX, stringY);
        }
예제 #10
0
 private void pictureBox_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         mousePath.StartFigure();
     }
 }
예제 #11
0
 /// <summary>
 /// 角の丸い枠線を表すGraphicsPathを取得します
 /// </summary>
 /// <returns></returns>
 private System.Drawing.Drawing2D.GraphicsPath getGraphicsPath()
 {
     if (graphicsPath == null)
     {
         graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
         graphicsPath.StartFigure();
         int w = base.Width - 1;
         int h = base.Height - 1;
         // 上の横線
         graphicsPath.AddLine(RADIUS, 0, w - RADIUS, 0);
         // 右上の角
         graphicsPath.AddArc(w - DIAMETER, 0, DIAMETER, DIAMETER, 270, 90);
         // 右の縦線
         graphicsPath.AddLine(w, RADIUS, w, h - RADIUS);
         // 右下の角
         graphicsPath.AddArc(w - DIAMETER, h - DIAMETER, DIAMETER, DIAMETER, 0, 90);
         // 下の横線
         graphicsPath.AddLine(w - RADIUS, h, RADIUS, h);
         // 左下の角
         graphicsPath.AddArc(0, h - DIAMETER, DIAMETER, DIAMETER, 90, 90);
         // 左の縦線
         graphicsPath.AddLine(0, h - RADIUS, 0, RADIUS);
         // 左上の角
         graphicsPath.AddArc(0, 0, DIAMETER, DIAMETER, 180, 90);
         graphicsPath.CloseFigure();
     }
     return(graphicsPath);
 }
예제 #12
0
            public void set_inner_surfaces(List <surface_store> i_inner_surfaces)
            {
                // add inner surface one after another
                for (int i = 0; i < i_inner_surfaces.Count; i++)
                {
                    if (i_inner_surfaces[i].SignedPolygonArea() > 0) // check whether the inner surface is oriented clockwise (positive area = anti-clockwise)
                    {
                        // anti-clockwise orientation detected so reverse the orientation to be clockwise
                        i_inner_surfaces[i].reverse_surface_orinetation();
                    }
                    inner_surfaces.Add(i_inner_surfaces[i]); // inner surface is clockwise
                }
                //inner_surfaces.AddRange(i_inner_surfaces);

                foreach (surface_store surf in inner_surfaces) // cycle through all the inner surfaces
                {
                    // Set the path of inner surface
                    List <PointF> temp_sur_pts = new List <PointF>();
                    foreach (edge2d ed in surf.surface_edges)
                    {
                        temp_sur_pts.Add(ed.end_pt.get_point());
                    }

                    System.Drawing.Drawing2D.GraphicsPath inner_surface = new System.Drawing.Drawing2D.GraphicsPath();
                    inner_surface.StartFigure();
                    inner_surface.AddPolygon(temp_sur_pts.ToArray());
                    inner_surface.CloseFigure();


                    // set region
                    surface_region.Exclude(inner_surface); // exclude the inner surface region
                }
            }
예제 #13
0
 private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         mousePath.StartFigure();
     }
 }
예제 #14
0
        /// <summary>
        /// takes in a parsed path and returns a list of points that can be used to draw the path
        /// </summary>
        /// <returns>The drawing points.</returns>
        /// <param name="segments">Segments.</param>
        public Vector2[] GetDrawingPoints(List <SvgPathSegment> segments, float flatness = 3)
        {
            var path = new System.Drawing.Drawing2D.GraphicsPath();

            for (var j = 0; j < segments.Count; j++)
            {
                var segment = segments[j];
                if (segment is SvgMoveToSegment)
                {
                    path.StartFigure();
                }
                else if (segment is SvgCubicCurveSegment)
                {
                    var cubicSegment = segment as SvgCubicCurveSegment;
                    path.AddBezier(ToDrawPoint(segment.Start), ToDrawPoint(cubicSegment.FirstCtrlPoint),
                                   ToDrawPoint(cubicSegment.SecondCtrlPoint), ToDrawPoint(segment.End));
                }
                else if (segment is SvgClosePathSegment)
                {
                    // important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
                    if (path.PointCount > 0 && !path.PathPoints[0].Equals(path.PathPoints[path.PathPoints.Length - 1]))
                    {
                        var i = path.PathTypes.Length - 1;
                        while (i >= 0 && path.PathTypes[i] > 0)
                        {
                            i--;
                        }
                        if (i < 0)
                        {
                            i = 0;
                        }
                        path.AddLine(path.PathPoints[path.PathPoints.Length - 1], path.PathPoints[i]);
                    }

                    path.CloseFigure();
                }
                else if (segment is SvgLineSegment)
                {
                    path.AddLine(ToDrawPoint(segment.Start), ToDrawPoint(segment.End));
                }
                else if (segment is SvgQuadraticCurveSegment)
                {
                    var quadSegment = segment as SvgQuadraticCurveSegment;
                    path.AddBezier(ToDrawPoint(segment.Start), ToDrawPoint(quadSegment.FirstCtrlPoint),
                                   ToDrawPoint(quadSegment.SecondCtrlPoint), ToDrawPoint(segment.End));
                }
                else
                {
                    Debug.Warn("unknown type in getDrawingPoints");
                }
            }

            path.Flatten(new System.Drawing.Drawing2D.Matrix(), flatness);

            return(System.Array.ConvertAll(path.PathPoints, i => new Vector2(i.X, i.Y)));
        }
예제 #15
0
 /// <summary>
 /// Method to curve our form border
 /// </summary>
 void curve_border()
 {
     System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath();
     p.StartFigure();
     p.AddArc(new System.Drawing.RectangleF(0, 0, 40, 40), 180, 90);
     p.AddLine(40, 0, this.Width - 40, 0);
     p.AddArc(new RectangleF(this.Width - 40, 0, 40, 40), -90, 90);
     p.AddLine(this.Width, 40, this.Width, this.Height - 40);
     p.AddArc(new RectangleF(this.Width - 40, this.Height - 40, 40, 40), 0, 90);
     p.AddLine(this.Width - 40, this.Height, 40, this.Height);
     p.AddArc(new Rectangle(0, this.Height - 40, 40, 40), 90, 90);
     p.CloseFigure();
     this.Region = new Region(p);
 }
예제 #16
0
		/// <summary>
		/// takes in a parsed path and returns a list of points that can be used to draw the path
		/// </summary>
		/// <returns>The drawing points.</returns>
		/// <param name="segments">Segments.</param>
		public Vector2[] getDrawingPoints( List<SvgPathSegment> segments, float flatness = 3 )
		{
			var path = new System.Drawing.Drawing2D.GraphicsPath();
			for( var j = 0; j < segments.Count; j++ )
			{
				var segment = segments[j];
				if( segment is SvgMoveToSegment )
				{
					path.StartFigure();
				}
				else if( segment is SvgCubicCurveSegment )
				{
					var cubicSegment = segment as SvgCubicCurveSegment;
					path.AddBezier( toDrawPoint( segment.start ), toDrawPoint( cubicSegment.firstCtrlPoint ), toDrawPoint( cubicSegment.secondCtrlPoint ), toDrawPoint( segment.end ) );
				}
				else if( segment is SvgClosePathSegment )
				{
					// important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
					if( path.PointCount > 0 && !path.PathPoints[0].Equals( path.PathPoints[path.PathPoints.Length - 1] ) )
					{
						var i = path.PathTypes.Length - 1;
						while( i >= 0 && path.PathTypes[i] > 0 )
							i--;
						if( i < 0 )
							i = 0;
						path.AddLine( path.PathPoints[path.PathPoints.Length - 1], path.PathPoints[i] );
					}
					path.CloseFigure();
				}
				else if( segment is SvgLineSegment )
				{
					path.AddLine( toDrawPoint( segment.start ), toDrawPoint( segment.end ) );
				}
				else if( segment is SvgQuadraticCurveSegment )
				{
					var quadSegment = segment as SvgQuadraticCurveSegment;
					path.AddBezier( toDrawPoint( segment.start ), toDrawPoint( quadSegment.firstCtrlPoint ), toDrawPoint( quadSegment.secondCtrlPoint ), toDrawPoint( segment.end ) );
				}
				else
				{
					Debug.warn( "unknown type in getDrawingPoints" );
				}
			}

			path.Flatten( new System.Drawing.Drawing2D.Matrix(), flatness );

			return System.Array.ConvertAll( path.PathPoints, i => new Vector2( i.X, i.Y ) );
		}
예제 #17
0
        protected override void OnSizeChanged(EventArgs e)
        {
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.StartFigure();
            path.AddLines(new Point[] { new Point(this.Width, 0), new Point(this.Width - this.Height, this.Height), new Point(this.Width, this.Height) });
            path.CloseFigure();

            Region reReg = new Region(path);

            reReg.Complement(m_Path);

            this.Invalidate(reReg);

            base.OnSizeChanged(e);
            this.m_Path = path;

            //ControlPaint.DrawSizeGrip(this.CreateGraphics(), System.Drawing.Color.FromArgb(0, 30, 88), this.Width - this.Height, 0, this.Height, this.Height);
        }
예제 #18
0
            public surface_store(int i_surf_id, List <point2d> i_surface_nodes, List <edge2d> i_surface_edges, int surf_count)
            {
                this._surface_id = i_surf_id; // add surface id
                surface_nodes.AddRange(i_surface_nodes);
                surface_edges.AddRange(i_surface_edges);

                List <PointF> temp_sur_pts = new List <PointF>();

                //foreach (point2d pt in this.surface_nodes)
                //{
                //    temp_sur_pts.Add(pt.get_point());
                //}

                temp_sur_pts.Add(this.surface_edges[0].start_pt.get_point()); // Add the first point of the surface edge
                foreach (edge2d ed in this.surface_edges)
                {
                    temp_sur_pts.Add(ed.end_pt.get_point()); // since all the surface edges are interconnected only store the end points
                    //surface_path.AddLine(ed.start_pt.get_point(), ed.end_pt.get_point());
                }



                // Set the path of outter surface
                System.Drawing.Drawing2D.GraphicsPath surface_path = new System.Drawing.Drawing2D.GraphicsPath();
                surface_path.StartFigure();
                surface_path.AddPolygon(temp_sur_pts.ToArray());
                surface_path.CloseFigure();

                // set region
                surface_region = new Region(surface_path);


                Color hatch_color = Form1.the_static_class.GetRandomColor(surf_count);

                System.Drawing.Drawing2D.HatchStyle hatch_style = Form1.the_static_class.GetRandomHatchStyle(surf_count);
                Color trans_color = Color.FromArgb(0, 10, 10, 10);

                tri_brush = new System.Drawing.Drawing2D.HatchBrush(hatch_style, hatch_color, trans_color);

                signed_area_chk = this.SignedPolygonArea();
                surface_area    = Math.Abs(signed_area_chk);
            }
예제 #19
0
            public void set_inner_surfaces(surface_store i_inner_surface)
            {
                inner_surfaces.Add(i_inner_surface);

                // Set the path of inner surface
                List <PointF> temp_sur_pts = new List <PointF>();

                foreach (edge2d ed in inner_surfaces[inner_surfaces.Count - 1].surface_edges)
                {
                    temp_sur_pts.Add(ed.end_pt.get_point());
                }

                System.Drawing.Drawing2D.GraphicsPath inner_surface = new System.Drawing.Drawing2D.GraphicsPath();
                inner_surface.StartFigure();
                inner_surface.AddPolygon(temp_sur_pts.ToArray());
                inner_surface.CloseFigure();

                // set region
                surface_region.Exclude(inner_surface); // exclude the inner surface region
            }
예제 #20
0
        public void showHomography(Boolean showing)
        {
            if (showing)
            {
                homoPlane.Reset();
                homoPlane.StartFigure();

                homoPlane.AddLine(scaledPoint(_main.hPlane[0]), scaledPoint(_main.hPlane[1]));
                homoPlane.AddLine(scaledPoint(_main.hPlane[1]), scaledPoint(_main.hPlane[2]));
                homoPlane.AddLine(scaledPoint(_main.hPlane[2]), scaledPoint(_main.hPlane[3]));
                homoPlane.AddLine(scaledPoint(_main.hPlane[3]), scaledPoint(_main.hPlane[0]));

                pictureBox.Invalidate();
            }
            else
            {
                homoPlane.Reset();
                pictureBox.Invalidate();
            }
        }
예제 #21
0
        private void SplashScreen1_Load(object sender, System.EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.None;

            using (System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath())
            {
                int roundedSize = 70;
                p.StartFigure();
                // Top-left
                p.AddArc(new Rectangle(-1, -1, roundedSize, roundedSize), 180, 90);
                // Top
                p.AddLine(roundedSize, -1, this.Width - roundedSize, -1);
                // Top-right
                p.AddArc(new Rectangle(this.Width - roundedSize, -1, roundedSize, roundedSize), -90, 90);
                // Right
                p.AddLine(this.Width, roundedSize, this.Width, this.Height - roundedSize);
                // Bottom-right
                p.AddArc(new Rectangle(this.Width - roundedSize, this.Height - roundedSize, roundedSize, roundedSize), 0, 90);
                // Bottom
                p.AddLine(this.Width - roundedSize, this.Height, roundedSize, this.Height);
                // Bottom-left;
                p.AddArc(new Rectangle(-1, this.Height - roundedSize, roundedSize, roundedSize), 90, 90);
                p.CloseFigure();
                this.Region = new Region(p);
            }

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                Version.Text = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
            }
            else
            {
                Version.Text = "Debug";
            }
            Assembly asm       = Assembly.GetExecutingAssembly();
            string   copyright = ((AssemblyCopyrightAttribute)asm.GetCustomAttribute(typeof(AssemblyCopyrightAttribute))).Copyright;

            Copyright.Text = copyright;
        }
예제 #22
0
        private void DrawFilledPath(SeriesBase series, System.Drawing.Pen pen, System.Drawing.Brush brush)
        {
            var path = new System.Drawing.Drawing2D.GraphicsPath();

            if (series is AreaSeries)
            {
                path.StartFigure();
                AreaSeries areaSeries = series as AreaSeries;
                var        points     = areaSeries.AreaPoints;
                var        pointCount = areaSeries.AreaPoints.Count;
                for (int i = 0; i < pointCount - 1; i++)
                {
                    System.Drawing.PointF startPoint = points[i].AsDrawingPointF();
                    System.Drawing.PointF endPoint   = points[i + 1].AsDrawingPointF();
                    path.AddLine(startPoint, endPoint);
                }

                path.CloseAllFigures();

                switch (RenderingMode)
                {
                case RenderingMode.GDIRendering:
                    GDIGraphics.FillPath(brush, path);
                    break;

                case RenderingMode.Default:
                    break;

                case RenderingMode.WritableBitmap:
                    WritableBitmapGraphics.FillPath(brush, path);
                    break;

                default:
                    break;
                }
            }
        }
예제 #23
0
        public void UpdateGrid()
        {
            myGridPen = new Pen( Image.GridColour )
            {
                DashStyle = System.Drawing.Drawing2D.DashStyle.Dash
            };

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

            int xDiff = (int) ( Image.GridWidth * Image.ZoomScale );
            int yDiff = (int) ( Image.GridHeight * Image.ZoomScale );

            if ( xDiff > 1 )
            {
                for ( int x = Image.GridHorizontalOffset; x <= Image.Width; x += Image.GridWidth )
                {
                    myGrid.StartFigure();
                    myGrid.AddLine( x * Image.ZoomScale, 0,
                        x * Image.ZoomScale, myDisplaySize.Height );
                }
            }

            if ( yDiff > 1 )
            {
                for ( int y = Image.GridVerticalOffset; y <= Image.Height; y += Image.GridHeight )
                {
                    myGrid.StartFigure();
                    myGrid.AddLine( 0, y * Image.ZoomScale,
                        myDisplaySize.Width, y * Image.ZoomScale );
                }
            }

            Invalidate();
        }
예제 #24
0
 public static void MoveTo(this sd.Drawing2D.GraphicsPath path, sd.PointF point) => path.StartFigure();
예제 #25
0
        public System.Drawing.Drawing2D.GraphicsPath CreateRoundRect(int x, int y, int width, int height, int radius, RectangleCorners corners)
        {
            int xw   = x + width;
            int yh   = y + height;
            int xwr  = xw - radius;
            int yhr  = yh - radius;
            int xr   = x + radius;
            int yr   = y + radius;
            int r2   = radius * 2;
            int xwr2 = xw - r2;
            int yhr2 = yh - r2;

            System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath();
            p.StartFigure();

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

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

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

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

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

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

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

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

            p.CloseFigure();
            return(p);
        }
예제 #26
0
        /// <summary>角の丸い矩形のGraphicsPathを生成する</summary>
        public static System.Drawing.Drawing2D.GraphicsPath CreateRoundedGraphicsPath(RectangleF bounds, float xRadius, float yRadius) {
            float left = bounds.X;
            float top = bounds.Y;
            float right = bounds.Right;
            float bottom = bounds.Bottom;

            var path = new System.Drawing.Drawing2D.GraphicsPath();
            path.StartFigure();
            path.AddArc(left, top, xRadius * 2, yRadius * 2, 180, 90);
            path.AddArc(right - xRadius * 2, top, xRadius * 2, yRadius * 2, 270, 90);
            path.AddArc(right - xRadius * 2, bottom - yRadius * 2, xRadius * 2, yRadius * 2, 0, 90);
            path.AddArc(left, bottom - yRadius * 2, xRadius * 2, xRadius * 2, 90, 90);
            path.CloseFigure();

            return path;
        }
예제 #27
0
        private static System.Drawing.Drawing2D.GraphicsPath CreateRinkPath()
        {
            System.Drawing.Drawing2D.GraphicsPath result = null;
            System.Drawing.Drawing2D.GraphicsPath rink   = null;
            try {
                const float cornerDiameter = cornerRadiusOfBoards * 2.0F;

                RectangleF topLeftCorner =
                    new RectangleF(0.0F,
                                   0.0F,
                                   cornerDiameter,
                                   cornerDiameter);
                RectangleF topRightCorner =
                    new RectangleF(rinkLength - cornerDiameter,
                                   0.0F,
                                   cornerDiameter,
                                   cornerDiameter);
                RectangleF bottomLeftCorner =
                    new RectangleF(0.0F,
                                   rinkWidth - cornerDiameter,
                                   cornerDiameter,
                                   cornerDiameter);
                RectangleF bottomRightCorner =
                    new RectangleF(rinkLength - cornerDiameter,
                                   rinkWidth - cornerDiameter,
                                   cornerDiameter,
                                   cornerDiameter);

                rink = new System.Drawing.Drawing2D.GraphicsPath();
                rink.StartFigure();
                rink.AddArc(topLeftCorner, 180.0F, 90.0F);
                rink.AddLine(0.0F + cornerRadiusOfBoards,
                             0.0F,
                             rinkLength - cornerRadiusOfBoards,
                             0.0F);
                rink.AddArc(topRightCorner, 270.0F, 90.0F);
                rink.AddLine(rinkLength,
                             0.0F + cornerRadiusOfBoards,
                             rinkLength,
                             rinkWidth - cornerRadiusOfBoards);
                rink.AddArc(bottomRightCorner, 0.0F, 90.0F);
                rink.AddLine(rinkLength - cornerRadiusOfBoards,
                             rinkWidth,
                             0.0F + cornerRadiusOfBoards,
                             rinkWidth);
                rink.AddArc(bottomLeftCorner, 90.0F, 90.0F);
                rink.AddLine(0.0F,
                             rinkWidth - cornerRadiusOfBoards,
                             0.0F,
                             0.0F + cornerRadiusOfBoards);
                rink.CloseFigure();

                result = rink;
                rink   = null;
                return(result);
            } finally {
                if (null != rink)
                {
                    rink.Dispose();
                }
            }
        }
예제 #28
0
파일: Carte.cs 프로젝트: crocovert/musliw
        private void Carte_Paint(object sender, PaintEventArgs e)
        {
            int i;
            double w, h;
            //projet = ((Musliw.MusliW)(this.MdiParent)).projet;
            Graphics page = e.Graphics;

            //page.Clear(this.BackColor);

            w = this.Width;
            h = this.Height;

            Pen stylo = new Pen(fen.stylo_couleur, (int)fen.epaisseur);
            Font fonte = new Font(FontFamily.GenericSansSerif, 7,FontStyle.Bold);
            this.ForeColor = Color.Black;
            Brush brosse =new SolidBrush(fen.brosse_couleur);
            Brush brosse_texte = new SolidBrush(fen.couleur_texte);
            double dx = w / (projet.reseaux[nproj].xu - projet.reseaux[nproj].xl);
            double dy = h / (projet.reseaux[nproj].yu - projet.reseaux[nproj].yl);
            double deltax,deltay,voldeltax,voldeltay;
            double cx = 0.5f * (projet.reseaux[nproj].xu + projet.reseaux[nproj].xl);
            double cy = 0.5f * (projet.reseaux[nproj].yu + projet.reseaux[nproj].yl);

            //MessageBox.Show(xl.ToString() + " " + yu.ToString());
            PointF p1=new PointF();
            PointF p2 = new PointF();
            PointF p3 = new PointF();
            PointF p4 = new PointF();
            PointF p5 = new PointF();

            PointF[] points = new PointF[4] ;
               double angle=0,norme=0;
            double sinx = 0, cosx = 1;
            if (fen.volume_echelle < 1e-6f)
            {
                fen.volume_echelle = 1e-6f;
            }
            for (i = 0; i < projet.reseaux[nproj].links.Count; i++)
            {
                norme = fen.norme(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur);
                if ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_visible == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_visible == true && norme > 0) && (projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_valid == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_valid == true))
                {

                    //page.DrawRectangle(stylo, 0f, 0f, 200, 200);
                    //MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
                deltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
                deltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
                cosx = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);
                sinx = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);

                    voldeltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    voldeltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    page.DrawLine(stylo, (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay), (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax),(float) (((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay),(float) (((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax));

                    p1.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay);
                    p1.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax);
                    p2.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + voldeltay);
                    p2.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + voldeltax);
                    p3.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + voldeltay);
                    p3.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + voldeltax);
                    p4.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay);
                    p4.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax);

                    System.Drawing.Drawing2D.GraphicsPath epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    System.Drawing.Drawing2D.GraphicsPath texte_epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    epaisseur.StartFigure();
                    points[0] = p1;
                    points[1] = p2;
                    points[2] = p3;
                    points[3] = p4;

                    epaisseur.AddPolygon(points);
                    epaisseur.CloseFigure();
                    //page.FillPath(brosse, epaisseur);
                    //page.FillPolygon(brosse, points);
                    //page.DrawPolygon(stylo,points);
                    epaisseur.Reset();
                    texte_epaisseur.StartFigure();
                    p5.X = 0.5f * (p3.X + p2.X);
                    p5.Y = 0.5f * (p3.Y + p2.Y);
                    texte_epaisseur.AddString(projet.reseaux[projet.reseau_actif].links[i].volau.ToString("0"), FontFamily.GenericSansSerif, 0, (float)fen.taille_texte, new PointF(p5.X, p5.Y), StringFormat.GenericDefault);
                    RectangleF encombrement = texte_epaisseur.GetBounds();
                    // texte_epaisseur.AddRectangle(encombrement);
                    //texte_epaisseur.AddPie(p5.X,p5.Y,2,2,0,360);

                    page.FillPolygon(brosse, points);
                    page.DrawPolygon(stylo, points);

                    if (encombrement.Width < fen.norme(p1.X, p4.X, p1.Y, p4.Y, 1) && projet.reseaux[projet.reseau_actif].links[i].volau > 0)
                    {
                        System.Drawing.Drawing2D.Matrix rotation = new System.Drawing.Drawing2D.Matrix();

                        if (cosx >= 0 && sinx <= 0)
                        {
                            angle = 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(-0.5f * encombrement.Width * cosx),(float)( 0.5f * encombrement.Width * sinx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();
                            page.FillPath(brosse_texte, texte_epaisseur);

                        }
                        else if (cosx <= 0 && sinx >= 0)
                        {
                            angle = 180f - 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(+0.5f * encombrement.Width * cosx + (encombrement.Height) * sinx),(float)( -0.5f * encombrement.Width * sinx + (encombrement.Height) * cosx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);

                        }
                        else if (cosx >= 0 && sinx >= 0)
                        {
                            angle = -180f * (float)Math.Acos(cosx) / (float)Math.PI;
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(-0.5f * encombrement.Width * cosx),(float)( 0.5f * encombrement.Width * sinx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }
                        else if (cosx <= 0 && sinx <= 0)
                        {
                            angle = 180 + 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(+0.5f * encombrement.Width * cosx + (encombrement.Height) * sinx),(float)( -0.5f * encombrement.Width * sinx + (encombrement.Height) * cosx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }

                    }
                    epaisseur.Dispose();
                    texte_epaisseur.Dispose();
                }

            }
            /*        for (i = 0; i < projet.reseaux[nproj].nodes.Count; i++)
            {
                if (projet.reseaux[nproj].nodes[i].i != 0)
                {
                    //page.DrawRectangle(stylo, 0f, 0f, 200, 200);
                    //MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
                    page.FillRectangle(brosse, (res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f);
                    page.DrawRectangle(stylo, (res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f);
                    page.DrawString(res.nodes[i].i.ToString(), fonte, Brushes.Black, new RectangleF((res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f));
                }
            }*/
        }
        public void DrawGlyph(int xDrawPos, int yDrawPos)
        {
            TrueTypeFont.Glyph glyph = TrueFont.ReadGlyph(GlyphIndex);

            if (glyph == null || glyph.Type != "simple")
            {
                return;
            }
            if (picCanvas.Image == null)
            {
                picCanvas.Image = CreateCanvasBitmap(picCanvas.Width, picCanvas.Height);
            }
            Graphics g = Graphics.FromImage(picCanvas?.Image);

            g.Clear(Color.Teal);
            g.DrawLine(new Pen(Color.Red), picCanvas.Width / 2, 0, picCanvas.Width / 2, picCanvas.Height);
            g.DrawLine(new Pen(Color.Red), 0, picCanvas.Height / 2, picCanvas.Width, picCanvas.Height / 2);
            g.DrawRectangle(new Pen(Color.Magenta), xDrawPos - 5, yDrawPos - 5, 10, 10);
            System.Drawing.Drawing2D.GraphicsPath fullPath = new System.Drawing.Drawing2D.GraphicsPath();

            int   p = 0, c = 0, first = 1;
            float firstX = 0, firstY = 0;
            float xOffset = 0, yOffset = 0;
            bool  offsetsSet = false;

            while (p < glyph.Points.Length)
            {
                if (first == 1)
                {
                    first  = 0;
                    firstX = (glyph.Points[p].X * FontScale + FontScale * (-TrueFont.xMin));
                    firstY = (glyph.Points[p].Y * -FontScale + FontScale * TrueFont.yMax);
                    if (offsetsSet == false)
                    {
                        offsetsSet = true;
                        xOffset    = xDrawPos - (FontScale * ((glyph.xMax - glyph.xMin) + (glyph.xMax - glyph.xMin) / 2));                     // + FontScale*(-TrueFont.xMin))/2;
                        yOffset    = yDrawPos - (-FontScale * ((glyph.yMin - glyph.yMax) - (glyph.yMin - glyph.yMax) / 4));
                    }
                    firstX += xOffset;
                    firstY += yOffset;
                    fullPath.StartFigure();
                }
                else
                {
                    float X = (glyph.Points[p].X * FontScale + FontScale * (-TrueFont.xMin)) + xOffset;
                    float Y = (glyph.Points[p].Y * -FontScale + FontScale * TrueFont.yMax) + yOffset;
                    //g.DrawLine(new Pen(Color.White, 1), firstX - 200, firstY, X - 200, Y); //used for manually drawing glyphs, but does not fill them

                    fullPath.AddLine(firstX, firstY, X, Y);

                    firstX = X;
                    firstY = Y;
                }

                if (p == glyph.ContourEnds[c])
                {
                    c++;
                    first = 1;
                    fullPath.CloseFigure();
                }
                p++;
            }

            //g.DrawPath(new Pen(Color.Black, 1), fullPath);
            g.FillPath(new SolidBrush(Color.Black), fullPath);
            picCanvas.Invalidate();
        }
예제 #30
0
 public override void StartFigure()
 {
     p.StartFigure();
 }
예제 #31
0
 public void StartFigure()
 {
     _path.StartFigure();
 }
예제 #32
0
        private static void DrawFaceOffArea(Graphics g, PointF position, Brush spotBrush, Pen linePen)
        {
            DrawFaceOffSpot(g, position, spotBrush, faceOffSpotDiameter, false);

            // Draw the hash marks around the spot
            PointF pos = position;
            float  halfOfThinLineWidth       = thinLinePenWidth / 2.0F;
            float  xDistanceFromCentreOnArea = innerHashDistanceFromCentreX + halfOfThinLineWidth;
            float  yDistanceFromCentreOnArea = innerHashDistanceFromCentreY + halfOfThinLineWidth;
            float  xLength = innerHashLengthX - halfOfThinLineWidth;
            float  yLength = innerHashLengthY - halfOfThinLineWidth;

            g.DrawLines(linePen,
                        new PointF[] {
                new PointF(pos.X + xDistanceFromCentreOnArea,
                           pos.Y + yDistanceFromCentreOnArea + yLength),
                new PointF(pos.X + xDistanceFromCentreOnArea,
                           pos.Y + yDistanceFromCentreOnArea),
                new PointF(pos.X + xDistanceFromCentreOnArea + xLength,
                           pos.Y + yDistanceFromCentreOnArea),
            });
            g.DrawLines(linePen,
                        new PointF[] {
                new PointF(pos.X - xDistanceFromCentreOnArea,
                           pos.Y + yDistanceFromCentreOnArea + yLength),
                new PointF(pos.X - xDistanceFromCentreOnArea,
                           pos.Y + yDistanceFromCentreOnArea),
                new PointF(pos.X - xDistanceFromCentreOnArea - xLength,
                           pos.Y + yDistanceFromCentreOnArea),
            });
            g.DrawLines(linePen,
                        new PointF[] {
                new PointF(pos.X + xDistanceFromCentreOnArea,
                           pos.Y - yDistanceFromCentreOnArea - yLength),
                new PointF(pos.X + xDistanceFromCentreOnArea,
                           pos.Y - yDistanceFromCentreOnArea),
                new PointF(pos.X + xDistanceFromCentreOnArea + xLength,
                           pos.Y - yDistanceFromCentreOnArea),
            });
            g.DrawLines(linePen,
                        new PointF[] {
                new PointF(pos.X - xDistanceFromCentreOnArea,
                           pos.Y - yDistanceFromCentreOnArea - yLength),
                new PointF(pos.X - xDistanceFromCentreOnArea,
                           pos.Y - yDistanceFromCentreOnArea),
                new PointF(pos.X - xDistanceFromCentreOnArea - xLength,
                           pos.Y - yDistanceFromCentreOnArea),
            });

            // Create a path for the circle
            RectangleF circleRectangle =
                new RectangleF(0.0F + position.X - faceOffCircleRadius,
                               0.0F + position.Y - faceOffCircleRadius,
                               faceOffCircleRadius * 2.0F,
                               faceOffCircleRadius * 2.0F);

            using (var circlePath = new System.Drawing.Drawing2D.GraphicsPath()) {
                circlePath.StartFigure();
                circlePath.AddEllipse(circleRectangle);
                circlePath.CloseFigure();

                // Clip the area of the circle so that we can draw the hash-marks nicely
                Region oldClip = g.Clip;
                using (Region clipRegion = new Region(circlePath)) {
                    g.ExcludeClip(clipRegion);

                    // Draw the hash-marks outside the circle
                    float lengthFromCentre = faceOffCircleRadius + outerHashLengthY;
                    g.DrawLine(linePen,
                               pos.X - xDistanceFromCentreOnArea,
                               pos.Y - lengthFromCentre,
                               pos.X - xDistanceFromCentreOnArea,
                               pos.Y + lengthFromCentre);
                    g.DrawLine(linePen,
                               pos.X + xDistanceFromCentreOnArea,
                               pos.Y - lengthFromCentre,
                               pos.X + xDistanceFromCentreOnArea,
                               pos.Y + lengthFromCentre);

                    // Restore the clipping region
                    g.Clip = oldClip;
                }
            }

            // Draw the circle
            g.DrawEllipse(linePen, circleRectangle);
        }
예제 #33
0
        private void pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_main.isVideoPlaying)
            {
                if (e.Button == MouseButtons.Right)
                {
                    enableHomography = !enableHomography;
                    showHomography(enableHomography);
                }

                if (e.Button == MouseButtons.Left)
                {
                    if (startDrawing)
                    {
                        startDrawing      = false;
                        pictureBox.Cursor = Cursors.Default;

                        endedPoint = new Point((int)mousePath.PathPoints[1].X, (int)mousePath.PathPoints[1].Y);

                        lblDistance.Visible  = true;
                        lblDistance.Location = new Point(endedPoint.X + 5, endedPoint.Y - lblDistance.Height / 2);

                        startPoint = rescalePoint(startPoint);
                        endedPoint = rescalePoint(endedPoint);

                        if (measureWidth)
                        {
                            road_width = roadWidth(startPoint, endedPoint);

                            lblDistance.Text = road_width.ToString("#0.00") + "m";

                            btnSave.Visible  = true;
                            btnSave.Height   = lblDistance.Height;
                            btnSave.Width    = lblDistance.Height;
                            btnSave.Location = new Point(lblDistance.Location.X + lblDistance.Width, lblDistance.Location.Y);
                        }
                        else
                        {
                            object_height    = objectHeight(startPoint, endedPoint);
                            lblDistance.Text = object_height.ToString("#0.00") + "m";

                            Debug.WriteLine(objectHeight(new Point(711, 609), new Point(721, 363)));
                        }
                    }
                    else
                    {
                        if (_main.enableHomography)
                        {
                            lblDistance.Visible = true;
                            startPoint          = new Point(e.X, e.Y);
                            mousePath.StartFigure();

                            pictureBox.Cursor   = Cursors.Cross;
                            lblDistance.Visible = false;
                            btnSave.Visible     = false;
                            startDrawing        = true;
                        }
                        else
                        {
                            lblDistance.Text     = "Could not open or load calibration files.";
                            lblDistance.Visible  = true;
                            lblDistance.Location = e.Location;

                            btnSave.Visible  = true;
                            btnSave.Location = new Point(lblDistance.Location.X + lblDistance.Width, lblDistance.Location.Y);
                        }
                    }
                }

                if (e.Button == MouseButtons.Middle)
                {
                    if (!isZoomOn)
                    {
                        _main.activatePbZoom(e.X, e.Y, pictureBox.Image);
                        isZoomOn = !isZoomOn;
                    }
                    else
                    {
                        _main.deactivatePbZoom();
                        isZoomOn = !isZoomOn;
                    }
                }
            }
        }
예제 #34
0
        private void SpecifyGroupVisualy(SKarnaughGroup group, Graphics g)
        {
            Point[] points1;
            Point[] points2;
            Point[] points3;
            Point[] points4;

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

            Rectangle[] drawRegions      = GetGroupRegions(group);
            int         drawRegionsCount = drawRegions.GetLength(0);
            int         Spc_HOR          = 20;
            int         Spc_VER          = 15;
            int         Dest_To_Reg      = m_innerTableRegion.Left / 2;

            if (drawRegionsCount == 1)
            {
                points1 = new Point[2];
                int middle_X = (drawRegions[0].Left + drawRegions[0].Right) / 2;
                Spc_HOR = 10;
                Spc_VER = 10;

                #region Set rectangular shape points (for around a cell)

                points1[0].X = drawRegions[0].Left + Spc_HOR;
                points1[0].Y = drawRegions[0].Top + Spc_VER;

                points1[1].X = drawRegions[0].Right - Spc_HOR;
                points1[1].Y = drawRegions[0].Bottom - Spc_VER;
                #endregion

                path.AddEllipse(points1[0].X, points1[0].Y, points1[1].X - points1[0].X, points1[1].Y - points1[0].Y);
                path.StartFigure();
            }
            else if (drawRegionsCount == 2)
            {
                points1 = new Point[4];
                points2 = new Point[4];

                #region Set curve points (for around two groups)

                if (drawRegions[0].Left == drawRegions[1].Left)
                {
                    // We have two HORIZONTAL group
                    #region Set top group points

                    points1[0].X = drawRegions[0].Left + Spc_HOR;
                    points1[0].Y = m_innerTableRegion.Top - Dest_To_Reg;

                    points1[1].X = (int)(drawRegions[0].Left + Spc_HOR);
                    points1[1].Y = (int)(drawRegions[0].Bottom - Spc_VER);

                    points1[2].X = (int)(drawRegions[0].Right - Spc_HOR);
                    points1[2].Y = points1[1].Y;

                    points1[3].X = points1[2].X;
                    points1[3].Y = points1[0].Y;
                    #endregion

                    #region Set bottom group points
                    points2[0].X = points1[0].X;
                    points2[0].Y = drawRegions[1].Bottom + Dest_To_Reg;

                    points2[1].X = points1[1].X;
                    points2[1].Y = (int)(drawRegions[1].Top + Spc_VER);

                    points2[2].X = points1[2].X;
                    points2[2].Y = points2[1].Y;

                    points2[3].X = points1[3].X;
                    points2[3].Y = points2[0].Y;
                    #endregion
                }
                else
                {
                    // We have two VERTICAL group

                    #region Set left group points

                    points1[0].X = m_innerTableRegion.Left - Dest_To_Reg;
                    points1[0].Y = drawRegions[0].Top + Spc_VER;

                    points1[1].X = (int)(drawRegions[0].Right - Spc_HOR);
                    points1[1].Y = (int)(drawRegions[0].Top + Spc_VER);

                    points1[2].X = points1[1].X;
                    points1[2].Y = (int)(drawRegions[0].Bottom - Spc_VER);

                    points1[3].X = points1[0].X;
                    points1[3].Y = drawRegions[0].Bottom - Spc_VER;
                    #endregion


                    #region Set right group points

                    points2[0].X = m_innerTableRegion.Right + Dest_To_Reg;
                    points2[0].Y = points1[0].Y;

                    points2[1].X = (int)(drawRegions[1].Left + Spc_HOR);
                    points2[1].Y = points1[1].Y;

                    points2[2].X = points2[1].X;
                    points2[2].Y = points1[2].Y;

                    points2[3].X = points2[0].X;
                    points2[3].Y = points1[2].Y;
                    #endregion
                }
                #endregion

                path.AddCurve(points1, 0.2f);
                path.StartFigure();
                path.AddCurve(points2, 0.2f);
            }
            else
            {
                points1 = new Point[3];
                points2 = new Point[3];
                points3 = new Point[3];
                points4 = new Point[3];

                #region Set curve points (for around four groups)

                // Group 1
                points1[0].X = m_innerTableRegion.Left - Dest_To_Reg;
                points1[0].Y = drawRegions[0].Bottom - Spc_VER;

                points1[1].X = drawRegions[0].Right - Spc_HOR;  //drawRegions[0].Right- Spc_HOR ;
                points1[1].Y = drawRegions[0].Bottom - Spc_VER; //points1[0].Y;

                points1[2].X = drawRegions[0].Right - Spc_HOR;
                points1[2].Y = m_innerTableRegion.Top - Dest_To_Reg;

                // Group 2
                points2[0].X = drawRegions[1].Right + Dest_To_Reg;
                points2[0].Y = points1[0].Y;

                points2[1].X = drawRegions[1].Left + Spc_HOR;
                points2[1].Y = points1[1].Y;

                points2[2].X = drawRegions[1].Left + Spc_HOR;
                points2[2].Y = points1[2].Y;

                // Group 3
                points3[0].X = points1[0].X;
                points3[0].Y = drawRegions[2].Top + Spc_VER;

                points3[1].X = points1[1].X;
                points3[1].Y = drawRegions[2].Top + Spc_VER;

                points3[2].X = points1[2].X;
                points3[2].Y = drawRegions[2].Bottom + Dest_To_Reg;

                // Group 4
                points4[0].X = points2[0].X;
                points4[0].Y = points3[0].Y;

                points4[1].X = points2[1].X;
                points4[1].Y = points3[1].Y;

                points4[2].X = points2[2].X;
                points4[2].Y = points3[2].Y;
                #endregion

                path.AddCurve(points1);
                path.StartFigure();
                path.AddCurve(points2);
                path.StartFigure();
                path.AddCurve(points3);
                path.StartFigure();
                path.AddCurve(points4);
            }

            // Draw with high quality
            g.DrawPath(m_groupSpecifyerPen, path);
            //
        }
예제 #35
0
        public static void Draw(
            DelaunatorSharp.Delaunator delaunay
            , DelaunatorSharp.IPoint[] points
            , BoundingBox bbox
            , Circumcircles circumcircles
            , System.Drawing.Graphics ctx
            , float padding
            , float scale
            , FlatQueue <float> queue
            , bool[] onEdge
            )
        {
            // ctx.clearRect(0, 0, width, height);
            ctx.Clear(System.Drawing.Color.White);


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

            int[] t = delaunay.Triangles;
            for (int i = 0; i < t.Length; i += 3)
            {
                DelaunatorSharp.IPoint pt1 = points[t[i + 0]];
                float ax = (float)pt1.X;
                float ay = (float)pt1.Y;


                DelaunatorSharp.IPoint pt2 = points[t[i + 1]];
                float bx = (float)pt2.X;
                float by = (float)pt2.Y;


                DelaunatorSharp.IPoint pt3 = points[t[i + 2]];
                float cx = (float)pt3.X;
                float cy = (float)pt3.Y;

                path1.StartFigure();
                path1.AddLine(projX(ax, padding, scale, bbox), projY(ay, padding, scale, bbox), projX(bx, padding, scale, bbox), projY(by, padding, scale, bbox));
                path1.AddLine(projX(bx, padding, scale, bbox), projY(by, padding, scale, bbox), projX(cx, padding, scale, bbox), projY(cy, padding, scale, bbox));
                path1.CloseFigure();
            }

            System.Drawing.Pen trianglePen = new System.Drawing.Pen(System.Drawing.Color.FromArgb((int)(0.4 * 255), 0, 200, 0));
            trianglePen.Width     = 0.5f;
            trianglePen.Alignment = System.Drawing.Drawing2D.PenAlignment.Center;
            ctx.DrawPath(trianglePen, path1);

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


            // for (const [x, y] of points)
            foreach (DelaunatorSharp.IPoint thisPoint in points)
            {
                float sx = projX((float)thisPoint.X, padding, scale, bbox);
                float sy = projY((float)thisPoint.Y, padding, scale, bbox);
                float r  = 1.5f;
                r = 5;

                path2.StartFigure();
                path2.AddArc(sx - r / 2.0f, sy - r / 2.0f, r, r, 0.0f, 360.0f);
                path2.CloseFigure();
            }

            System.Drawing.Brush blackBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            ctx.FillPath(blackBrush, path2);



            // ctx.beginPath();
            System.Drawing.Drawing2D.GraphicsPath path3 = new System.Drawing.Drawing2D.GraphicsPath();
            // path3.StartFigure();
            for (int i = 0; i < onEdge.Length; i++)
            {
                if (!onEdge[i])
                {
                    continue;
                }

                DelaunatorSharp.IPoint pt1 = points[t[i]];
                float ax = (float)pt1.X;
                float ay = (float)pt1.Y;

                DelaunatorSharp.IPoint pt2 = points[t[i % 3 == 2 ? i - 2 : i + 1]];
                float bx = (float)pt2.X;
                float by = (float)pt2.Y;

                path3.StartFigure();
                path3.AddLine(projX(ax, padding, scale, bbox), projY(ay, padding, scale, bbox), projX(bx, padding, scale, bbox), projY(by, padding, scale, bbox));
                path3.CloseFigure();
                // ctx.moveTo(projX(ax), projY(ay));
                // ctx.lineTo(projX(bx), projY(by));
                // ctx.closePath();
            }
            // path3.CloseFigure();
            System.Drawing.Pen hullPen = new System.Drawing.Pen(System.Drawing.Color.Blue);
            hullPen.Width = 2.0f;
            ctx.DrawPath(hullPen, path3);



            System.Drawing.Drawing2D.GraphicsPath path4 = new System.Drawing.Drawing2D.GraphicsPath();
            foreach (int i in queue.ids)
            {
                // ctx.beginPath();
                path4.StartFigure();
                float sr = circumcircles.r[i] * scale;
                float sx = projX(circumcircles.x[i], padding, scale, bbox);
                float sy = projY(circumcircles.y[i], padding, scale, bbox);
                //ctx.moveTo(sx + sr, sy);
                //ctx.arc(sx, sy, sr, 0, Math.PI* 2, false);
                //ctx.strokeStyle = 'rgba(200,0,0,1)';
                //ctx.lineWidth = 1;
                //ctx.stroke();
                //ctx.fillStyle = 'rgba(255,255,0,0.2)';
                //ctx.fill();

                path4.AddArc(sx - sr / 2.0f, sy - sr / 2.0f, sr, sr, 0.0f, 360.0f);
                path4.CloseFigure();
            }

            System.Drawing.SolidBrush circleBrush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb((int)(0.2 * 255), 255, 255, 0));
            System.Drawing.Pen        redCircle   = new System.Drawing.Pen(System.Drawing.Color.FromArgb(255, 200, 0, 0));
            redCircle.Width     = 1;
            redCircle.Alignment = System.Drawing.Drawing2D.PenAlignment.Center;
            ctx.FillPath(circleBrush, path4);
            ctx.DrawPath(redCircle, path4);
        }