public DotDensityLegendItem(int dotCount)
     : base()
 {
     DotCount   = dotCount;
     LabelFont  = new GeoFont("Arial", 20, DrawingFontStyles.Bold);
     LabelBrush = new GeoSolidBrush(GeoColor.FromArgb(180, GeoColor.FromHtml("#d3d3d3")));
 }
Exemple #2
0
        protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers)
        {
            if (String.IsNullOrEmpty(projectPath))
            {
                return;
            }
            base.DrawCore(canvas, labelsInAllLayers);

            double         oneToOneScale      = PrinterHelper.GetPointsPerGeographyUnit(canvas.MapUnit);
            RectangleShape currentBoundingBox = GetBoundingBox();

            string drawingText = projectPath;

            if (printerWrapMode == PrinterWrapMode.WrapText)
            {
                float drawingSize = (float)(Font.Size * oneToOneScale / canvas.CurrentScale);
                drawingFont = new GeoFont(Font.FontName, drawingSize, Font.Style);

                drawingText = WrapText(canvas, currentBoundingBox, drawingFont, projectPath);
            }
            else
            {
                // 1st time draw the layer, change the fontsize to match up the boundingBox
                if (lastBoundingBox == null)
                {
                    float drawingSize = font.Size;
                    if (currentBoundingBox.GetWellKnownText() != new RectangleShape().GetWellKnownText())
                    {
                        drawingSize = GetFontSizeByBoundingBox(canvas, Font, drawingText, currentBoundingBox);
                    }
                    drawingFont = new GeoFont(font.FontName, drawingSize, font.Style);

                    drawingSize = (float)(drawingSize / oneToOneScale * canvas.CurrentScale);
                    Font        = new GeoFont(font.FontName, drawingSize, font.Style);
                }
                else
                {
                    // change the boundingBox, change the fontsize to match up the boundingBox
                    if ((Math.Round(lastBoundingBox.Width, 8) != Math.Round(currentBoundingBox.Width, 8)) ||
                        (Math.Round(lastBoundingBox.Height, 8) != Math.Round(currentBoundingBox.Height, 8)))     // Change font size when resize
                    {
                        float drawingSize = GetFontSizeByBoundingBox(canvas, drawingFont, drawingText, currentBoundingBox);
                        drawingFont = new GeoFont(font.FontName, drawingSize, font.Style);

                        drawingSize = (float)(drawingSize / oneToOneScale * canvas.CurrentScale);
                        Font        = new GeoFont(font.FontName, drawingSize, font.Style);
                    }
                    else
                    {
                        float drawingSize = (float)(Font.Size * oneToOneScale / canvas.CurrentScale);
                        drawingFont = new GeoFont(font.FontName, drawingSize, font.Style);
                    }
                }

                lastBoundingBox = currentBoundingBox;
            }

            canvas.DrawTextWithWorldCoordinate(drawingText, drawingFont, TextBrush, currentBoundingBox.GetCenterPoint().X, currentBoundingBox.GetCenterPoint().Y, DrawingLevel.LabelLevel);
        }
Exemple #3
0
        protected override DrawingRectangleF MeasureTextCore(string text, GeoFont font)
        {
            PlatformGeoCanvas canvas = new PlatformGeoCanvas();

            canvas.BeginDrawing(new Bitmap((int)virtualMapWidth, (int)virtualMapHeight), virtualWorldExtent, MapUnit);

            return(canvas.MeasureText(text, font));
        }
Exemple #4
0
        protected override DrawingRectangleF MeasureTextCore(string text, GeoFont font)
        {
            Font f                = new Font(new FontFamily("Arial"), font.Size);
            Size size             = TextRenderer.MeasureText(text, f);
            DrawingRectangleF drf = new DrawingRectangleF(0, 0, size.Width, size.Height);

            return(drf);
        }
 public void FromGeoFont(GeoFont geoFont)
 {
     IsBold      = geoFont.IsBold;
     IsItalic    = geoFont.IsItalic;
     IsStrike    = geoFont.IsStrikeout;
     IsUnderline = geoFont.IsUnderline;
     FontName    = geoFont.FontName;
     FontSize    = (int)geoFont.Size;
 }
