Example #1
0
        public MainPage()
        {
            InitializeComponent();

            MapView mapView = new MapView();

            Content = mapView;

            mapView.MapUnit = GeographyUnit.DecimalDegree;
            GeoImage        textureSource = new GeoImage(typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("TextureDemo.Images.texture.png"));
            GeoTextureBrush textureBrush  = new GeoTextureBrush(textureSource);

            InMemoryFeatureLayer layer = new InMemoryFeatureLayer();

            layer.InternalFeatures.Add(new Feature(new EllipseShape(new PointShape(0, 0), 60)));
            layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.County2;
            layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.Advanced.FillCustomBrush = textureBrush;
            layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(layer);
            mapView.Overlays.Add(layerOverlay);

            mapView.CurrentExtent = new RectangleShape(-180, 90, 180, -90);
        }
Example #2
0
 public WeatherLineStyle(LineStyle lineStyle, GeoImage GeoImage, int imageSpacing, ImageDirection imageDirection)
 {
     this.lineStyle      = lineStyle;
     this.geoImage       = GeoImage;
     this.imageSpacing   = imageSpacing;
     this.imageDirection = imageDirection;
 }
Example #3
0
        protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers)
        {
            Collection <string> urls = GetRequestUrl(canvas.CurrentWorldExtent, (int)canvas.Width, (int)canvas.Height);
            string currentUrl        = urls[random.Next(0, urls.Count - 1)];

            bool isSuccess   = false;
            int  failedCount = 0;

            while (!isSuccess && failedCount < 2)
            {
                try
                {
                    currentUrl = SignUrl(currentUrl, PrivateKey);
                    HttpWebRequest myWebRequest = (HttpWebRequest)WebRequest.Create(currentUrl);
                    myWebRequest.Timeout = TimeoutInSecond * 1000;
                    myWebRequest.Proxy   = WebProxy;
                    WebResponse response    = myWebRequest.GetResponse();
                    Stream      stream      = response.GetResponseStream();
                    GeoImage    geoImage    = new GeoImage(stream);
                    PointShape  centerPoint = canvas.CurrentWorldExtent.GetCenterPoint();
                    canvas.DrawWorldImage(geoImage, centerPoint.X, centerPoint.Y, canvas.Width, canvas.Height, DrawingLevel.LevelOne);
                    isSuccess = true;
                }
                catch
                {
                    failedCount++;
                }
            }
        }
Example #4
0
        private static PointStyle GetCurrentVehicleStyle(string iconVirtualPath)
        {
            Stream   vehicleStream = MapSuiteSampleHelper.GetResourceStream(iconVirtualPath);
            GeoImage vehicleImage  = new GeoImage(vehicleStream);

            return(new PointStyle(vehicleImage));
        }
        private static GeoImage GetGeoImageFromResource(string path)
        {
            var      stream = Application.GetResourceStream(new Uri(path, UriKind.RelativeOrAbsolute)).Stream;
            GeoImage image  = new GeoImage(stream);

            return(image);
        }
