GetLastPoint() public method

public GetLastPoint ( ) : PointF
return PointF
Exemplo n.º 1
0
        public override GraphicsPath Path(SvgRenderer renderer)
        {
            if (_Path == null || this.IsPathDirty)
            {
                _Path = new GraphicsPath();

                try
                {
                    for (int i = 0; i < Points.Count; i += 2)
                    {
                        PointF endPoint = new PointF(Points[i].ToDeviceValue(renderer, UnitRenderingType.Horizontal, this), 
                                                     Points[i + 1].ToDeviceValue(renderer, UnitRenderingType.Vertical, this));

                        // TODO: Remove unrequired first line
                        if (_Path.PointCount == 0)
                        {
                            _Path.AddLine(endPoint, endPoint);
                        }
                        else
                        {
                            _Path.AddLine(_Path.GetLastPoint(), endPoint);
                        }
                    }
                }
                catch (Exception exc)
                {
                    Trace.TraceError("Error rendering points: " + exc.Message);
                }
                this.IsPathDirty = false;
            }
            return _Path;
        }
Exemplo n.º 2
0
        public override GraphicsPath Path(ISvgRenderer renderer)
        {
            if ((_Path == null || this.IsPathDirty) && base.StrokeWidth > 0)
            {
                _Path = new GraphicsPath();

                try
                {
                    for (int i = 0; (i + 1) < Points.Count; i += 2)
                    {
                        PointF endPoint = new PointF(Points[i].ToDeviceValue(renderer, UnitRenderingType.Horizontal, this),
                                                     Points[i + 1].ToDeviceValue(renderer, UnitRenderingType.Vertical, this));

                        if (renderer == null)
                        {
                          var radius = base.StrokeWidth / 2;
                          _Path.AddEllipse(endPoint.X - radius, endPoint.Y - radius, 2 * radius, 2 * radius);
                          continue;
                        }

                        // TODO: Remove unrequired first line
                        if (_Path.PointCount == 0)
                        {
                            _Path.AddLine(endPoint, endPoint);
                        }
                        else
                        {
                            _Path.AddLine(_Path.GetLastPoint(), endPoint);
                        }
                    }
                }
                catch (Exception exc)
                {
                    Trace.TraceError("Error rendering points: " + exc.Message);
                }
                if (renderer != null)
                  this.IsPathDirty = false;
            }
            return _Path;
        }
Exemplo n.º 3
0
        private const double ROUNDED_RECT_RAD_PERCENT = .05d; //5 percent

        #endregion Fields

        #region Methods

        public static GraphicsPath Get3DShinePath(Rectangle container, ControlShape shape)
        {
            GraphicsPath path = new GraphicsPath();

            Rectangle pathRect = container;
            pathRect.Width -= 1;
            pathRect.Height -= 1;

            RectangleF halfRect = new RectangleF(pathRect.X, pathRect.Y,
                                                    pathRect.Width, pathRect.Height / 2f);

            if (pathRect.Height > 0 && pathRect.Width > 0)
            {
                switch (shape)
                {
                    case ControlShape.Rect:
                        path.AddRectangle(halfRect);
                        break;
                    case ControlShape.RoundedRect:
                        //radius is 10% of smallest side
                        int rad = (int)(Math.Min(halfRect.Height, halfRect.Width) * ROUNDED_RECT_RAD_PERCENT);
                        path.AddRoundedRectangle(halfRect, rad);
                        break;
                    case ControlShape.Circular:
                        path.AddArc(pathRect, 180, 142);
                        PointF[] pts = new PointF[]
                    {
                        path.GetLastPoint(),
                        new PointF(container.Width * .70f, container.Height * .33f),
                        new PointF(container.Width * .25f, container.Height * .5f),
                        path.PathPoints[0]
                    };
                        path.AddCurve(pts);
                        path.CloseFigure();
                        break;
                }
            }

            return path;
        }
Exemplo n.º 4
0
        public GraphicsPath SyntaxToPath(string PathSyntax)
        {
            List<string> t = Tokenize(PathSyntax);
            if (t.Count < 2) return new GraphicsPath();

            GraphicsPath p = new GraphicsPath();
            int i = 0;
            if (t[0] == "F1") {
                p.FillMode = FillMode.Winding;
                i++;
            } else if (t[0] == "F0") {
                p.FillMode = FillMode.Alternate;
                i++;
            }

            PointF last_point = new PointF(0, 0);

            for (; i < t.Count; i++) {
                switch (t[i]) { // doesn't handle a lot of short-cuts yet. Doesn't support Hh or Vv
                    case "M":
                        p.StartFigure();
                        last_point = GetPointStr(t[i + 1], t[i + 2]);
                        i += 2;
                        break;
                    case "m":
                        p.StartFigure();
                        last_point = GetPointStrOff(t[i + 1], t[i + 2], last_point);
                        i += 2;
                        break;

                    case "L":
                        p.AddLine(last_point, GetPointStr(t[i + 1], t[i + 2]));
                        last_point = p.GetLastPoint();
                        i += 2;
                        break;

                    case "l":
                        p.AddLine(last_point, GetPointStrOff(t[i + 1], t[i + 2], last_point));
                        last_point = p.GetLastPoint();
                        i += 2;
                        break;

                    case "C":
                        p.AddBezier(last_point, GetPointStr(t[i + 1], t[i + 2]), GetPointStr(t[i + 3], t[i + 4]), GetPointStr(t[i + 5], t[i + 6]));
                        last_point = p.GetLastPoint();
                        i += 6;
                        break;

                    case "Z":
                    case "z":
                        p.CloseFigure();
                        break;

                    default:
                        throw new Exception("Unsupported symbol: " + t[i]);
                }
            }
            p.CloseAllFigures();

            return p;
        }
