Пример #1
0
    private void DrawCoordinate(Graphics graphics, IPoint p, string[] coordinateModes, Pen pen, System.Drawing.Font font,
                                SolidBrush textBrush, SolidBrush shadowBrush, StringFormat format)
    {
        DrawCross(graphics, p, pen, 10);

        double x = p.Coordinate.X;
        double y = p.Coordinate.Y;

        if (AppSettings.MapUnits == "feet")
        {
            x *= Constants.MetersPerFoot;
            y *= Constants.MetersPerFoot;
        }

        double lon;
        double lat;

        CoordinateSystem.ToGeodetic(x, y, out lon, out lat);

        double xOffset = 2;

        foreach (string mode in coordinateModes)
        {
            string yText;
            string xText;

            switch (mode)
            {
            case "dms":
                yText = (lat < 0 ? "S " : "N ") + ToDms(lat);
                xText = (lon < 0 ? "W " : "E ") + ToDms(lon);
                break;

            case "dd":
                yText = (lat < 0 ? "S " : "N ") + Math.Abs(lat).ToString("0.000000") + "°";
                xText = (lon < 0 ? "W " : "E ") + Math.Abs(lon).ToString("0.000000") + "°";
                break;

            case "usng":
                yText = "";
                MGRS mgrs = new MGRS();
                mgrs.ToGrid(lon, lat, out xText);
                break;

            default:
                string unit = AppSettings.MapUnits == "feet" ? " ft" : " m";
                yText = "N " + p.Coordinate.Y.ToString("#,##0") + unit;
                xText = "E " + p.Coordinate.X.ToString("#,##0") + unit;
                break;
            }


            DrawText(graphics, p, String.Format("{0}\n{1}", yText, xText), font, textBrush, shadowBrush, xOffset, -3, format);

            SizeF size = graphics.MeasureString((xText.Length > yText.Length ? xText : yText) + "..", font);
            xOffset += size.Width / _resolution;
        }
    }
Пример #2
0
    private void DrawCoordinate(Graphics graphics, IPoint p, string[] coordinateModes, Pen pen, System.Drawing.Font font,
                                SolidBrush textBrush, SolidBrush shadowBrush, StringFormat format)
    {
        DrawCross(graphics, p, pen, 10);

        Coordinate g       = _appSettings.MapCoordinateSystem.ToGeodetic(p.Coordinate);
        double     xOffset = 2;

        foreach (string mode in coordinateModes)
        {
            string yText;
            string xText;

            switch (mode)
            {
            case "dms":
                yText = (g.Y < 0 ? "S " : "N ") + ToDms(g.Y);
                xText = (g.X < 0 ? "W " : "E ") + ToDms(g.X);
                break;

            case "dd":
                yText = (g.Y < 0 ? "S " : "N ") + Math.Abs(g.Y).ToString("0.000000") + "°";
                xText = (g.X < 0 ? "W " : "E ") + Math.Abs(g.X).ToString("0.000000") + "°";
                break;

            case "usng":
                yText = "";
                MGRS mgrs = new MGRS();
                xText = mgrs.ToGrid(g);
                break;

            default:
                Coordinate c = p.Coordinate;

                if (!_appSettings.MapCoordinateSystem.Equals(_appSettings.MeasureCoordinateSystem))
                {
                    c = _appSettings.MeasureCoordinateSystem.ToProjected(g);

                    if (!Double.IsNaN(_appSettings.MarkupShiftX) && !Double.IsNaN(_appSettings.MarkupShiftY))
                    {
                        c = c.Translate(-_appSettings.MarkupShiftX, -_appSettings.MarkupShiftY);
                    }
                }

                string unit = _appSettings.MeasureCoordinateSystem.MapUnits == "feet" ? " ft" : " m";
                yText = "N " + c.Y.ToString("#,##0") + unit;
                xText = "E " + c.X.ToString("#,##0") + unit;
                break;
            }

            DrawText(graphics, p, String.Format("{0}\n{1}", yText, xText), font, textBrush, shadowBrush, xOffset, -3, format);

            SizeF size = graphics.MeasureString((xText.Length > yText.Length ? xText : yText) + "..", font);
            xOffset += size.Width / _resolution;
        }
    }
Пример #3
0
  private void DrawCoordinate(Graphics graphics, IPoint p, string[] coordinateModes, Pen pen, System.Drawing.Font font, 
      SolidBrush textBrush, SolidBrush shadowBrush, StringFormat format)
  {
    DrawCross(graphics, p, pen, 10);

    double x = p.Coordinate.X;
    double y = p.Coordinate.Y;

    if (AppSettings.MapUnits == "feet")
    {
      x *= Constants.MetersPerFoot;
      y *= Constants.MetersPerFoot;
    }

    double lon;
    double lat;
    CoordinateSystem.ToGeodetic(x, y, out lon, out lat);

    double xOffset = 2;

    foreach (string mode in coordinateModes)
    {
      string yText;
      string xText;

      switch (mode)
      {
        case "dms":
          yText = (lat < 0 ? "S " : "N ") + ToDms(lat);
          xText = (lon < 0 ? "W " : "E ") + ToDms(lon);
          break;

        case "dd":
          yText = (lat < 0 ? "S " : "N ") + Math.Abs(lat).ToString("0.000000") + "°";
          xText = (lon < 0 ? "W " : "E ") + Math.Abs(lon).ToString("0.000000") + "°";
          break;

        case "usng":
          yText = "";
          MGRS mgrs = new MGRS();
          mgrs.ToGrid(lon, lat, out xText);
          break;

        default:
          string unit = AppSettings.MapUnits == "feet" ? " ft" : " m";
          yText = "N " + p.Coordinate.Y.ToString("#,##0") + unit;
          xText = "E " + p.Coordinate.X.ToString("#,##0") + unit;
          break;
      }


      DrawText(graphics, p, String.Format("{0}\n{1}", yText, xText), font, textBrush, shadowBrush, xOffset, -3, format);

      SizeF size = graphics.MeasureString((xText.Length > yText.Length ? xText : yText) + "..", font);
      xOffset += size.Width / _resolution;
    }
  }