Example #6
0
        private ImageSource GenerateMapImage()
        {
            Collection <Layer> layersToDraw = new Collection <Layer>();

            // Create the background world maps using vector tiles stored locally in our MBTiles file and also set the styling though a json file
            ThinkGeoMBTilesLayer mbTilesLayer = new ThinkGeoMBTilesLayer(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Data/Mbtiles/Frisco.mbtiles"), new Uri(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Data/Json/thinkgeo-world-streets-light.json"), UriKind.Relative));

            mbTilesLayer.Open();
            layersToDraw.Add(mbTilesLayer);

            // Create the new layer and set the projection as the data is in srid 2276 and our background is srid 3857 (spherical mercator).
            ShapeFileFeatureLayer zoningLayer = new ShapeFileFeatureLayer(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Data/Shapefile/Zoning.shp"));

            zoningLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857);
            zoningLayer.Open();

            // Create an Area style on zoom level 1 and then apply it to all zoom levels up to 20.
            zoningLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoBrushes.Blue));
            zoningLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            layersToDraw.Add(zoningLayer);

            // Create a GeoCanvas to do the drawing
            GeoCanvas canvas = GeoCanvas.CreateDefaultGeoCanvas();

            // Create a GeoImage as the image to draw on
            GeoImage geoImage = new GeoImage(800, 600);

            // Start the drawing by specifying the image, extent and map units
            canvas.BeginDrawing(geoImage, MapUtil.GetDrawingExtent(zoningLayer.GetBoundingBox(), 800, 600), GeographyUnit.Meter);

            // This collection is used during drawing to pass labels in between layers so we can track collisions
            Collection <SimpleCandidate> labels = new Collection <SimpleCandidate>();

            // Loop through all the layers and draw them to the GeoCanvas
            // The flush is to compact styles that use different drawing levels
            foreach (var layer in layersToDraw)
            {
                layer.Draw(canvas, labels);
                canvas.Flush();
            }

            // End drawing, we can now use the GeoImage
            canvas.EndDrawing();

            // Create a memory stream and save the GeoImage as a standard PNG formatted image
            MemoryStream imageStream = new MemoryStream();

            geoImage.Save(imageStream, GeoImageFormat.Png);

            // Reset the image stream back to the beginning
            imageStream.Position = 0;

            return(ImageSource.FromStream(() =>
            {
                return imageStream;
            }));
        }
Example #7
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);
        }
Example #8
0
        public RstReader(string filename)
        {
            _geoImage = IGeoImage.GeoOpen(filename);
            GeoImage g = _geoImage as GeoImage;

            _fullEnvelope      = new Envelope(g.MinX, g.MinY, g.MaxX, g.MaxY);
            _coordType         = g.IsProjected ? enumCoordinateType.Projection : enumCoordinateType.Geographic;
            _sref              = SpatialReferenceFactory.GetSpatialReferenceByWKT(g.ProjectDescription, enumWKTSource.GDAL);
            _byteCountPerPixel = GetBandCount(_geoImage.DataType);
        }
Example #9
0
        private void SetLayerProperties()
        {
            GeoImage image = new GeoImage(txtPath.Text);

            imagePrinterLayer.Image = image;

            imagePrinterLayer.Open();
            PointShape centerPoint = imagePrinterLayer.GetPosition().GetCenterPoint();

            imagePrinterLayer.SetPosition(image.Width, image.Height, centerPoint, PrintingUnit.Point);
        }
Example #10
0
        //In the MouseDoubleClick event, we allow adding a new draggable icon by left double clicking on the map and
        //removing an icon by right double clicking.
        private void winformsMap1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            winformsMap1.EditOverlay.EditShapesLayer.Open();
            PointShape clickedPointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, e.X, e.Y, winformsMap1.Width, winformsMap1.Height);

            //For removing the icon clicked on.
            if (e.Button == MouseButtons.Right)
            {
                Collection <Feature> clickedFeatures = winformsMap1.EditOverlay.EditShapesLayer.QueryTools.GetFeaturesNearestTo(clickedPointShape, GeographyUnit.DecimalDegree, 1,
                                                                                                                                ReturningColumnsType.AllColumns);
                winformsMap1.EditOverlay.EditShapesLayer.Close();

                if (clickedFeatures.Count > 0)
                {
                    //Gets the dimension of the icon and checks if the clicked point is inside it.
                    ValueStyle valueStyle = (ValueStyle)winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles[0];
                    //we loop thru the different ValueItem to get the appropriate icon according to the "Type".
                    GeoImage geoImage = null;
                    string   text     = clickedFeatures[0].ColumnValues["Type"].Trim();
                    foreach (ValueItem valueItem in valueStyle.ValueItems)
                    {
                        if (text == valueItem.Value)
                        {
                            geoImage = (GeoImage)valueStyle.ValueItems[0].DefaultPointStyle.Image;
                            break;
                        }
                    }
                    //We check to see if we clicked inside the icon itself.
                    ScreenPointF screenPointF = ExtentHelper.ToScreenCoordinate(winformsMap1.CurrentExtent, clickedFeatures[0], winformsMap1.Width, winformsMap1.Height);
                    RectangleF   rectangleF   = new RectangleF(screenPointF.X - (geoImage.GetWidth() / 2), screenPointF.Y - (geoImage.GetHeight() / 2),
                                                               geoImage.GetWidth(), geoImage.GetHeight());
                    bool IsInside = rectangleF.Contains(new PointF(e.X, e.Y));

                    //If inside, removes the feature from the EditShapesLayer of the EditOverlay.
                    if (IsInside == true)
                    {
                        winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Remove(clickedFeatures[0]);
                        winformsMap1.Refresh(winformsMap1.EditOverlay);
                    }
                }
            }
            //Adding a new icon.
            else if (e.Button == MouseButtons.Left)
            {
                Feature carFeature = new Feature(clickedPointShape);
                carFeature.ColumnValues["Type"] = "Unknown";
                //We use DateTime.Now.Ticks to be sure to use a unique key each time we add a new feature.
                winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(DateTime.Now.Ticks.ToString(), carFeature);
                //We call CalculateAllControlPoints to update the control points with the new feature to be able to drag the newly added feature.
                winformsMap1.EditOverlay.CalculateAllControlPoints();
                winformsMap1.Refresh(winformsMap1.EditOverlay);
            }
        }