Exemplo n.º 5
0
      void bg_DoWork(object sender, DoWorkEventArgs e)
      {
         MapInfo info = (MapInfo)e.Argument;
         if(!info.Area.IsEmpty)
         {
            //var types = GMaps.Instance.GetAllLayersOfType(info.Type);

            string bigImage = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + Path.DirectorySeparatorChar + "GMap at zoom " + info.Zoom + " - " + info.Type + "-" + DateTime.Now.Ticks + ".png";
            e.Result = bigImage;

            // current area
            GPoint topLeftPx = info.Type.Projection.FromLatLngToPixel(info.Area.LocationTopLeft, info.Zoom);
            GPoint rightButtomPx = info.Type.Projection.FromLatLngToPixel(info.Area.Bottom, info.Area.Right, info.Zoom);
            GPoint pxDelta = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);
            GMap.NET.GSize maxOfTiles = info.Type.Projection.GetTileMatrixMaxXY(info.Zoom);

            int padding = info.MakeWorldFile ? 0 : 22;
            {
               using(Bitmap bmpDestination = new Bitmap((int)(pxDelta.X + padding * 2), (int)(pxDelta.Y + padding * 2)))
               {
                  using(Graphics gfx = Graphics.FromImage(bmpDestination))
                  {
                     gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
                     gfx.SmoothingMode = SmoothingMode.HighQuality;

                     int i = 0;

                     // get tiles & combine into one
                     lock(tileArea)
                     {
                        foreach(var p in tileArea)
                        {
                           if(bg.CancellationPending)
                           {
                              e.Cancel = true;
                              return;
                           }

                           int pc = (int)(((double)++i / tileArea.Count) * 100);
                           bg.ReportProgress(pc, p);

                           foreach(var tp in info.Type.Overlays)
                           {
                              Exception ex;
                              GMapImage tile;

                              // tile number inversion(BottomLeft -> TopLeft) for pergo maps
                              if(tp.InvertedAxisY)
                              {
                                 tile = GMaps.Instance.GetImageFrom(tp, new GPoint(p.X, maxOfTiles.Height - p.Y), info.Zoom, out ex) as GMapImage;
                              }
                              else // ok
                              {
                                 tile = GMaps.Instance.GetImageFrom(tp, p, info.Zoom, out ex) as GMapImage;
                              }

                              if(tile != null)
                              {
                                 using(tile)
                                 {
                                    long x = p.X * info.Type.Projection.TileSize.Width - topLeftPx.X + padding;
                                    long y = p.Y * info.Type.Projection.TileSize.Width - topLeftPx.Y + padding;
                                    {
                                       gfx.DrawImage(tile.Img, x, y, info.Type.Projection.TileSize.Width, info.Type.Projection.TileSize.Height);
                                    }
                                 }
                              }
                           }
                        }
                     }

                     // draw routes
                     {
                        foreach(GMapRoute r in Main.routes.Routes)
                        {
                           if(r.IsVisible)
                           {
                              using(GraphicsPath rp = new GraphicsPath())
                              {
                                 for(int j = 0; j < r.Points.Count; j++)
                                 {
                                    var pr = r.Points[j];
                                    GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                                    px.Offset(padding, padding);
                                    px.Offset(-topLeftPx.X, -topLeftPx.Y);

                                    GPoint p2 = px;

                                    if(j == 0)
                                    {
                                       rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
                                    }
                                    else
                                    {
                                       System.Drawing.PointF p = rp.GetLastPoint();
                                       rp.AddLine(p.X, p.Y, p2.X, p2.Y);
                                    }
                                 }

                                 if(rp.PointCount > 0)
                                 {
                                    gfx.DrawPath(r.Stroke, rp);
                                 }
                              }
                           }
                        }
                     }

                     // draw polygons
                     {
                        foreach(GMapPolygon r in Main.polygons.Polygons)
                        {
                           if(r.IsVisible)
                           {
                              using(GraphicsPath rp = new GraphicsPath())
                              {
                                 for(int j = 0; j < r.Points.Count; j++)
                                 {
                                    var pr = r.Points[j];
                                    GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                                    px.Offset(padding, padding);
                                    px.Offset(-topLeftPx.X, -topLeftPx.Y);

                                    GPoint p2 = px;

                                    if(j == 0)
                                    {
                                       rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
                                    }
                                    else
                                    {
                                       System.Drawing.PointF p = rp.GetLastPoint();
                                       rp.AddLine(p.X, p.Y, p2.X, p2.Y);
                                    }
                                 }

                                 if(rp.PointCount > 0)
                                 {
                                    rp.CloseFigure();

                                    gfx.FillPath(r.Fill, rp);

                                    gfx.DrawPath(r.Stroke, rp);
                                 }
                              }
                           }
                        }
                     }

                     // draw markers
                     {
                        foreach(GMapMarker r in Main.objects.Markers)
                        {
                           if(r.IsVisible)
                           {
                              var pr = r.Position;
                              GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                              px.Offset(padding, padding);
                              px.Offset(-topLeftPx.X, -topLeftPx.Y);
                              px.Offset(r.Offset.X, r.Offset.Y);

                              r.LocalPosition = new System.Drawing.Point((int)px.X, (int)px.Y);

                              r.OnRender(gfx);
                           }
                        }

                        // tooltips above
                        foreach(GMapMarker m in Main.objects.Markers)
                        {
                           if(m.IsVisible && m.ToolTip != null && m.IsVisible)
                           {
                              if(!string.IsNullOrEmpty(m.ToolTipText))
                              {
                                 m.ToolTip.OnRender(gfx);
                              }
                           }
                        }
                     }

                     // draw info
                     {
                        System.Drawing.Rectangle rect = new System.Drawing.Rectangle();
                        {
                           rect.Location = new System.Drawing.Point(padding, padding);
                           rect.Size = new System.Drawing.Size((int)pxDelta.X, (int)pxDelta.Y);
                        }

                        using(Font f = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold))
                        {
                           // draw bounds & coordinates
                           using(Pen p = new Pen(Brushes.DimGray, 3))
                           {
                              p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;

                              gfx.DrawRectangle(p, rect);

                              string topleft = info.Area.LocationTopLeft.ToString();
                              SizeF s = gfx.MeasureString(topleft, f);

                              gfx.DrawString(topleft, f, p.Brush, rect.X + s.Height / 2, rect.Y + s.Height / 2);

                              string rightBottom = new PointLatLng(info.Area.Bottom, info.Area.Right).ToString();
                              SizeF s2 = gfx.MeasureString(rightBottom, f);

                              gfx.DrawString(rightBottom, f, p.Brush, rect.Right - s2.Width - s2.Height / 2, rect.Bottom - s2.Height - s2.Height / 2);
                           }

                           // draw scale
                           using(Pen p = new Pen(Brushes.Blue, 1))
                           {
                              double rez = info.Type.Projection.GetGroundResolution(info.Zoom, info.Area.Bottom);
                              int px100 = (int)(100.0 / rez); // 100 meters
                              int px1000 = (int)(1000.0 / rez); // 1km   

                              gfx.DrawRectangle(p, rect.X + 10, rect.Bottom - 20, px1000, 10);
                              gfx.DrawRectangle(p, rect.X + 10, rect.Bottom - 20, px100, 10);

                              string leftBottom = "scale: 100m | 1Km";
                              SizeF s = gfx.MeasureString(leftBottom, f);
                              gfx.DrawString(leftBottom, f, p.Brush, rect.X + 10, rect.Bottom - s.Height - 20);
                           }
                        }
                     }
                  }

                  bmpDestination.Save(bigImage, ImageFormat.Png);
               }
            }

            //The worldfile for the original image is:

            //0.000067897543      // the horizontal size of a pixel in coordinate units (longitude degrees in this case);
            //0.0000000
            //0.0000000
            //-0.0000554613012    // the comparable vertical pixel size in latitude degrees, negative because latitude decreases as you go from top to bottom in the image.
            //-111.743323868834   // longitude of the pixel in the upper-left-hand corner.
            //35.1254392635083    // latitude of the pixel in the upper-left-hand corner.

            // generate world file
            if(info.MakeWorldFile)
            {
               string wf = bigImage + "w";
               using(StreamWriter world = File.CreateText(wf))
               {
                  world.WriteLine("{0:0.000000000000}", (info.Area.WidthLng / pxDelta.X));
                  world.WriteLine("0.0000000");
                  world.WriteLine("0.0000000");
                  world.WriteLine("{0:0.000000000000}", (-info.Area.HeightLat / pxDelta.Y));
                  world.WriteLine("{0:0.000000000000}", info.Area.Left);
                  world.WriteLine("{0:0.000000000000}", info.Area.Top);
                  world.Close();
               }
            }
         }
      }