Exemple #6
0
 public SquareTextPointStyle()
 {
     SymbolType = PointSymbolType.Square;
     SymbolSize = 30;
     PointType  = PointType.Symbol;
     font       = new GeoFont("Verdana", 14);
     textBrush  = new GeoSolidBrush(GeoColor.StandardColors.White);
     SymbolPen  = new GeoPen(GeoColor.StandardColors.White, 1);
 }
        private void mapView_Loaded(object sender, RoutedEventArgs e)
        {
            GeoFont geoFont = new GeoFont("unicode", 8);
            var     random  = new Random();

            var inMemoryFeatureLayer1 = new InMemoryFeatureLayer();

            for (var i = 0; i < 100000; i++)
            {
                var feature = new Feature(random.Next(-1000000, 1000000), random.Next(-1000000, 1000000));
                inMemoryFeatureLayer1.InternalFeatures.Add(feature);
            }

            inMemoryFeatureLayer1.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = new PointStyle(geoFont, startGlyphContent, GeoBrushes.Black);
            inMemoryFeatureLayer1.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;


            var inMemoryFeatureLayer2 = new InMemoryFeatureLayer();

            foreach (var feature in inMemoryFeatureLayer1.InternalFeatures)
            {
                inMemoryFeatureLayer2.InternalFeatures.Add(feature);
            }

            var clusterStyle = new ClusterPointStyle(new PointStyle(geoFont, startGlyphContent, GeoBrushes.Red), new TextStyle("FeatureCount", geoFont, new GeoSolidBrush(GeoColors.White)));

            clusterStyle.DrawingClusteredFeature += ClusterStyle_DrawingClusteredFeature;
            clusterStyle.CellSize = 100;
            clusterStyle.MinimumFeaturesPerCellToCluster = 10;

            inMemoryFeatureLayer2.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(clusterStyle);
            inMemoryFeatureLayer2.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            var layerOverlay1 = new LayerOverlay();

            layerOverlay1.Layers.Add(inMemoryFeatureLayer1);

            var layerOverlay2 = new LayerOverlay()
            {
                TileType = TileType.SingleTile
            };

            layerOverlay2.Layers.Add(inMemoryFeatureLayer2);

            var backgroundOverlay = new BackgroundOverlay()
            {
                BackgroundBrush = new GeoSolidBrush(GeoColors.LightGray)
            };

            mapView.Overlays.Add(backgroundOverlay);
            mapView.Overlays.Add(layerOverlay1);
            mapView.Overlays.Add(layerOverlay2);

            mapView.MapUnit       = GeographyUnit.Meter;
            mapView.CurrentExtent = new RectangleShape(-100000, 100000, 100000, -100000);
        }
 public CustomStartEndLineStyle(string startFontName, int startCharacterIndex, Color startColor, float startSize,
                                string endFontName, int endCharacterIndex, Color endColor, float endSize,
                                Color lineColor, float lineSize)
 {
     var startFont = new GeoFont(startFontName, startSize);
     var endFont = new GeoFont(endFontName, endSize);
     _startPointStyle = new PointStyle(startFont, startCharacterIndex, new GeoSolidBrush(GeoColor.FromArgb(startColor.A, startColor.R, startColor.G, startColor.B)));
     _endPointStyle = new PointStyle(endFont, endCharacterIndex, new GeoSolidBrush(GeoColor.FromArgb(endColor.A, endColor.R, endColor.G, endColor.B)));
     _lineStyle = new LineStyle(new GeoPen(GeoColor.FromArgb(lineColor.A, lineColor.R, lineColor.G, lineColor.B), lineSize));
 }
Exemple #9
0
        private GeoFont GetScaledFont(GeoFont geoFont)
        {
            GeoFont rtn = geoFont;

            if (rtn != null)
            {
                float newSize = (float)(rtn.Size / (canvas.CurrentScale) * pageBaseUnitToPageUnitRatio);
                rtn = new GeoFont(rtn.FontName, newSize, rtn.Style);
            }

            return(rtn);
        }
Exemple #10
0
        private static Font GetGdiPlusFontFromGeoFont(GeoFont font)
        {
            if (font == null)
            {
                return(null);
            }

            FontStyle gdiplusFontStyle = GetFontStyleFromDrawingFontStyle(font.Style);

            Font resultFont = new Font(font.FontName, font.Size, gdiplusFontStyle);

            return(resultFont);
        }
Exemple #11
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);
        }
Exemple #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, 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>");
        }