Example #11
0
        private void FeatureUpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            // create a new focus layer that use the layer style from any source layers
            var sourceOverlay = Map.Overlays["SourceOverlay"] as LayerOverlay;
            var layerStyle    = (sourceOverlay.Layers.First() as InMemoryFeatureLayer).ZoomLevelSet.ZoomLevel01.CustomStyles.First();
            var focusLayer    = new InMemoryFeatureLayer();

            focusLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(layerStyle);
            focusLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // change column value of any valid source features randomly, then add the feature to new focus layer
            for (int i = 0; i < UpdateFeatureCount; i++)
            {
                var sourceLayer = sourceOverlay.Layers[featureUpdateRadom.Next(0, layerCount)] as InMemoryFeatureLayer;
                if (sourceLayer.IsVisible)
                {
                    var sourceFeature = sourceLayer.InternalFeatures[$"{featureUpdateRadom.Next(0, featureColumnCount)}.{featureUpdateRadom.Next(0, featureRowCount)}"];
                    sourceFeature.ColumnValues["State"] = ((Convert.ToInt32(sourceFeature.ColumnValues["State"]) + 1) % 5).ToString();
                    focusLayer.InternalFeatures.Add(sourceFeature);
                }
            }

            Dispatcher.Invoke(new Action(() =>
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                // save the old overlay as a geoImage, then remove it
                GeoImage focusOverlayBackgroundImage = null;
                if (Map.Overlays.Contains("FocusOverlay"))
                {
                    var dirtyFocusOverlay       = Map.Overlays["FocusOverlay"] as CustomLayerOverlay;
                    focusOverlayBackgroundImage = dirtyFocusOverlay.ToGeoImage(Map.CurrentExtent, Map.MapUnit);
                    Map.Overlays.Remove(dirtyFocusOverlay);
                    dirtyFocusOverlay.Dispose();
                }

                // create a new FocusOverlay, add it to map, then refresh it
                var focusOverlay = new CustomLayerOverlay(focusOverlayBackgroundImage)
                {
                    TileType       = TileType.SingleTile,
                    DrawingQuality = DrawingQuality.HighSpeed
                };
                focusOverlay.Layers.Add(focusLayer);
                Map.Overlays.Add("FocusOverlay", focusOverlay);
                Map.Refresh(Map.CurrentExtent, focusOverlay);

                stopwatch.Stop();
                InformationTextBlock.Text = $"Refresh Time (ms): {stopwatch.ElapsedMilliseconds}";
            }));
        }