Exemplo n.º 6
0
        private void GetLastPoint2(Graphics g)
        {
            GraphicsPath myPath = new GraphicsPath();

            try
            {
                PointF lastPoint = myPath.GetLastPoint();
                if(!lastPoint.IsEmpty)
                {
                    string lastPointXString = lastPoint.X.ToString();
                    string lastPointYString = lastPoint.Y.ToString();
                    Console.WriteLine(lastPointXString + ", " + lastPointYString);
                }
                else
                    Console.WriteLine("lastPoint is empty");
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine (ae.Message);
            }

            // Draw the path to the screen.
            g.DrawPath(new Pen(Color.Black, 2), myPath);
        }
Exemplo n.º 7
0
        private void GetLastPoint1(Graphics g)
        {
            GraphicsPath myPath = new GraphicsPath();
            myPath.AddLine(100, 100, 300, 100);
            PointF lastPoint = myPath.GetLastPoint();
            if(!lastPoint.IsEmpty)
            {
                string lastPointXString = lastPoint.X.ToString();
                string lastPointYString = lastPoint.Y.ToString();
                Console.WriteLine(lastPointXString + ", " + lastPointYString);
            }
            else
                Console.WriteLine("lastPoint is empty");

            // Draw the path to the screen.
            g.DrawPath(new Pen(Color.Black, 2), myPath);
        }
