Ejemplo n.º 1
0
        private StringBuilder GetStringBuilder(DrawingLevel drawingLevel)
        {
            StringBuilder result = new StringBuilder();

            switch (drawingLevel)
            {
            case DrawingLevel.LevelOne:
                result = contentStringBuildLevel1;
                break;

            case DrawingLevel.LevelTwo:
                result = contentStringBuildLevel2;
                break;

            case DrawingLevel.LevelThree:
                result = contentStringBuildLevel3;
                break;

            case DrawingLevel.LevelFour:
                result = contentStringBuildLevel4;
                break;

            case DrawingLevel.LabelLevel:
                result = contentStringBuildLabelLevel;
                break;
            }
            return(result);
        }
Ejemplo n.º 2
0
        protected override void DrawTextCore(string text, GeoFont font, GeoBrush fillBrush, GeoPen haloPen, IEnumerable <ScreenPointF> textPathInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle, DrawingTextAlignment drawingTextAlignment)
        {
            int id = 0;

            if (fillBrush != null)
            {
                id = fillBrush.GetHashCode();
            }

            if (!styleUrlDictionary.ContainsKey(id))
            {
                string kmlStyle = GetTextStyleKml(id, ((GeoSolidBrush)fillBrush).Color, font.Size);
                kmlBuilder.Append(kmlStyle);
                styleUrlDictionary.Add(id, string.Format("<styleUrl>#{0}</styleUrl>", id));
            }

            StringBuilder contentStringBuilder = GetStringBuilder(drawingLevel);

            contentStringBuilder.AppendLine();
            contentStringBuilder.AppendLine(@"<Placemark>");
            contentStringBuilder.AppendLine(styleUrlDictionary[id]);
            text = text.Replace("<", "&lt;");
            text = text.Replace(">", "&gt;");
            text = text.Replace("`", "&apos;");
            text = text.Replace("\"", "&quot;");
            text = text.Replace("&", "&amp;");
            contentStringBuilder.AppendLine(@"<name>" + text + @"</name>");

            if (textPathInScreen.Count() > 1)
            {
                contentStringBuilder.AppendLine(@"<LineString>");

                contentStringBuilder.AppendLine(extrudeString);
                contentStringBuilder.AppendLine(tessellateString);
                contentStringBuilder.AppendLine(altitudeModeString);
                AppendCoordinates(textPathInScreen, xOffset, yOffset, contentStringBuilder);
                contentStringBuilder.AppendLine(@"</LineString>");
            }
            else
            {
                contentStringBuilder.AppendLine(@"<Point>");

                contentStringBuilder.AppendLine(extrudeString);
                contentStringBuilder.AppendLine(tessellateString);
                contentStringBuilder.AppendLine(altitudeModeString);
                AppendCoordinates(textPathInScreen, xOffset, yOffset, contentStringBuilder);
                contentStringBuilder.AppendLine(@"</Point>");
            }

            contentStringBuilder.AppendLine(@"</Placemark>");
        }
Ejemplo n.º 3
0
 protected override void DrawEllipseCore(ScreenPointF screenPoint, float width, float height, GeoPen outlinePen, GeoBrush fillBrush, DrawingLevel drawingLevel, float xOffset, float yOffset, PenBrushDrawingOrder penBrushDrawingOrder)
 {
     //throw new NotImplementedException();
     return;
 }
Ejemplo n.º 4
0
        protected override void DrawLineCore(IEnumerable <ScreenPointF> screenPoints, GeoPen linePen, DrawingLevel drawingLevel, float xOffset, float yOffset)
        {
            int id = linePen.GetHashCode();

            if (!styleUrlDictionary.ContainsKey(id))
            {
                string kmlStyle = GetLineStyleKml(id, linePen);
                kmlBuilder.Append(kmlStyle);
                styleUrlDictionary.Add(id, string.Format("<styleUrl>#{0}</styleUrl>", id));
            }

            StringBuilder contentStringBuilder = GetStringBuilder(drawingLevel);

            contentStringBuilder.AppendLine();
            contentStringBuilder.AppendLine(@"<Placemark>");
            contentStringBuilder.AppendLine(styleUrlDictionary[id]);
            contentStringBuilder.AppendLine(@"<LineString>");

            contentStringBuilder.AppendLine(extrudeString);
            contentStringBuilder.AppendLine(tessellateString);
            contentStringBuilder.AppendLine(altitudeModeString);

            AppendCoordinates(screenPoints, xOffset, yOffset, contentStringBuilder);
            contentStringBuilder.AppendLine(@"</LineString>");
            contentStringBuilder.AppendLine(@"</Placemark>");
        }