Example #12
0
        protected override PrinterLayer GetPrinterLayerFromActiveMapCore(RectangleShape boudingBox)
        {
            if ((northArrowMapTool != null && !string.IsNullOrEmpty(northArrowMapTool.ImagePath)) ||
                (adornmentLogo != null && !string.IsNullOrEmpty(adornmentLogo.LogoPath)))
            {
                GeoImage geoImage = null;

                double widthInPixel = 0, heightInPixel = 0;

                if (northArrowMapTool != null && !string.IsNullOrEmpty(northArrowMapTool.ImagePath))
                {
                    geoImage      = GetGeoImage(northArrowMapTool);
                    widthInPixel  = (int)northArrowMapTool.Width;
                    heightInPixel = (int)northArrowMapTool.Height;
                }
                else if (adornmentLogo != null && !string.IsNullOrEmpty(adornmentLogo.LogoPath))
                {
                    geoImage      = GetGeoImage(adornmentLogo);
                    widthInPixel  = (int)adornmentLogo.Width;
                    heightInPixel = (int)adornmentLogo.Height;
                }

                ImagePrinterLayer imagePrinterLayer = new ImagePrinterLayer(geoImage, 0, 0, PrintingUnit.Inch)
                {
                    DrawingExceptionMode = DrawingExceptionMode.DrawException
                };
                imagePrinterLayer.Open();
                AdornmentLocation location          = GetLocation();
                double            width             = PrinterHelper.ConvertLength((double)widthInPixel, PrintingUnit.Point, PrintingUnit.Inch);
                double            height            = PrinterHelper.ConvertLength((double)heightInPixel, PrintingUnit.Point, PrintingUnit.Inch);
                double            left              = 0;
                double            top               = 0;
                if (northArrowMapTool != null)
                {
                    left = PrinterHelper.ConvertLength(northArrowMapTool.Margin.Left, PrintingUnit.Point, PrintingUnit.Inch);
                    top  = PrinterHelper.ConvertLength(northArrowMapTool.Margin.Top, PrintingUnit.Point, PrintingUnit.Inch);
                }
                if (adornmentLogo != null)
                {
                    left = PrinterHelper.ConvertLength(adornmentLogo.Left, PrintingUnit.Point, PrintingUnit.Inch);
                    top  = PrinterHelper.ConvertLength(adornmentLogo.Top, PrintingUnit.Point, PrintingUnit.Inch);
                }
                SetPosition(location, boudingBox, imagePrinterLayer, width, height, left, top);
                return(imagePrinterLayer);
            }
            else
            {
                return(null);
            }
        }
        private void Map1_Loaded(object sender, RoutedEventArgs e)
        {
            Map1.MapUnit = GeoUnit.Meter;

            GeoImage      image         = new GeoImage(@"SampleData/bing-aerial-900913.png");
            GeoSize       size          = image.GetSize();
            GeoImageLayer geoImageLayer = new GeoImageLayer(image, new WorldFile(GeoCommonHelper.GetMaxBound(GeoUnit.Meter), (float)size.Width, (float)size.Height));

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(geoImageLayer);
            Map1.Overlays.Add(layerOverlay);
            Map1.ZoomToFullBound();
        }