Exemplo n.º 8
0
      void bg_DoWork(object sender, DoWorkEventArgs e)
      {
         MapInfo info = (MapInfo)e.Argument;
         if(!info.Area.IsEmpty)
         {
            string bigImage = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + Path.DirectorySeparatorChar + "GMap at zoom " + info.Zoom + " - " + info.Type + "-" + DateTime.Now.Ticks + ".jpg";
            e.Result = bigImage;

            // current area
            GPoint topLeftPx = info.Type.Projection.FromLatLngToPixel(info.Area.LocationTopLeft, info.Zoom);
            GPoint rightButtomPx = info.Type.Projection.FromLatLngToPixel(info.Area.Bottom, info.Area.Right, info.Zoom);
            GPoint pxDelta = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);
            GMap.NET.GSize maxOfTiles = info.Type.Projection.GetTileMatrixMaxXY(info.Zoom);

            int padding = info.MakeWorldFile || info.MakeKmz ? 0 : 22;
            {
               using(Bitmap bmpDestination = new Bitmap((int)(pxDelta.X + padding * 2), (int)(pxDelta.Y + padding * 2)))
               {
                  using(Graphics gfx = Graphics.FromImage(bmpDestination))
                  {
                     gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
                     gfx.SmoothingMode = SmoothingMode.HighQuality;

                     int i = 0;

                     // get tiles & combine into one
                     lock(tileArea)
                     {
                        foreach(var p in tileArea)
                        {
                           if(bg.CancellationPending)
                           {
                              e.Cancel = true;
                              return;
                           }

                           int pc = (int)(((double)++i / tileArea.Count) * 100);
                           bg.ReportProgress(pc, p);

                           foreach(var tp in info.Type.Overlays)
                           {
                              Exception ex;
                              GMapImage tile;

                              // tile number inversion(BottomLeft -> TopLeft) for pergo maps
                              if(tp.InvertedAxisY)
                              {
                                 tile = GMaps.Instance.GetImageFrom(tp, new GPoint(p.X, maxOfTiles.Height - p.Y), info.Zoom, out ex) as GMapImage;
                              }
                              else // ok
                              {
                                 tile = GMaps.Instance.GetImageFrom(tp, p, info.Zoom, out ex) as GMapImage;
                              }

                              if(tile != null)
                              {
                                 using(tile)
                                 {
                                    long x = p.X * info.Type.Projection.TileSize.Width - topLeftPx.X + padding;
                                    long y = p.Y * info.Type.Projection.TileSize.Width - topLeftPx.Y + padding;
                                    {
                                       gfx.DrawImage(tile.Img, x, y, info.Type.Projection.TileSize.Width, info.Type.Projection.TileSize.Height);
                                    }
                                 }
                              }
                           }
                        }
                     }

                     // draw routes
                     {
                        foreach(GMapRoute r in Main.routes.Routes)
                        {
                           if(r.IsVisible)
                           {
                              using(GraphicsPath rp = new GraphicsPath())
                              {
                                 for(int j = 0; j < r.Points.Count; j++)
                                 {
                                    var pr = r.Points[j];
                                    GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                                    px.Offset(padding, padding);
                                    px.Offset(-topLeftPx.X, -topLeftPx.Y);

                                    GPoint p2 = px;

                                    if(j == 0)
                                    {
                                       rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
                                    }
                                    else
                                    {
                                       System.Drawing.PointF p = rp.GetLastPoint();
                                       rp.AddLine(p.X, p.Y, p2.X, p2.Y);
                                    }
                                 }

                                 if(rp.PointCount > 0)
                                 {
                                    gfx.DrawPath(r.Stroke, rp);
                                 }
                              }
                           }
                        }
                     }

                     // draw polygons
                     {
                        foreach(GMapPolygon r in Main.polygons.Polygons)
                        {
                           if(r.IsVisible)
                           {
                              using(GraphicsPath rp = new GraphicsPath())
                              {
                                 for(int j = 0; j < r.Points.Count; j++)
                                 {
                                    var pr = r.Points[j];
                                    GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                                    px.Offset(padding, padding);
                                    px.Offset(-topLeftPx.X, -topLeftPx.Y);

                                    GPoint p2 = px;

                                    if(j == 0)
                                    {
                                       rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
                                    }
                                    else
                                    {
                                       System.Drawing.PointF p = rp.GetLastPoint();
                                       rp.AddLine(p.X, p.Y, p2.X, p2.Y);
                                    }
                                 }

                                 if(rp.PointCount > 0)
                                 {
                                    rp.CloseFigure();

                                    gfx.FillPath(r.Fill, rp);

                                    gfx.DrawPath(r.Stroke, rp);
                                 }
                              }
                           }
                        }
                     }

                     // draw markers
                     {
                        foreach(GMapMarker r in Main.objects.Markers)
                        {
                           if(r.IsVisible)
                           {
                              var pr = r.Position;
                              GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                              px.Offset(padding, padding);
                              px.Offset(-topLeftPx.X, -topLeftPx.Y);
                              px.Offset(r.Offset.X, r.Offset.Y);

                              gfx.ResetTransform();
                              gfx.TranslateTransform(-r.LocalPosition.X, -r.LocalPosition.Y);
                              gfx.TranslateTransform((int)px.X, (int)px.Y);

                              r.OnRender(gfx);
                           }
                        }

                        // tooltips above
                        foreach(GMapMarker m in Main.objects.Markers)
                        {
                           if(m.IsVisible && m.ToolTip != null && m.IsVisible)
                           {
                              if(!string.IsNullOrEmpty(m.ToolTipText))
                              {
                                 var pr = m.Position;
                                 GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                                 px.Offset(padding, padding);
                                 px.Offset(-topLeftPx.X, -topLeftPx.Y);
                                 px.Offset(m.Offset.X, m.Offset.Y);

                                 gfx.ResetTransform();
                                 gfx.TranslateTransform(-m.LocalPosition.X, -m.LocalPosition.Y);
                                 gfx.TranslateTransform((int)px.X, (int)px.Y);

                                 m.ToolTip.OnRender(gfx);
                              }
                           }
                        }
                        gfx.ResetTransform();
                     }

                     // draw info
                     if(!info.MakeWorldFile)
                     {
                        System.Drawing.Rectangle rect = new System.Drawing.Rectangle();
                        {
                           rect.Location = new System.Drawing.Point(padding, padding);
                           rect.Size = new System.Drawing.Size((int)pxDelta.X, (int)pxDelta.Y);
                        }

                        using(Font f = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold))
                        {
                           // draw bounds & coordinates
                           using(Pen p = new Pen(Brushes.DimGray, 3))
                           {
                              p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;

                              gfx.DrawRectangle(p, rect);

                              string topleft = info.Area.LocationTopLeft.ToString();
                              SizeF s = gfx.MeasureString(topleft, f);

                              gfx.DrawString(topleft, f, p.Brush, rect.X + s.Height / 2, rect.Y + s.Height / 2);

                              string rightBottom = new PointLatLng(info.Area.Bottom, info.Area.Right).ToString();
                              SizeF s2 = gfx.MeasureString(rightBottom, f);

                              gfx.DrawString(rightBottom, f, p.Brush, rect.Right - s2.Width - s2.Height / 2, rect.Bottom - s2.Height - s2.Height / 2);
                           }

                           // draw scale
                           using(Pen p = new Pen(Brushes.Blue, 1))
                           {
                              double rez = info.Type.Projection.GetGroundResolution(info.Zoom, info.Area.Bottom);
                              int px100 = (int)(100.0 / rez); // 100 meters
                              int px1000 = (int)(1000.0 / rez); // 1km   

                              gfx.DrawRectangle(p, rect.X + 10, rect.Bottom - 20, px1000, 10);
                              gfx.DrawRectangle(p, rect.X + 10, rect.Bottom - 20, px100, 10);

                              string leftBottom = "scale: 100m | 1Km";
                              SizeF s = gfx.MeasureString(leftBottom, f);
                              gfx.DrawString(leftBottom, f, p.Brush, rect.X + 10, rect.Bottom - s.Height - 20);
                           }
                        }
                     }
                  }

                  bmpDestination.Save(bigImage, ImageFormat.Jpeg);
               }
            }

            //The worldfile for the original image is:

            //0.000067897543      // the horizontal size of a pixel in coordinate units (longitude degrees in this case);
            //0.0000000
            //0.0000000
            //-0.0000554613012    // the comparable vertical pixel size in latitude degrees, negative because latitude decreases as you go from top to bottom in the image.
            //-111.743323868834   // longitude of the pixel in the upper-left-hand corner.
            //35.1254392635083    // latitude of the pixel in the upper-left-hand corner.

            // generate world file
            if(info.MakeWorldFile)
            {
               string wf = bigImage + "w";
               using(StreamWriter world = File.CreateText(wf))
               {
                  world.WriteLine("{0:0.000000000000}", (info.Area.WidthLng / pxDelta.X));
                  world.WriteLine("0.0000000");
                  world.WriteLine("0.0000000");
                  world.WriteLine("{0:0.000000000000}", (-info.Area.HeightLat / pxDelta.Y));
                  world.WriteLine("{0:0.000000000000}", info.Area.Left);
                  world.WriteLine("{0:0.000000000000}", info.Area.Top);
                  world.Close();
               }
            }

            if(info.MakeKmz)
            {
               var kmzFile = Path.GetDirectoryName(bigImage) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(bigImage) + ".kmz";
               e.Result = kmzFile;

               using(ZipStorer zip = ZipStorer.Create(kmzFile, "GMap.NET"))
               {
                  zip.AddFile(ZipStorer.Compression.Store, bigImage, "files/map.jpg", "map");

                  using(var readme = new MemoryStream(
                    Encoding.UTF8.GetBytes(
                     string.Format(CultureInfo.InvariantCulture, @"<?xml version=""1.0"" encoding=""UTF-8""?> 
<kml xmlns=""http://www.opengis.net/kml/2.2"" xmlns:gx=""http://www.google.com/kml/ext/2.2"" xmlns:kml=""http://www.opengis.net/kml/2.2"" xmlns:atom=""http://www.w3.org/2005/Atom"">
<GroundOverlay>
	<name>{8}</name>
	<LookAt>
		<longitude>{6}</longitude>
		<latitude>{7}</latitude>
		<altitude>0</altitude>
		<heading>0</heading>
		<tilt>0</tilt>
		<range>69327.55500845652</range>
	</LookAt>
	<color>91ffffff</color>
	<Icon>
		<href>files/map.jpg</href>
	</Icon>
	<gx:LatLonQuad>
		<coordinates>
			{0},{1},0 {2},{3},0 {4},{5},0 {6},{7},0 
		</coordinates>
	</gx:LatLonQuad>
</GroundOverlay>
</kml>", info.Area.Left, info.Area.Bottom,
         info.Area.Right, info.Area.Bottom,
         info.Area.Right, info.Area.Top,
         info.Area.Left, info.Area.Top,
         kmzFile))))
                  {

                     zip.AddStream(ZipStorer.Compression.Store, "doc.kml", readme, DateTime.Now, "kml");
                     zip.Close();
                  }
               }
            }
         }
      }