Exemple #13
0
 public WindPointStyle(string textColumn, string levelColumn, string angleColumn, GeoColor fillColor)
 {
     this.directionLineLength1 = 40;
     this.directionLineLength2 = 10;
     this.blackBrush           = new GeoSolidBrush(GeoColor.SimpleColors.Black);
     this.font            = new GeoFont("Verdana", 10);
     this.textBrush       = new GeoSolidBrush(GeoColor.StandardColors.Black);
     this.fillBrush       = new GeoSolidBrush(fillColor);
     this.outlinePen      = new GeoPen(GeoColor.StandardColors.Black, 4);
     this.innerlinePen    = new GeoPen(fillBrush, 2);
     this.textColumn      = textColumn;
     this.windLevelColumn = levelColumn;
     this.angleColumn     = angleColumn;
 }
        public void UpdateOverlay(Map map, GeoCollection <object> args)
        {
            var          layerName = args["layer"].ToString();
            LayerOverlay overlay   = map.CustomOverlays["ShapeOverlay"] as LayerOverlay;

            overlay.Layers.Clear();
            if (layerName.ToLowerInvariant() == "us")
            {
                // States layer
                ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Server.MapPath("~/App_Data/USStates.SHP"));
                AreaStyle             areaStyle  = new AreaStyle();
                areaStyle.FillSolidBrush       = new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214));
                areaStyle.OutlinePen           = new GeoPen(GeoColor.FromArgb(255, 156, 155, 154), 2);
                areaStyle.OutlinePen.DashStyle = LineDashStyle.Solid;
                worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = areaStyle;
                worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                overlay.Layers.Add(worldLayer);
            }
            else
            {
                // Cities layer
                ShapeFileFeatureLayer countyLayer = new ShapeFileFeatureLayer(Server.MapPath("~/App_Data/cities_e.shp"));
                PointStyle            pointStyle  = new PointStyle();
                pointStyle.SymbolType       = PointSymbolType.Square;
                pointStyle.SymbolSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.White);
                pointStyle.SymbolPen        = new GeoPen(GeoColor.StandardColors.Black, 1);
                pointStyle.SymbolSize       = 6;

                PointStyle stackStyle = new PointStyle();
                stackStyle.SymbolType       = PointSymbolType.Square;
                stackStyle.SymbolSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.Maroon);
                stackStyle.SymbolPen        = new GeoPen(GeoColor.StandardColors.Transparent, 0);
                stackStyle.SymbolSize       = 2;

                pointStyle.CustomPointStyles.Add(stackStyle);
                GeoFont       font      = new GeoFont("Arial", 9, DrawingFontStyles.Bold);
                GeoSolidBrush txtBrush  = new GeoSolidBrush(GeoColor.StandardColors.Maroon);
                TextStyle     textStyle = new TextStyle("NAME", font, txtBrush);
                textStyle.XOffsetInPixel = 0;
                textStyle.YOffsetInPixel = -6;
                countyLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = pointStyle;
                countyLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle    = textStyle;
                countyLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                overlay.Layers.Add(countyLayer);
            }
        }