Example #14
0
        private void btnToBitmap_Click(object sender, RoutedEventArgs e)
        {
            PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"];
            PagePrinterLayer          pagePrinterLayer          = printerInteractiveOverlay.PrinterLayers["PageLayer"] as PagePrinterLayer;

            // Create a bitmap that is the size of the pages bounding box.  The page by default is in points unit
            // system which is very similar to pixels so that ampping is nice.
            GeoImage bitmap = null;

            try
            {
                bitmap = new GeoImage((int)pagePrinterLayer.GetBoundingBox().Width, (int)pagePrinterLayer.GetBoundingBox().Height);

                // Create a GeoCanvas and start the drawing
                GeoCanvas gdiPlusGeoCanvas = GeoCanvas.CreateDefaultGeoCanvas();
                gdiPlusGeoCanvas.BeginDrawing(bitmap, pagePrinterLayer.GetBoundingBox(), Map1.MapUnit);

                // Loop through all of the PrintingLayer in the PrinterInteractiveOverlay and print all of the
                // except for the PagePrinterLayer
                Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>();
                foreach (PrinterLayer printerLayer in printerInteractiveOverlay.PrinterLayers)
                {
                    printerLayer.IsDrawing = true;
                    if (!(printerLayer is PagePrinterLayer))
                    {
                        printerLayer.Draw(gdiPlusGeoCanvas, labelsInAllLayers);
                    }
                    printerLayer.IsDrawing = false;
                }

                // End the drawing
                gdiPlusGeoCanvas.EndDrawing();

                //Save the resulting bitmap to a file and open the file to show the user
                string filename = "PrintingResults.bmp";
                bitmap.Save(filename);
                Process.Start("explorer.exe", filename);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " " + ex.StackTrace, "Exception");
            }
            finally
            {
                if (bitmap != null)
                {
                    bitmap.Dispose();
                }
            }
        }
Example #15
0
        private GeoImage GetCacheImage(PageGeoCanvas pageGeoCanvas, GeographyUnit geographyUnit, RectangleShape adjustedWorldExtent, Collection <SimpleCandidate> labelsInAllLayers, double width, double height)
        {
            RectangleShape currentBoundingBox = GetBoundingBox();

            if (mapImageCache == null && Layers.Count > 0)
            {
                Bitmap       bitmap       = null;
                MemoryStream memoryStream = null;
                try
                {
                    bitmap = new Bitmap((int)width, (int)height);
                    PlatformGeoCanvas tmpCanvas = new PlatformGeoCanvas();
                    tmpCanvas.DrawingQuality = DrawingQuality.HighSpeed;
                    tmpCanvas.BeginDrawing(bitmap, currentBoundingBox, geographyUnit);

                    pageGeoCanvas.BeginDrawing(tmpCanvas, adjustedWorldExtent, MapUnit);

                    lock (Layers)
                    {
                        foreach (Layer layer in Layers)
                        {
                            if (!layer.IsOpen)
                            {
                                layer.Open();
                            }
                            pageGeoCanvas.Flush();
                            layer.Draw(pageGeoCanvas, labelsInAllLayers);
                        }
                    }

                    pageGeoCanvas.EndDrawing();
                    tmpCanvas.EndDrawing();
                    IsDrawing    = false;
                    memoryStream = new MemoryStream();
                    bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
                    mapImageCache = new GeoImage(memoryStream);
                }
                catch (Exception ex)
                {
                    GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                }
                finally
                {
                    bitmap?.Dispose();
                }
            }
            return(mapImageCache);
        }
        private void AddLogoImage()
        {
            //Load the image to a GeoImage and then create the ImagePrinterLayer using that image
            GeoImage          compassGeoImage   = new GeoImage(@"..\..\..\Resources\Compass.png");
            ImagePrinterLayer imagePrinterLayer = new ImagePrinterLayer(compassGeoImage);

            // Set the imagePrinterLayer position offset from the page center and .75 inches wide and .75 inches tall
            RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);

            imagePrinterLayer.SetPosition(.75, .75, pageBoundingbox.GetCenterPoint().X + 3.5, pageBoundingbox.GetCenterPoint().Y - 2.0, PrintingUnit.Inch);

            // Add the imagePrinterLayer to the PrinterInteractiveOverlay
            PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"];

            printerInteractiveOverlay.PrinterLayers.Add("ImageLayer", imagePrinterLayer);
        }
Example #17
0
        public CustomLayerOverlay(GeoImage backgroundImage = null)
        {
            BackgroundImage = backgroundImage;
            if (BackgroundImage != null)
            {
                // set the background image as a control of this overlay
                var wpfBitmap = new BitmapImage();
                wpfBitmap.BeginInit();
                wpfBitmap.StreamSource = BackgroundImage.GetImageStream();
                wpfBitmap.EndInit();

                var imageControl = new Image()
                {
                    Source = wpfBitmap
                };
                imageControl.SetValue(Panel.ZIndexProperty, -100);
                OverlayCanvas.Children.Add(imageControl);
            }
        }