Exemplo n.º 9
0
      /// <summary>
      /// draw polygons, override to draw custom
      /// </summary>
      /// <param name="g"></param>
      protected virtual void DrawPolygons(Graphics g)
      {
#if !PocketPC
         foreach(GMapPolygon r in Polygons)
         {
            if(r.IsVisible)
            {
               using(GraphicsPath rp = new GraphicsPath())
               {
                  for(int i = 0; i < r.LocalPoints.Count; i++)
                  {
                     GPoint p2 = r.LocalPoints[i];

                     if(i == 0)
                     {
                        rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
                     }
                     else
                     {
                        System.Drawing.PointF p = rp.GetLastPoint();
                        rp.AddLine(p.X, p.Y, p2.X, p2.Y);
                     }
                  }

                  if(rp.PointCount > 0)
                  {
                     rp.CloseFigure();

                     if (!(((SolidBrush)r.Fill).Color.A == 155 && ((SolidBrush)r.Fill).Color.B == 255 && ((SolidBrush)r.Fill).Color.G == 248 && ((SolidBrush)r.Fill).Color.R == 240))
                        g.FillPath(r.Fill, rp);

                     g.DrawPath(r.Stroke, rp);
                  }
               }
            }
         }
#else
         foreach(GMapPolygon r in Polygons)
         {
            if(r.IsVisible)
            {
               Point[] pnts = new Point[r.LocalPoints.Count];
               for(int i = 0; i < r.LocalPoints.Count; i++)
               {
                  Point p2 = new Point(r.LocalPoints[i].X, r.LocalPoints[i].Y);
                  pnts[pnts.Length - 1 - i] = p2;
               }

               if(pnts.Length > 0)
               {
                  g.FillPolygon(r.Fill, pnts);
                  g.DrawPolygon(r.Stroke, pnts);
               }
            }
         }
#endif
      }
Exemplo n.º 10
0
      /// <summary>
      /// draw routes, override to draw custom
      /// </summary>
      /// <param name="g"></param>
      protected virtual void DrawRoutes(Graphics g)
      {
#if !PocketPC
         foreach(GMapRoute r in Routes)
         {
            if(r.IsVisible)
            {
               using(GraphicsPath rp = new GraphicsPath())
               {
                  for(int i = 0; i < r.LocalPoints.Count; i++)
                  {
                     GPoint p2 = r.LocalPoints[i];

                     if(i == 0)
                     {
                        rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
                     }
                     else
                     {
                        System.Drawing.PointF p = rp.GetLastPoint();
                        rp.AddLine(p.X, p.Y, p2.X, p2.Y);
                     }
                  }

                  if(rp.PointCount > 0)
                  {
                     g.DrawPath(r.Stroke, rp);
                  }
               }
            }
         }
#else
         foreach(GMapRoute r in Routes)
         {
            if(r.IsVisible)
            {
               Point[] pnts = new Point[r.LocalPoints.Count];
               for(int i = 0; i < r.LocalPoints.Count; i++)
               {
                  Point p2 = new Point(r.LocalPoints[i].X, r.LocalPoints[i].Y);
                  pnts[pnts.Length - 1 - i] = p2;
               }

               if(pnts.Length > 0)
               {
                  g.DrawLines(r.Stroke, pnts);
               }
            }
         }
#endif
      }