Exemple #15
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());
 }
        private static ValueStyle GetIconStyle(string imagePath)
        {
            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = "TYPE";

            GeoFont       font  = new GeoFont("Arial", 9);
            GeoSolidBrush brush = new GeoSolidBrush(GeoColor.StandardColors.Black);

            valueStyle.ValueItems.Add(new ValueItem("1", new IconStyle(imagePath + "vehicle1.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("2", new IconStyle(imagePath + "vehicle2.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("3", new IconStyle(imagePath + "vehicle3.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("4", new IconStyle(imagePath + "vehicle4.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("5", new IconStyle(imagePath + "vehicle5.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("6", new IconStyle(imagePath + "vehicle6.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("7", new IconStyle(imagePath + "vehicle7.png", "Type", font, brush)));

            return(valueStyle);
        }
Exemple #17
0
        internal static void RaiseDrawingException <T>(string name, object sender, EventArgs e)
        {
            DrawingExceptionLayerEventArgs       drawingExceptionLayerEventArgs       = e as DrawingExceptionLayerEventArgs;
            DrawingExceptionTileOverlayEventArgs drawingExceptionTileOverlayEventArgs = e as DrawingExceptionTileOverlayEventArgs;

            if (!sender.Equals(default(T)))
            {
                var message = string.Format(CultureInfo.InvariantCulture, ConnectionFailed, name);
                var font    = new GeoFont("Arial", 10, DrawingFontStyles.Italic);

                if (drawingExceptionLayerEventArgs != null)
                {
                    if (drawingExceptionLayerEventArgs.Canvas.ClippingArea != null)
                    {
                        var clippingCenter = drawingExceptionLayerEventArgs.Canvas.ClippingArea.GetCenterPoint();
                        drawingExceptionLayerEventArgs.Canvas.DrawTextWithWorldCoordinate(message, font, new GeoSolidBrush(GeoColor.StandardColors.GrayText), clippingCenter.X, clippingCenter.Y, DrawingLevel.LabelLevel);
                        drawingExceptionLayerEventArgs.Cancel = true;
                    }
                    else
                    {
                        var drawingArea = drawingExceptionLayerEventArgs.Canvas.MeasureText(message, font);
                        drawingExceptionLayerEventArgs.Canvas.DrawTextWithScreenCoordinate(message, font, new GeoSolidBrush(GeoColor.StandardColors.GrayText), 20 + drawingArea.Width * .5f, 20 + drawingArea.Height * .5f, DrawingLevel.LabelLevel);
                        drawingExceptionLayerEventArgs.Cancel = true;
                    }
                }
                else if (drawingExceptionTileOverlayEventArgs != null)
                {
                    if (drawingExceptionTileOverlayEventArgs.Canvas.ClippingArea != null)
                    {
                        var clippingCenter = drawingExceptionTileOverlayEventArgs.Canvas.ClippingArea.GetCenterPoint();
                        drawingExceptionTileOverlayEventArgs.Canvas.DrawTextWithWorldCoordinate(message, font, new GeoSolidBrush(GeoColor.StandardColors.GrayText), clippingCenter.X, clippingCenter.Y, DrawingLevel.LabelLevel);
                        drawingExceptionTileOverlayEventArgs.Cancel = true;
                    }
                    else
                    {
                        var drawingArea = drawingExceptionTileOverlayEventArgs.Canvas.MeasureText(message, font);
                        drawingExceptionTileOverlayEventArgs.Canvas.DrawTextWithScreenCoordinate(message, font, new GeoSolidBrush(GeoColor.StandardColors.GrayText), 20 + drawingArea.Width * .5f, 20 + drawingArea.Height * .5f, DrawingLevel.LabelLevel);
                        drawingExceptionTileOverlayEventArgs.Cancel = true;
                    }
                }
            }
        }
Exemple #18
0
        public static void LoadFromViewModel(this DataGridPrinterLayer dataGridPrinterLayer, DataGridViewModel dataGridEntity)
        {
            DrawingFontStyles drawingFontStyles = DrawingFontStyles.Regular;

            if (dataGridEntity.IsBold)
            {
                drawingFontStyles = drawingFontStyles | DrawingFontStyles.Bold;
            }
            if (dataGridEntity.IsItalic)
            {
                drawingFontStyles = drawingFontStyles | DrawingFontStyles.Italic;
            }
            if (dataGridEntity.IsStrikeout)
            {
                drawingFontStyles = drawingFontStyles | DrawingFontStyles.Strikeout;
            }
            if (dataGridEntity.IsUnderline)
            {
                drawingFontStyles = drawingFontStyles | DrawingFontStyles.Underline;
            }

            GeoFont geoFont = new GeoFont(dataGridEntity.FontName.Source, dataGridEntity.FontSize, drawingFontStyles);

            dataGridPrinterLayer.TextFont = geoFont;

            int originalCount = dataGridEntity.CurrentDataTable.Rows.Count;

            dataGridPrinterLayer.DataTable = dataGridEntity.CurrentDataTable.DefaultView.ToTable();
            int currentCount = dataGridPrinterLayer.DataTable.Rows.Count;

            //Todo:remove the last row which is all empty value;
            if (originalCount != currentCount)
            {
                dataGridPrinterLayer.DataTable.Rows.RemoveAt(currentCount - 1);
            }

            dataGridPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColor.StandardColors.Black, 1));
            dataGridPrinterLayer.TextBrush      = dataGridEntity.FontColor;
            dataGridPrinterLayer.DragMode       = dataGridEntity.DragMode;
            dataGridPrinterLayer.ResizeMode     = dataGridEntity.ResizeMode;
        }
Exemple #19
0
        protected override DrawingRectangleF MeasureTextCore(string text, GeoFont font)
        {
            Bitmap   bitmap   = null;
            Graphics graphics = null;
            SizeF    size;

            try
            {
                bitmap = new Bitmap(1, 1);
                bitmap.SetResolution(Dpi, Dpi);
                graphics = Graphics.FromImage(bitmap);

                size = graphics.MeasureString(text, GetGdiPlusFontFromGeoFont(font), new PointF(), StringFormat.GenericTypographic);
                if (size.Width == 0 && size.Height != 0 && text.Length != 0)
                {
                    size.Width = 1;
                }
            }
            catch (Exception ex)
            {
                GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                size = new SizeF(1, 1);
            }
            finally
            {
                if (graphics != null)
                {
                    graphics.Dispose();
                }
                if (bitmap != null)
                {
                    bitmap.Dispose();
                }
            }

            DrawingRectangleF drawingRectangleF = new DrawingRectangleF(size.Width / 2, size.Height / 2, size.Width, size.Height);

            return(drawingRectangleF);
        }
Exemple #20
0
        private float GetFontSizeByBoundingBox(GeoCanvas canvas, GeoFont font, string drawingText, RectangleShape boundingBox)
        {
            float rtn = font.Size;

            ScreenPointF boundingBoxPointFUL = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, boundingBox.UpperLeftPoint, canvas.Width, canvas.Height);
            ScreenPointF boundingBoxPointFUR = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, boundingBox.UpperRightPoint, canvas.Width, canvas.Height);
            ScreenPointF boundingBoxPointFLL = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, boundingBox.LowerLeftPoint, canvas.Width, canvas.Height);

            double widthInScreen  = boundingBoxPointFUR.X - boundingBoxPointFUL.X;
            double heightInScreen = boundingBoxPointFLL.Y - boundingBoxPointFUL.Y;

            DrawingRectangleF textRectInScreen = canvas.MeasureText(drawingText, font);

            if (textRectInScreen.Width > widthInScreen || textRectInScreen.Height > heightInScreen)
            {
                while (textRectInScreen.Width > widthInScreen || textRectInScreen.Height > heightInScreen)
                {
                    rtn = rtn * 9 / 10;
                    textRectInScreen = canvas.MeasureText(drawingText, new GeoFont(font.FontName, rtn, font.Style));
                }
            }
            else
            {
                while (textRectInScreen.Width < widthInScreen && textRectInScreen.Height < heightInScreen)
                {
                    rtn = rtn * 10 / 9;
                    textRectInScreen = canvas.MeasureText(drawingText, new GeoFont(font.FontName, rtn, font.Style));
                }
                rtn = rtn * 9 / 10;
            }
            if (rtn > maxFontSize)
            {
                rtn = maxFontSize;
            }

            return(rtn);
        }
Exemple #21
0
        private void Map1_Loaded(object sender, RoutedEventArgs e)
        {
            Map1.MapUnit = GeographyUnit.DecimalDegree;

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"../../Data/Countries02.shp");
            AreaStyle             areaStyle  = new AreaStyle();

            areaStyle.FillSolidBrush       = new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214));
            areaStyle.OutlinePen           = new GeoPen(GeoColor.FromArgb(255, 118, 138, 69), 1);
            areaStyle.OutlinePen.DashStyle = LineDashStyle.Solid;

            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = areaStyle;
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            PointStyle pointStyle = new PointStyle();

            pointStyle.SymbolType       = PointSymbolType.Square;
            pointStyle.SymbolSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.White);
            pointStyle.SymbolPen        = new GeoPen(GeoColor.StandardColors.Black, 1);
            pointStyle.SymbolSize       = 6;

            PointStyle stackStyle = new PointStyle();

            stackStyle.SymbolType       = PointSymbolType.Square;
            stackStyle.SymbolSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.Maroon);
            stackStyle.SymbolPen        = new GeoPen(GeoColor.StandardColors.Transparent, 0);
            stackStyle.SymbolSize       = 2;

            pointStyle.CustomPointStyles.Add(stackStyle);
            ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(@"../../Data/WorldCapitals.shp");

            // We can customize our own Style. Here we passed in a color and a size.
            capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.White, 7, GeoColor.StandardColors.Brown);
            // The Style we set here is available from ZoomLevel01 to ZoomLevel05. That means if we zoom in a bit more, the appearance we set here will not be visible anymore.
            capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;


            capitalLayer.ZoomLevelSet.ZoomLevel06.DefaultPointStyle = pointStyle;
            // The Style we set here is available from ZoomLevel06 to ZoomLevel20. That means if we zoom out a bit more, the appearance we set here will not be visible any more.
            capitalLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer capitalLabelLayer = new ShapeFileFeatureLayer(@"../../Data/WorldCapitals.shp");
            // We can customize our own TextStyle. Here we passed in the font, the size, the style and the color.
            GeoFont       font      = new GeoFont("Arial", 9, DrawingFontStyles.Bold);
            GeoSolidBrush txtBrush  = new GeoSolidBrush(GeoColor.StandardColors.Maroon);
            TextStyle     textStyle = new TextStyle("CITY_NAME", font, txtBrush);

            textStyle.XOffsetInPixel = 0;
            textStyle.YOffsetInPixel = -6;
            capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("CITY_NAME", "Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
            // The TextStyle we set here is available from ZoomLevel01 to ZoomLevel05.
            capitalLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;

            capitalLabelLayer.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = textStyle;
            // The TextStyle we set here is available from ZoomLevel06 to ZoomLevel20.
            capitalLabelLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)));
            layerOverlay.Layers.Add(worldLayer);
            layerOverlay.Layers.Add(capitalLayer);
            layerOverlay.Layers.Add(capitalLabelLayer);

            Map1.Overlays.Add(layerOverlay);
            Map1.CurrentExtent = new RectangleShape(-136.60, 60.06, -53.81, 11.63);
            Map1.Refresh();
        }
 public CustomTextStyle(string textColumnName, GeoFont textFont, GeoBrush textBrush)
     : base(textColumnName, textFont, textBrush)
 {
 }