Example #18
0
        internal static PrinterLayer GetImagePrinterLayer(double width, double height, double centerX, double centerY)
        {
            ImageElementViewModel imageEntity = new ImageElementViewModel();
            GeoImage geoImage = null;

            geoImage = new GeoImage(new MemoryStream(imageEntity.SelectedImage));
            ImagePrinterLayer imagePrinterLayer = new ImagePrinterLayer(geoImage, 0, 0, PrintingUnit.Inch)
            {
                DrawingExceptionMode = DrawingExceptionMode.DrawException
            };

            imagePrinterLayer.LoadFromViewModel(imageEntity);
            var imgWidth  = imagePrinterLayer.Image.Width;
            var imgHeight = imagePrinterLayer.Image.Height;

            imagePrinterLayer.Open();
            imagePrinterLayer.SetPosition(width, height, centerX, centerY, PrintingUnit.Inch);
            return(imagePrinterLayer);
        }
Example #19
0
        protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers)
        {
            GeoImage       miniImage         = new GeoImage(width, height);
            RectangleShape scaledWorldExtent = MapEngine.GetDrawingExtent(canvas.CurrentWorldExtent, width, height);

            scaledWorldExtent.ScaleUp(300);
            GdiPlusGeoCanvas minCanvas = new GdiPlusGeoCanvas();

            minCanvas.BeginDrawing(miniImage, scaledWorldExtent, canvas.MapUnit);
            foreach (Layer layer in layers)
            {
                layer.Draw(minCanvas, labelsInAllLayers);
            }

            minCanvas.DrawArea(RectangleShape.ScaleDown(minCanvas.CurrentWorldExtent, 1), new GeoPen(GeoColor.StandardColors.Gray, 2), DrawingLevel.LevelOne);
            minCanvas.DrawArea(canvas.CurrentWorldExtent, new GeoPen(GeoColor.StandardColors.Black, 2), DrawingLevel.LevelOne);

            minCanvas.EndDrawing();

            ScreenPointF drawingLocation = GetDrawingLocation(canvas, width, height);

            canvas.DrawScreenImageWithoutScaling(miniImage, (drawingLocation.X + width / 2) + 10, (drawingLocation.Y + height / 2) - 10, DrawingLevel.LevelOne, 0, 0, 0);
        }
Example #20
0
        protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers)
        {
            if (IsVisible)
            {
                ScreenPointF screenPointF = GetDrawingLocation(canvas, logoImage.Width, logoImage.Height);

                // If the canvas happens to be using GDI+ then we can do an optimization and skip
                // the GeoImage.  Otherwise we go the longer route in the else statement
                if (canvas is GdiPlusGeoCanvas)
                {
                    GdiPlusGeoCanvas gdiPlusGeoCanvas = canvas as GdiPlusGeoCanvas;
                    gdiPlusGeoCanvas.DrawScreenImageWithoutScaling(logoImage, screenPointF.X + logoImage.Width * 0.5f, screenPointF.Y + logoImage.Height * 0.5f, DrawingLevel.LevelOne, 0, 0, 0);
                }
                else
                {
                    //  Here we have to convert the stream to a TIFF to be used in the GeoImage
                    Stream stream = new MemoryStream();
                    logoImage.Save(stream, ImageFormat.Tiff);
                    GeoImage geoImage = new GeoImage(stream);

                    canvas.DrawScreenImageWithoutScaling(geoImage, screenPointF.X + logoImage.Width * 0.5f, screenPointF.Y + logoImage.Height * 0.5f, DrawingLevel.LevelOne, 0, 0, 0);
                }
            }
        }
 public CustomGeoImageLineStyle(LineStyle lineStyle, GeoImage geoImage, int spacing, SymbolSide side)
     : this(lineStyle, new Collection <GeoImage> {
     geoImage
 }, spacing, side)
 {
 }
 public RotatingAdornmentLayer(GeoImage imageToDraw)
 {
     _imageToDraw = imageToDraw;
 }
        private static PointStyle GetCurrentVehicleStyle(string iconVirtualPath)
        {
            Stream vehicleStream = MapSuiteSampleHelper.GetResourceStream(iconVirtualPath);
            GeoImage vehicleImage = new GeoImage(vehicleStream);

            return new PointStyle(vehicleImage);
        }