Ejemplo n.º 5
0
        protected override void DrawEllipseCore(ScreenPointF screenPoint, float width, float height, GeoPen outlinePen, GeoBrush fillBrush, DrawingLevel drawingLevel, float xOffset, float yOffset, PenBrushDrawingOrder penBrushDrawingOrder)
        {
            screenPoint = GetScreenPoint(screenPoint);

            GeoPen scaledPen = GetScaledPen(outlinePen);;

            canvas.DrawEllipse(new ScreenPointF(screenPoint.X, screenPoint.Y), width, height, scaledPen, fillBrush, drawingLevel, xOffset, yOffset, penBrushDrawingOrder);
        }
Ejemplo n.º 6
0
        protected override void DrawLineCore(IEnumerable <ScreenPointF> screenPoints, GeoPen linePen, DrawingLevel drawingLevel, float xOffset, float yOffset)
        {
            Collection <ScreenPointF> convertedPoints = new Collection <ScreenPointF>();

            foreach (ScreenPointF item in screenPoints)
            {
                convertedPoints.Add(GetScreenPoint(item));
            }

            GeoPen scaledPen = GetScaledPen(linePen);

            canvas.DrawLine(convertedPoints, scaledPen, drawingLevel, xOffset, yOffset);
        }
Ejemplo n.º 7
0
        protected override void DrawTextCore(string text, GeoFont font, GeoBrush fillBrush, GeoPen haloPen, IEnumerable <ScreenPointF> textPathInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle)
        {
            List <ScreenPointF> screenPoints = new List <ScreenPointF>();

            foreach (ScreenPointF screenPointF in textPathInScreen)
            {
                screenPoints.Add(GetScreenPoint(screenPointF));
            }

            GeoFont scaledFont = GetScaledFont(font);

            canvas.DrawText(text, scaledFont, fillBrush, haloPen, screenPoints, drawingLevel, xOffset, yOffset, rotateAngle);
        }
Ejemplo n.º 8
0
 protected override void DrawEllipseCore(ScreenPointF screenPoint, float width, float height, GeoPen outlinePen, GeoBrush fillBrush, DrawingLevel drawingLevel, float xOffset, float yOffset, PenBrushDrawingOrder penBrushDrawingOrder)
 {
     return;
 }
Ejemplo n.º 9
0
        protected override void DrawScreenImageCore(GeoImage image, float centerXInScreen, float centerYInScreen, float widthInScreen, float heightInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle)
        {
            ScreenPointF newCenterPoint = GetScreenPoint(new ScreenPointF(centerXInScreen, centerYInScreen));

            float newWidth  = (float)(GetScaledLength(widthInScreen));
            float newHeight = (float)(GetScaledLength(heightInScreen));

            canvas.DrawScreenImage(image, newCenterPoint.X, newCenterPoint.Y, newWidth, newHeight, drawingLevel, xOffset, yOffset, rotateAngle);
        }
Ejemplo n.º 10
0
 protected override void DrawScreenImageWithoutScalingCore(GeoImage image, float centerXInScreen, float centerYInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle)
 {
     DrawScreenImageCore(image, centerXInScreen, centerYInScreen, image.GetWidth(), image.GetHeight(), drawingLevel, xOffset, yOffset, rotateAngle);
 }
        protected override void DrawAreaCore(IEnumerable <ScreenPointF[]> screenPoints, GeoPen outlinePen, GeoBrush fillBrush, DrawingLevel drawingLevel, float xOffset, float yOffset, PenBrushDrawingOrder penBrushDrawingOrder)
        {
            var outline = screenPoints.FirstOrDefault();

            if (outline != null)
            {
                switch (outlineDrawMode)
                {
                case OutlineDrawMode.Open:
                    DrawLineCore(outline.Take(outline.Length - 1), outlinePen, drawingLevel, xOffset, yOffset);
                    break;

                case OutlineDrawMode.Dynamic:
                    DrawLineCore(outline.Skip(outline.Length - 3).Take(3), outlinePen, drawingLevel, xOffset, yOffset);
                    break;

                case OutlineDrawMode.Sealed:
                    DrawLineCore(outline, outlinePen, drawingLevel, xOffset, yOffset);
                    break;

                case OutlineDrawMode.LineWithFill:
                default:
                    base.DrawAreaCore(screenPoints, outlinePen, fillBrush, drawingLevel, xOffset, yOffset, penBrushDrawingOrder);
                    break;
                }
            }
        }