Exemplo n.º 11
0
        public static GraphicsPath PathDataParse(string text, PointInfoCollection pointsInfo)
        {
            PathFunc.startinfo = null;
            int num1 = -1;
            pointsInfo.Clear();
            GraphicsPath path1 = new GraphicsPath();
            GraphicsPathIterator iterator1 = new GraphicsPathIterator(path1);
            PointF tf1 = PointF.Empty;
            string text1 = "";
            int nLength=text.Length;
            Regex regex1 = new Regex("[A-DF-Za-df-z][^A-DF-Za-df-z]*");
            PointF tf2 = PointF.Empty;
            Match match1 = regex1.Match(text);
            int num2 = 0;
            //StringBuilder text2 = new StringBuilder();
            //string text3 = text;
            PointF tf3 = PointF.Empty;
            PointF tf4 = PointF.Empty;
            PointInfo info1 = null;
            StringBuilder text4=new StringBuilder(text);
            while (match1.Success)
            {
                float single1;
                float single2;
                float single3;
                float single4;
                float single5;
                float single6;
                ExtendedGraphicsPath path2;
                int num3 = match1.Index;
                text4.Remove(0,text1.Length);
            //                text4 =new StringBuilder(text3.Substring(num3, text3.Length - match1.Index));
                if (info1 != null)
                {
                    //info1.NextString =match1.Value.Trim();// text4.ToString();//match1.Value.Trim();
                }
                text1 = match1.Value.Trim();
                char ch1 = (char) text1.ToCharArray(0, 1).GetValue(0);
                float[] singleArray1 = PathFunc.GetCoords(text1);
                PointInfo info2 = null;
                char ch2 = ch1;
                if (ch2 <= 'Z')
                {
                    if (ch2 <= 'H')
                    {
                        switch (ch2)
                        {
                            case 'A':
                            {
                                path2 = new ExtendedGraphicsPath(path1);
                                if (singleArray1.Length != 7)
                                {
                                    throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                                }
                                isArc=true;
                                path2.AddArc(tf2, new PointF(singleArray1[5], singleArray1[6]), singleArray1[0], singleArray1[1], (singleArray1[3] != 0f) && true, (singleArray1[4] != 0f) && true, singleArray1[2]);
                                goto Label_092D;
                            }
                            case 'B':
                            {
                                goto Label_0FEB;
                            }
                            case 'C':
                            {
                                PointF pf1=tf2;
                                int num10=0;

                                if (singleArray1.Length < 6)
                                {
                                    throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                                }

                                drawArc:
                                path1.AddBezier(pf1.X, pf1.Y, singleArray1[num10], singleArray1[num10+1], singleArray1[num10+2], singleArray1[num10+3], singleArray1[num10+4], singleArray1[num10+5]);

                                pf1=new PointF(singleArray1[num10+4],singleArray1[num10+5]);

                                if((num10+6)<singleArray1.Length)
                                {

            //									info2 = new PointInfo(new PointF(singleArray1[num10+4], singleArray1[num10+5]), new PointF(singleArray1[num10+0], singleArray1[num10+1]), new PointF(singleArray1[num10+2], singleArray1[num10+3]), text1);
            //									info2.Command="C";
            //									pointsInfo.Add(info2);
                                    num10+=6;
                                    goto drawArc;

                                }
                                if (num10>0)
                                {
                                    tf1 = new PointF(singleArray1[num10+2], singleArray1[num10+3]);
                                    tf2 = new PointF(singleArray1[num10+4], singleArray1[num10+5]);

                                    info2 = new PointInfo(new PointF(singleArray1[num10+4], singleArray1[num10+5]), new PointF(singleArray1[num10+0], singleArray1[num10+1]), new PointF(singleArray1[num10+2], singleArray1[num10+3]), text1);
                                    info2.Command="C";
                                    goto Label_1001;
                                }

                                goto Label_0872;
                            }
                            case 'H':
                            {
                                goto Label_033D;
                            }
                        }
                        goto Label_0FEB;
                    }
                    switch (ch2)
                    {
                        case 'L':
                        {
            //                            if (singleArray1.Length != 2)
            //                            {
            //                                throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
            //                            }
                            //path1.AddLine(tf2, new PointF(singleArray1[0], singleArray1[1]));
                            PointF[] ptfs=new PointF[singleArray1.Length/2+1];
                            ptfs[0]=tf2;
                            int index1=0;
                            for (int i = 1; i < singleArray1.Length; i++)
                            {
                                index1++;
                                ptfs[index1]=new PointF(singleArray1[i-1],singleArray1[i]);
                                i++;
                            }
                            path1.AddLines(ptfs);
                            info2 = new PointInfo(new PointF(singleArray1[0], singleArray1[1]), text1);
                            goto Label_02B5;
                        }
                        case 'M':
                        {
                            path1.StartFigure();
                            if (singleArray1.Length != 2)
                            {
                                throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                            }
                            tf2 = new PointF(singleArray1[0], singleArray1[1]);
                            info2 = new PointInfo(tf2, text1);
                            info2.IsStart = true;
                            isArc=false;
                            PathFunc.startinfo = info2;
                            //info2.PreString = text1;//text2.ToString();
                            goto Label_0205;
                        }
                        case 'N':
                        case 'O':
                        case 'P':
                        case 'R':
                        case 'U':
                        {
                            goto Label_0FEB;
                        }
                        case 'Q':
                        {
                            single1 = tf2.X + (((singleArray1[0] - tf2.X) * 2f) / 3f);
                            single2 = tf2.Y + (((singleArray1[1] - tf2.Y) * 2f) / 3f);
                            single3 = singleArray1[0] + ((singleArray1[2] - singleArray1[0]) / 3f);
                            single4 = singleArray1[1] + ((singleArray1[3] - singleArray1[1]) / 3f);
                            if (singleArray1.Length != 4)
                            {
                                throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                            }
                            path1.AddBezier(tf2.X, tf2.Y, single1, single2, single3, single4, singleArray1[2], singleArray1[3]);
                            goto Label_0579;
                        }
                        case 'S':
                        {
                            if (singleArray1.Length != 4)
                            {
                                throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                            }
                            if (!tf1.IsEmpty)
                            {
                                goto Label_0755;
                            }
                            path1.AddBezier(tf2.X, tf2.Y, tf2.X, tf2.Y, singleArray1[0], singleArray1[1], singleArray1[2], singleArray1[3]);
                            pointsInfo.Add(new PointInfo(new PointF(singleArray1[2], singleArray1[3]), tf2, new PointF(singleArray1[0], singleArray1[1]), text1));
                            goto Label_07C4;
                        }
                        case 'T':
                        {
                            if (!tf1.IsEmpty)
                            {
                                goto Label_05D2;
                            }
                            single5 = tf2.X;
                            single6 = tf2.Y;
                            goto Label_0600;
                        }
                        case 'V':
                        {
                            if (singleArray1.Length != 1)
                            {
                                throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                            }
                            path1.AddLine(tf2, new PointF(tf2.X, singleArray1[0]));
                            goto Label_0439;
                        }
                        case 'Z':
                        {
                            goto Label_0F72;
                        }
                    }
                    goto Label_0FEB;
                }
                if (ch2 <= 'h')
                {
                    switch (ch2)
                    {
                        case 'a':
                        {
                            path2 = new ExtendedGraphicsPath(path1);
                            if (singleArray1.Length != 7)
                            {
                                throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                            }
                            path2.AddArc(tf2, new PointF(singleArray1[5] + tf2.X, singleArray1[6] + tf2.Y), singleArray1[0], singleArray1[1], (singleArray1[3] != 0f) && true, (singleArray1[4] != 0f) && true, singleArray1[2]);
                            goto Label_09F7;
                        }
                        case 'b':
                        {
                            goto Label_0FEB;
                        }
                        case 'c':
                        {
                            if (singleArray1.Length != 6)
                            {
                                throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("unnabeparsepath") + text1);
                            }
                            path1.AddBezier(tf2.X, tf2.Y, (float) (singleArray1[0] + tf2.X), (float) (singleArray1[1] + tf2.Y), (float) (singleArray1[2] + tf2.X), (float) (singleArray1[3] + tf2.Y), (float) (singleArray1[4] + tf2.X), (float) (singleArray1[5] + tf2.Y));
                            goto Label_0EF0;
                        }
                        case 'h':
                        {
                            goto Label_0397;
                        }
                    }
                    goto Label_0FEB;
                }
                switch (ch2)
                {
                    case 'l':
                    {
                        if (singleArray1.Length != 2)
                        {
                            throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                        }
                        path1.AddLine(tf2, new PointF(singleArray1[0] + tf2.X, singleArray1[1] + tf2.Y));
                        goto Label_030E;
                    }
                    case 'm':
                    {
                        path1.StartFigure();
                        if (singleArray1.Length != 2)
                        {
                            throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                        }
                        tf2 = new PointF(singleArray1[0], singleArray1[1]);
                        info2 = new PointInfo(tf2, text1);
                        info2.IsStart = true;
                        isArc=false;
                        PathFunc.startinfo = info2;
                        goto Label_025F;
                    }
                    case 'n':
                    case 'o':
                    case 'p':
                    case 'r':
                    case 'u':
                    {
                        goto Label_0FEB;
                    }
                    case 'q':
                    {
                        single1 = tf2.X + ((singleArray1[0] * 2f) / 3f);
                        single2 = tf2.Y + ((singleArray1[1] * 2f) / 3f);
                        single3 = (singleArray1[0] + tf2.X) + ((singleArray1[2] - singleArray1[0]) / 3f);
                        single4 = (singleArray1[1] + tf2.Y) + ((singleArray1[3] - singleArray1[1]) / 3f);
                        if (singleArray1.Length != 4)
                        {
                            throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                        }
                        path1.AddBezier(tf2.X, tf2.Y, single1, single2, single3, single4, (float) (singleArray1[2] + tf2.X), (float) (singleArray1[3] + tf2.Y));
                        goto Label_0B0D;
                    }
                    case 's':
                    {
                        if (singleArray1.Length != 4)
                        {
                            throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                        }
                        if (!tf1.IsEmpty)
                        {
                            goto Label_0D63;
                        }
                        path1.AddBezier(tf2.X, tf2.Y, tf2.X, tf2.Y, (float) (singleArray1[0] + tf2.X), (float) (singleArray1[1] + tf2.Y), (float) (singleArray1[2] + tf2.X), (float) (singleArray1[3] + tf2.Y));
                        goto Label_0DF2;
                    }
                    case 't':
                    {
                        if (!tf1.IsEmpty)
                        {
                            goto Label_0B98;
                        }
                        single5 = tf2.X;
                        single6 = tf2.Y;
                        goto Label_0BC6;
                    }
                    case 'v':
                    {
                        if (singleArray1.Length != 1)
                        {
                            throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                        }
                        path1.AddLine(tf2, new PointF(tf2.X, singleArray1[0] + tf2.Y));
                        goto Label_049B;
                    }
                    case 'z':
                    {
                        goto Label_0F72;
                    }
                    default:
                    {
                        goto Label_0FEB;
                    }
                }
            Label_0205://M
                num2++;
                goto Label_1001;
            Label_025F:
                num2++;
                goto Label_1001;
            Label_02B5:
                tf2 = new PointF(singleArray1[0], singleArray1[1]);
                goto Label_1001;
            Label_030E:
                tf2 = new PointF(singleArray1[0] + tf2.X, singleArray1[1] + tf2.Y);
                info2 = new PointInfo(tf2, text1);
                goto Label_1001;
            Label_033D:
                if (singleArray1.Length == 1)
                {
                    path1.AddLine(tf2, new PointF(singleArray1[0], tf2.Y));
                }
                else
                {
                    throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                }
                tf2 = new PointF(singleArray1[0], tf2.Y);
                info2 = new PointInfo(tf2, text1);
                goto Label_1001;
            Label_0397:
                if (singleArray1.Length == 1)
                {
                    path1.AddLine(tf2, new PointF(singleArray1[0] + tf2.X, tf2.Y));
                }
                else
                {
                    throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                }
                tf2 = new PointF(singleArray1[0] + tf2.X, tf2.Y);
                info2 = new PointInfo(tf2, text1);
                goto Label_1001;
            Label_0439:
                tf2 = new PointF(tf2.X, singleArray1[0]);
                info2 = new PointInfo(tf2, text1);
                goto Label_1001;
            Label_049B:
                tf2 = new PointF(tf2.X, singleArray1[0] + tf2.Y);
                info2 = new PointInfo(tf2, text1);
                goto Label_1001;
            Label_0579:
                tf1 = new PointF(single3, single4);
                tf2 = new PointF(singleArray1[2], singleArray1[3]);
                info2 = new PointInfo(tf2, new PointF(single1, single2), new PointF(single3, single4), text1);
                goto Label_1001;
            Label_05D2:
                single5 = (2f * tf2.X) - tf1.X;
                single6 = (2f * tf2.Y) - tf1.Y;
            Label_0600:
                single1 = tf2.X + (((single5 - tf2.X) * 2f) / 3f);
                single2 = tf2.Y + (((single6 - tf2.Y) * 2f) / 3f);
                single3 = single5 + ((singleArray1[0] - single5) / 3f);
                single4 = single6 + ((singleArray1[1] - single6) / 3f);
                if (singleArray1.Length != 2)
                {
                    throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                }
                path1.AddBezier(tf2.X, tf2.Y, single1, single2, single3, single4, singleArray1[0], singleArray1[1]);
                tf1 = new PointF(single3, single4);
                tf2 = new PointF(singleArray1[0], singleArray1[1]);
                info2 = new PointInfo(tf2, new PointF(single1, single2), new PointF(single3, single4), text1);
                goto Label_1001;
            Label_0755:
                single1 = (2f * tf2.X) - tf1.X;
                single2 = (2f * tf2.Y) - tf1.Y;
                path1.AddBezier(tf2.X, tf2.Y, single1, single2, singleArray1[0], singleArray1[1], singleArray1[2], singleArray1[3]);
            Label_07C4:
                tf1 = new PointF(singleArray1[0], singleArray1[1]);
                tf2 = new PointF(singleArray1[2], singleArray1[3]);
                info2 = new PointInfo(path1.GetLastPoint(), path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2], text1);
                goto Label_1001;
            Label_0872:
                tf1 = new PointF(singleArray1[2], singleArray1[3]);
                tf2 = new PointF(singleArray1[4], singleArray1[5]);
                info2 = new PointInfo(new PointF(singleArray1[4], singleArray1[5]), new PointF(singleArray1[0], singleArray1[1]), new PointF(singleArray1[2], singleArray1[3]), text1);
                goto Label_1001;
            Label_092D://A
                tf1 = PointF.Empty;
                tf2 = path1.GetLastPoint();//, path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2]
                info2 = new PointInfo(tf2,PointF.Empty,new PointF(tf2.X+singleArray1[0],tf2.Y), text1);
                info2.NextControl=new PointF(tf2.X,tf2.Y+singleArray1[1]);
                info2.Rx=singleArray1[0];
                info2.Ry=singleArray1[1];
                info2.Angle=singleArray1[2];
                info2.LargeArcFlage=(int)singleArray1[3];
                info2.SweepFlage=(int)singleArray1[4];
                goto Label_1001;
            Label_09F7:
                tf1 = PointF.Empty;
                tf2 = path1.GetLastPoint();
                info2 = new PointInfo(path1.GetLastPoint(), path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2], text1);
                goto Label_1001;
            Label_0B0D:
                tf1 = new PointF(single3, single4);
                tf2 = new PointF(singleArray1[2] + tf2.X, tf2.Y + singleArray1[3]);
                info2 = new PointInfo(path1.GetLastPoint(), path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2], text1);
                goto Label_1001;
            Label_0B98:
                single5 = (2f * tf2.X) - tf1.X;
                single6 = (2f * tf2.Y) - tf1.Y;
            Label_0BC6:
                single1 = tf2.X + (((single5 - tf2.X) * 2f) / 3f);
                single2 = tf2.Y + (((single6 - tf2.Y) * 2f) / 3f);
                single3 = single5 + (((singleArray1[0] + tf2.X) - single5) / 3f);
                single4 = single6 + (((singleArray1[1] + tf2.Y) - single6) / 3f);
                if (singleArray1.Length != 2)
                {
                    throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
                }
                path1.AddBezier(tf2.X, tf2.Y, single1, single2, single3, single4, (float) (singleArray1[0] + tf2.X), (float) (singleArray1[1] + tf2.Y));
                tf1 = new PointF(single3, single4);
                tf2 = new PointF(singleArray1[0] + tf2.X, tf2.Y + singleArray1[1]);
                info2 = new PointInfo(path1.GetLastPoint(), path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2], text1);
                goto Label_1001;
            Label_0D63:
                single1 = (2f * tf2.X) - tf1.X;
                single2 = (2f * tf2.Y) - tf1.Y;
                path1.AddBezier(tf2.X, tf2.Y, single1, single2, (float) (singleArray1[0] + tf2.X), (float) (singleArray1[1] + tf2.Y), (float) (singleArray1[2] + tf2.X), (float) (singleArray1[3] + tf2.Y));
            Label_0DF2:
                tf1 = new PointF(singleArray1[0] + tf2.X, tf2.Y + singleArray1[1]);
                tf2 = new PointF(singleArray1[2] + tf2.X, tf2.Y + singleArray1[3]);
                info2 = new PointInfo(path1.GetLastPoint(), path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2], text1);
                goto Label_1001;
            Label_0EF0:
                tf1 = new PointF(singleArray1[2] + tf2.X, tf2.Y + singleArray1[3]);
                tf2 = new PointF(singleArray1[4] + tf2.X, tf2.Y + singleArray1[5]);
                info2 = new PointInfo(path1.GetLastPoint(), path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2], text1);
                goto Label_1001;
            Label_0F72://Z
                path1.CloseFigure();
                if (pointsInfo.Count > 0)
                {
                    PointInfo info3 = pointsInfo[pointsInfo.Count - 1];
                    if ((PathFunc.startinfo != null) && (info3 != PathFunc.startinfo))
                    {   PathFunc.startinfo.PreInfo = info3;
                        info3.NextInfo = PathFunc.startinfo;
                        if(!isArc)
                        {
                            PathFunc.startinfo.SecondControl = info3.SecondControl;
                        }
            //                        info3.NextControl = PathFunc.startinfo.NextControl;
                        info3.IsEnd = true;
                    }
                }
                num2++;
                goto Label_1001;
            Label_0FEB://error
                throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("unnabeparsepath") + text);
            Label_1001:
                if (info2 != null)
                {
                    info2.Command = ch1.ToString();
                    pointsInfo.Add(info2);
                    //info2.PreString = text1;//text2.ToString();
                    info2.SubPath = num2;
                    info2.Index=num3;
                }

                info1 = info2;
                //text2.Append(match1.Value);
                match1 = match1.NextMatch();
                num1++;
            }
            return path1;
        }