Example #24
0
        private void DrawInternal(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers)
        {
            RectangleShape currentBoundingBox = GetBoundingBox();

            AreaStyle brushStyle = BackgroundMask.CloneDeep() as AreaStyle;

            brushStyle.OutlinePen.Width = 0;
            brushStyle.Draw(new BaseShape[] { currentBoundingBox }, canvas, new Collection <SimpleCandidate>(), labelsInAllLayers);

            // Clear Cache images
            if (LastmapExtent != null)
            {
                if (LastmapExtent.UpperLeftPoint.X != MapExtent.UpperLeftPoint.X ||
                    LastmapExtent.UpperLeftPoint.Y != MapExtent.UpperLeftPoint.Y ||
                    LastmapExtent.LowerRightPoint.X != MapExtent.LowerRightPoint.X ||
                    LastmapExtent.LowerRightPoint.Y != MapExtent.LowerRightPoint.Y ||
                    IsDrawing)
                {
                    mapImageCache = null;
                }
            }

            //For adjusting the world extent of the map to the ratio of the drawing area.
            RectangleShape adjustedWorldExtent = ExtentHelper.GetDrawingExtent(MapExtent, (float)currentBoundingBox.Width, (float)currentBoundingBox.Height);
            RectangleShape boundingBox         = GetBoundingBox();
            PointShape     ajustedWorldCenter  = adjustedWorldExtent.GetCenterPoint();
            PageGeoCanvas  pageGeoCanvas       = new PageGeoCanvas(new RectangleShape(0, boundingBox.Height, boundingBox.Width, 0), currentBoundingBox);

            //if (EnableClipping)
            //{
            //    pageGeoCanvas.EnableCliping = true;
            //    pageGeoCanvas.ClipingArea = adjustedWorldExtent;
            //}

            //if (canvas is GdiPlusGeoCanvas && DrawingMode != Core.DrawingMode.Vector)
            // only display on map.
            if (DrawingMode != MapPrinterDrawingMode.Vector && !(canvas is PrinterGeoCanvas))
            {
                double   width  = boundingBox.Width / canvas.CurrentWorldExtent.Width * canvas.Width;
                double   height = boundingBox.Height / canvas.CurrentWorldExtent.Height * canvas.Height;
                GeoImage image  = GetCacheImage(pageGeoCanvas, canvas.MapUnit, adjustedWorldExtent, labelsInAllLayers, width, height);

                pageGeoCanvas.BeginDrawing(canvas, adjustedWorldExtent, MapUnit);
                if (image != null)
                {
                    pageGeoCanvas.DrawWorldImage(image, ajustedWorldCenter.X, ajustedWorldCenter.Y, (float)boundingBox.Width - 0.5f, (float)boundingBox.Height - 0.5f, DrawingLevel.LabelLevel);
                }
                if (DrawDescription)
                {
                    DrawDescriptionText(pageGeoCanvas);
                }
                //pageGeoCanvas.EnableCliping = false;
                pageGeoCanvas.EndDrawing();
            }
            // display on map or printer.
            else
            {
                pageGeoCanvas.BeginDrawing(canvas, adjustedWorldExtent, MapUnit);
                double increase = 0;
                if (BackgroundMask.OutlinePen != null)
                {
                    float haflPenWidth = BackgroundMask.OutlinePen.Width / 2;
                    increase = haflPenWidth * canvas.CurrentWorldExtent.Width / canvas.Width;
                }
                canvas.ClippingArea = new RectangleShape(
                    currentBoundingBox.UpperLeftPoint.X - increase,
                    currentBoundingBox.UpperLeftPoint.Y + increase,
                    currentBoundingBox.LowerRightPoint.X + increase,
                    currentBoundingBox.LowerRightPoint.Y - increase);
                if (canvas is PrinterGeoCanvas)
                {
                    foreach (Layer layer in Layers)
                    {
                        pageGeoCanvas.Flush();

                        float        savedDrawingMarginPercentage = 0;
                        FeatureLayer featureLayer = layer as FeatureLayer;
                        if (featureLayer != null)
                        {
                            savedDrawingMarginPercentage      = featureLayer.DrawingMarginInPixel;
                            featureLayer.DrawingMarginInPixel = 0;
                        }
                        layer.SafeProcess(() =>
                        {
                            layer.Draw(pageGeoCanvas, labelsInAllLayers);
                        });
                        if (featureLayer != null && savedDrawingMarginPercentage != 0)
                        {
                            featureLayer.DrawingMarginInPixel = savedDrawingMarginPercentage;
                        }
                    }
                }
                else
                {
                    using (MemoryStream ms = GetImageStream(canvas, labelsInAllLayers, adjustedWorldExtent, boundingBox))
                    {
                        pageGeoCanvas.DrawWorldImage(new GeoImage(ms), ajustedWorldCenter.X, ajustedWorldCenter.Y, (float)boundingBox.Width - 0.5f, (float)boundingBox.Height - 0.5f, DrawingLevel.LabelLevel);
                    }
                    //foreach (Layer layer in Layers)
                    //{
                    //    pageGeoCanvas.Flush();
                    //    layer.SafeProcess(() =>
                    //    {
                    //        layer.Draw(pageGeoCanvas, labelsInAllLayers);
                    //    });
                    //}
                }
                if (DrawDescription)
                {
                    DrawDescriptionText(pageGeoCanvas);
                }
                //pageGeoCanvas.EnableCliping = false;
                var areaStyle = new AreaStyle(BackgroundMask.OutlinePen)
                {
                    DrawingLevel = DrawingLevel.LabelLevel
                };
                areaStyle.Draw(new BaseShape[1] {
                    currentBoundingBox
                }, canvas, new Collection <SimpleCandidate>(), labelsInAllLayers);
                canvas.ClippingArea = null;
            }

            AreaStyle lineStyle = new AreaStyle(BackgroundMask.OutlinePen.CloneDeep());

            lineStyle.DrawingLevel = DrawingLevel.LabelLevel;
            lineStyle.Draw(new BaseShape[] { currentBoundingBox }, canvas, new Collection <SimpleCandidate>(), labelsInAllLayers);
            LastmapExtent = new RectangleShape(MapExtent.UpperLeftPoint.X, MapExtent.UpperLeftPoint.Y, MapExtent.LowerRightPoint.X, MapExtent.LowerRightPoint.Y);
        }
Example #25
0
 protected override object ToNativeImageCore(GeoImage image)
 {
     throw new NotImplementedException();
 }
Example #26
0
 protected override void DrawScreenImageWithoutScalingCore(GeoImage image, float centerXInScreen, float centerYInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle)
 {
     throw new NotImplementedException();
 }
Example #27
0
 public override Stream GetStreamFromGeoImage(GeoImage image)
 {
     return(canvas.GetStreamFromGeoImage(image));
 }
Example #28
0
 protected override object ToNativeImageCore(GeoImage image)
 {
     return(canvas.ToNativeImage(image));
 }
Example #29
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);
 }
 public MemoryRasterLayer(Stream imageStream)
 {
     this.ImageSource = new MemoryRasterSource();
     this.image       = new GeoImage(imageStream);
 }
Example #31
0
 public override System.IO.Stream GetStreamFromGeoImage(GeoImage image)
 {
     throw new NotImplementedException();
 }
Example #32
0
 public RotatedImageStyle(GeoImage geoImage, string angleColumnName)
 {
     this.geoImage        = geoImage;
     this.angleColumnName = angleColumnName;
 }