Ejemplo n.º 12
0
 protected override void DrawTextCore(string text, GeoFont font, GeoBrush fillBrush, GeoPen haloPen, IEnumerable <ScreenPointF> textPathInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle)
 {
     //StringBuilder rnSB = new StringBuilder();
     //rnSB.AppendLine("<Placemark>");
     //rnSB.AppendFormat("<description>{0}</description>", text);
     //rnSB.AppendFormat("<name>{0}</name>", text);
     //rnSB.AppendLine("<visibility>1</visibility>");
     //rnSB.AppendLine("<Point>");
     //AppendCoordinates(textPathInScreen,xOffset,yOffset,rnSB);
     ////rnSB.AppendFormat("<coordinates>{0},{1},20000</coordinates>",
     ////    ((ScreenPointF[])(textPathInScreen))[0].X,
     ////    ((ScreenPointF[])(textPathInScreen))[0].Y);
     //rnSB.AppendLine("</Point>");
     //rnSB.AppendLine("<Style><IconStyle><Icon><href></href></Icon></IconStyle></Style>");
     //rnSB.AppendLine("</Placemark>");
     //StringBuilder contentStringBuilder = GetStringBuilder(drawingLevel);
     //contentStringBuilder.Append(rnSB.ToString());
 }
Ejemplo n.º 13
0
        protected override void DrawAreaCore(IEnumerable <ScreenPointF[]> screenPoints, GeoPen outlinePen, GeoBrush fillBrush, DrawingLevel drawingLevel, float xOffset, float yOffset, PenBrushDrawingOrder penBrushDrawingOrder)
        {
            //if (fillBrush == null)
            //{
            //    fillBrush = new GeoSolidBrush(GeoColor.SimpleColors.Transparent);
            //}
            int id = 0;

            if (fillBrush != null)
            {
                id = fillBrush.GetHashCode();
            }
            else
            {
                id        = outlinePen.GetHashCode();
                fillBrush = new GeoSolidBrush(GeoColor.SimpleColors.Transparent);
            }

            if (!_styleUrlDictionary.ContainsKey(id))
            {
                string kmlStyle = GetPolygonStyleKml(id, outlinePen, ((GeoSolidBrush)fillBrush).Color);
                _kmlBuilder.Append(kmlStyle);
                _styleUrlDictionary.Add(id, string.Format("<styleUrl>#{0}</styleUrl>", id));
            }

            StringBuilder contentStringBuilder = GetStringBuilder(drawingLevel);

            contentStringBuilder.AppendLine();
            contentStringBuilder.AppendLine(@"<Placemark>");
            contentStringBuilder.AppendLine(_styleUrlDictionary[id]);
            contentStringBuilder.AppendLine(@"<Polygon>");

            contentStringBuilder.AppendLine(_extrudeString);
            contentStringBuilder.AppendLine(_tessellateString);
            contentStringBuilder.AppendLine(_altitudeModeString);

            bool firstCoordinates = true;

            foreach (ScreenPointF[] screenPoint in screenPoints)
            {
                if (firstCoordinates)
                {
                    contentStringBuilder.AppendLine(@"<outerBoundaryIs>");
                    AppendLinearRing(screenPoint, xOffset, yOffset, contentStringBuilder);
                    contentStringBuilder.AppendLine(@"</outerBoundaryIs>");
                    firstCoordinates = false;
                }
                else
                {
                    contentStringBuilder.AppendLine(@"<innerBoundaryIs>");
                    AppendLinearRing(screenPoint, xOffset, yOffset, contentStringBuilder);
                    contentStringBuilder.AppendLine(@"</innerBoundaryIs>");
                }
            }
            contentStringBuilder.AppendLine(@"</Polygon>");
            contentStringBuilder.AppendLine(@"</Placemark>");
        }