Exemplo n.º 12
0
        public void EvaluateParameters()
        {
            Rectangle outerRectangle = new Rectangle(
                (int)(_owner.Center.X - _owner.OuterRadius * _outerFactor),
                (int)(_owner.Center.Y - _owner.OuterRadius * _outerFactor),
                (int)(2 * _owner.OuterRadius * _outerFactor),
                (int)(2 * _owner.OuterRadius * _outerFactor)
                );

            Rectangle innerRectangle = new Rectangle(
                (int)(_owner.Center.X - _owner.InnerRadius * _innerFactor),
                (int)(_owner.Center.Y - _owner.InnerRadius * _innerFactor),
                (int)(2 * _owner.InnerRadius * _innerFactor),
                (int)(2 * _owner.InnerRadius * _innerFactor)
                );

            // Внешняя дуга.
            GraphicsPath outerArc = new GraphicsPath();
            outerArc.AddArc(outerRectangle, _startAngle, _sweepAngle);

            // Внутренняя дуга сектора.
            GraphicsPath innerArc = new GraphicsPath();
            innerArc.AddArc(innerRectangle, _startAngle, _sweepAngle);

            // Вычисляем границу сектора.
            _diagSectorPath.Dispose();
            _diagSectorPath = new GraphicsPath();
            _diagSectorPath.AddPath(outerArc, true);
            _diagSectorPath.AddLine(
                outerArc.GetLastPoint(),
                innerArc.GetLastPoint()
                );
            innerArc.Reverse();
            _diagSectorPath.AddPath(innerArc, true);
            outerArc.Reverse();
            _diagSectorPath.AddLine(
                outerArc.GetLastPoint(),
                innerArc.GetLastPoint()
                );

            _region.Dispose();
            _region = new Region(_diagSectorPath);

            _owner.Invalidate();
        }
        public override void OnRender(System.Drawing.Graphics g)
        {
            if (IsVisible)
            {
                List<Point> points = new List<Point>();
                using (GraphicsPath rp = new GraphicsPath())
                {
                    for (int i = 0; i < LocalPoints.Count; i++)
                    {
                        GPoint p2 = LocalPoints[i];

                        points.Add(new Point(LocalPoints[i].X, LocalPoints[i].Y));
                        if (i == 0)
                        {
                            rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
                        }
                        else
                        {
                            System.Drawing.PointF p = rp.GetLastPoint();
                            rp.AddLine(p.X, p.Y, p2.X, p2.Y);
                        }
                        Pen pen = new Pen(Color.FromArgb(100, 255, 0, 0));
                        pen.Width = 1.5F;
                        if (_showNode)
                            g.DrawArc(pen, (float)LocalPoints[i].X - 3, (float)LocalPoints[i].Y - 3, 6, 6, (float)360, (float)360);
                    }

                    if (rp.PointCount > 0)
                    {
                        g.DrawPath(Stroke, rp);
                    }
                }
            }
        }
        public override void OnRender(Graphics g)
        {
            if (IsVisible)
            {
                using (GraphicsPath rp = new GraphicsPath())
                {
                    for (int i = 0; i < LocalPoints.Count; i++)
                    {
                        GPoint p2 = LocalPoints[i];

                        if (i == 0)
                        {
                            rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
                        }
                        else
                        {
                            System.Drawing.PointF p = rp.GetLastPoint();
                            rp.AddLine(p.X, p.Y, p2.X, p2.Y);
                        }
                    }

                    if (rp.PointCount > 0)
                    {
                        rp.CloseFigure();
                        g.FillPath(Fill, rp);
                        g.DrawPath(Stroke, rp);
                    }
                }
            }
        }
Exemplo n.º 15
0
		public void GetLastPoint2()
		{
			path = new GraphicsPath ();
			
			PointF actual = path.GetLastPoint ();		
		}
Exemplo n.º 16
0
		public void GetLastPoint()
		{
			path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddLine (new Point (400, 200), new Point (10, 100));

			PointF expected = new PointF (10f, 100f);
			PointF actual = path.GetLastPoint ();

			DrawingTest.AssertAlmostEqual(expected, actual);

			path.StartFigure ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.StartFigure ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));

			expected = new PointF (10f, 420f);
			actual = path.GetLastPoint ();

			DrawingTest.AssertAlmostEqual(expected, actual);

			path.StartFigure ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			expected = new PointF (400f, 10f);
			actual = path.GetLastPoint ();

			DrawingTest.AssertAlmostEqual(expected, actual);

			//t.AssertCompare ();
		}