Exemple #23
0
 public CustomTextStyle(string textColumnName, GeoFont textFont, GeoSolidBrush textSolidBrush)
     : base(textColumnName, textFont, textSolidBrush)
 {
     this.minFontSize = 8;
     this.MaxFontSize = 25;
 }
Exemple #24
0
        private static string WrapText(GeoCanvas canvas, RectangleShape drawingBoundingBox, GeoFont drawingFont, string text)
        {
            StringBuilder sb = new StringBuilder();

            //ScreenPointF textCenterOnScreen = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, drawingBoundingBox.GetCenterPoint(), canvas.Width, canvas.Height);
            DrawingRectangleF drawingRect        = canvas.MeasureText(text, drawingFont);
            ScreenPointF      upperLeftOnScreen  = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, drawingBoundingBox.UpperLeftPoint, canvas.Width, canvas.Height);
            ScreenPointF      lowerRightOnScreen = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, drawingBoundingBox.UpperRightPoint, canvas.Width, canvas.Height);
            int drawingRectWidthOnScreen         = (int)(lowerRightOnScreen.X - upperLeftOnScreen.X);

            Graphics  g         = Graphics.FromImage(new Bitmap(1, 1));
            FontStyle fontStyle = GetFontStyleFromDrawingFontStyle(drawingFont.Style);

            SizeF textSize = g.MeasureString(text, new Font(drawingFont.FontName, drawingFont.Size, fontStyle), new PointF(), StringFormat.GenericTypographic);

            if (drawingRect.Width > drawingRectWidthOnScreen)
            {
                text = text.Replace("\n", " ");
                text = text.Replace("\r", " ");
                text = text.Replace(".", ". ");
                text = text.Replace(">", "> ");
                text = text.Replace("\t", " ");
                text = text.Replace(",", ", ");
                text = text.Replace(";", "; ");
                text = text.Replace("<br>", " ");

                int      maxStringLength = GetMaxStringLength(text, textSize.Width, drawingRectWidthOnScreen);
                string[] texts           = Wrap(text, maxStringLength);
                foreach (string item in texts)
                {
                    if (item == "")
                    {
                        sb.Append(item);
                    }
                    else
                    {
                        sb.AppendLine(item);
                    }
                }
            }
            else
            {
                sb.Append(text);
            }

            return(sb.ToString());
        }
 public IconTextStyle(GeoImage iconImage, string textColumnName, GeoFont textFont, GeoSolidBrush textSolidBrush)
     : base(iconImage, textColumnName, textFont, textSolidBrush)
 {
     Initialize();
 }
 public IconTextStyle(string iconPathFilename, string textColumnName, GeoFont textFont, GeoSolidBrush textSolidBrush)
     : base(iconPathFilename, textColumnName, textFont, textSolidBrush)
 {
     Initialize();
 }