Ejemplo n.º 14
0
 protected override void DrawScreenImageWithoutScalingCore(GeoImage image, float centerXInScreen, float centerYInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
        protected override void DrawAreaCore(IEnumerable <ScreenPointF[]> screenPoints, GeoPen outlinePen, GeoBrush fillBrush, DrawingLevel drawingLevel, float xOffset, float yOffset, PenBrushDrawingOrder penBrushDrawingOrder)
        {
            foreach (ScreenPointF[] screenPointFs in screenPoints)
            {
                for (int i = 0; i < screenPointFs.Length; i++)
                {
                    screenPointFs[i] = GetScreenPoint(screenPointFs[i]);
                }
            }

            GeoPen scaledPen = GetScaledPen(outlinePen);

            canvas.DrawArea(screenPoints, scaledPen, fillBrush, drawingLevel, xOffset, yOffset, penBrushDrawingOrder);
        }
Ejemplo n.º 16
0
        protected override void DrawAreaCore(IEnumerable <ScreenPointF[]> screenPoints, GeoPen outlinePen, GeoBrush fillBrush, DrawingLevel drawingLevel, float xOffset, float yOffset, PenBrushDrawingOrder penBrushDrawingOrder)
        {
            if (fillBrush == null)
            {
                fillBrush = new GeoSolidBrush(GeoColor.SimpleColors.Transparent);
            }

            int id = 0;

            if (outlinePen != null)
            {
                id = outlinePen.GetHashCode();
            }
            else if (fillBrush != null)
            {
                id = id ^ fillBrush.GetHashCode();
            }

            if (!styleUrlDictionary.ContainsKey(id))
            {
                GeoSolidBrush          brush         = fillBrush as GeoSolidBrush;
                GeoLinearGradientBrush gradientBrush = fillBrush as GeoLinearGradientBrush;
                GeoHatchBrush          hatchBrush    = fillBrush as GeoHatchBrush;
                string kmlStyle = string.Empty;
                if (gradientBrush != null)
                {
                    kmlStyle = GetPolygonStyleKml(id, outlinePen, gradientBrush.StartColor);
                }
                else if (hatchBrush != null)
                {
                    kmlStyle = GetPolygonStyleKml(id, outlinePen, hatchBrush.BackgroundColor);
                }
                else
                {
                    kmlStyle = GetPolygonStyleKml(id, outlinePen, brush.Color);
                }
                kmlBuilder.Append(kmlStyle);
                styleUrlDictionary.Add(id, string.Format("<styleUrl>#{0}</styleUrl>", id));
            }

            StringBuilder contentStringBuilder = GetStringBuilder(drawingLevel);

            contentStringBuilder.AppendLine();
            contentStringBuilder.AppendLine(@"<Placemark>");
            contentStringBuilder.AppendLine(styleUrlDictionary[id]);
            contentStringBuilder.AppendLine(@"<Polygon>");

            contentStringBuilder.AppendLine(extrudeString);
            contentStringBuilder.AppendLine(tessellateString);
            contentStringBuilder.AppendLine(altitudeModeString);

            bool firstCoordinates = true;

            foreach (ScreenPointF[] screenPoint in screenPoints)
            {
                if (firstCoordinates)
                {
                    contentStringBuilder.AppendLine(@"<outerBoundaryIs>");
                    AppendLinearRing(screenPoint, xOffset, yOffset, contentStringBuilder);
                    contentStringBuilder.AppendLine(@"</outerBoundaryIs>");
                    firstCoordinates = false;
                }
                else
                {
                    contentStringBuilder.AppendLine(@"<innerBoundaryIs>");
                    AppendLinearRing(screenPoint, xOffset, yOffset, contentStringBuilder);
                    contentStringBuilder.AppendLine(@"</innerBoundaryIs>");
                }
            }
            contentStringBuilder.AppendLine(@"</Polygon>");
            contentStringBuilder.AppendLine(@"</Placemark>");

            foreach (ScreenPointF[] screenPoint in screenPoints)
            {
                switch (Mode)
                {
                case AltitudeMode.Absolute:
                case AltitudeMode.RelativeToGround:
                    contentStringBuilder.AppendLine(@"<Placemark>");
                    AppendLinearRing(screenPoint, xOffset, yOffset, ZHeight, contentStringBuilder);
                    contentStringBuilder.AppendLine(@"</Placemark>");
                    break;

                default:
                    break;
                }
            }
        }
        protected override void DrawLineCore(IEnumerable <ScreenPointF> screenPoints, GeoPen linePen, DrawingLevel drawingLevel, float xOffset, float yOffset)
        {
            switch (outlineDrawMode)
            {
            case OutlineDrawMode.Open:
                var tmpScreenPoints = screenPoints.ToArray();
                base.DrawLineCore(tmpScreenPoints.Take(tmpScreenPoints.Length - 1), linePen, drawingLevel, xOffset, yOffset);
                break;

            default:
                base.DrawLineCore(screenPoints, linePen, drawingLevel, xOffset, yOffset);
                break;
            }
        }