コード例 #1
0
        private void btnPan_Click(object sender, EventArgs e)
        {
            // Grab the MapPrinterLayer and adjust the extent
            PrinterInteractiveOverlay printerOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"];

            MapPrinterLayer mapPrinterLayer = ((MapPrinterLayer)(printerOverlay.PrinterLayers["MapLayer"]));

            if (sender == btnPanNorth)
            {
                mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Up, 30);
            }
            else if (sender == btnPanSouth)
            {
                mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Down, 30);
            }
            else if (sender == btnPanWest)
            {
                mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Left, 30);
            }
            else if (sender == btnPanEast)
            {
                mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Right, 30);
            }

            Map1.Refresh();
        }
コード例 #2
0
        public ScaleLineElementWindow(MapPrinterLayer mapPrinterLayer)
        {
            InitializeComponent();
            viewModel   = new ScaleLineElementViewModel(mapPrinterLayer);
            DataContext = viewModel;

            HelpContainer.Content = HelpResourceHelper.GetHelpButton("PrintMapScaleLineHelp", HelpButtonMode.NormalButton);
        }
コード例 #3
0
 public ScaleLineElementViewModel(MapPrinterLayer mapPrinterLayer)
 {
     PropertyChanged     += ScaleLineElementEntity_PropertyChanged;
     this.mapPrinterLayer = mapPrinterLayer;
     dragMode             = PrinterDragMode.Draggable;
     selectedUnitSystem   = ScaleLineUnitSystem.ImperialAndMetric;
     BackgroundStyle      = new AreaStyle();
     BackgroundStyle.CustomAreaStyles.Add(new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.Transparent)));
 }
コード例 #4
0
        private void AddMapLayer()
        {
            // Create the MapPrinterLayer and set the position
            MapPrinterLayer mapPrinterLayer = new MapPrinterLayer();

            mapPrinterLayer.MapUnit        = GeographyUnit.Meter;
            mapPrinterLayer.MapExtent      = new RectangleShape(-20026376.39, 20048966.10, 20026376.39, -20048966.10);
            mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.Black, 1));
            mapPrinterLayer.Open();

            // Set the maps position slightly below the pages center and 8 inches wide and 7 inches tall
            RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);

            mapPrinterLayer.SetPosition(8, 7, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1, PrintingUnit.Inch);

            // Setup the intial extent and ensure they snap to the default ZoomLevel
            ZoomLevelSet zoomLevelSet = new ZoomLevelSet();

            mapPrinterLayer.MapExtent = MapUtil.ZoomToScale(zoomLevelSet.ZoomLevel03.Scale, new RectangleShape(-20026376.39, 20048966.10, 20026376.39, -20048966.10), mapPrinterLayer.MapUnit, (float)mapPrinterLayer.GetBoundingBox().Width, (float)mapPrinterLayer.GetBoundingBox().Height);

            // This ThinkGeo Cloud test key is exclusively for demonstration purposes and is limited to requesting base map
            // tiles only. Do not use it in your own applications, as it may be restricted or disabled without prior notice.
            // Please visit https://cloud.thinkgeo.com to create a free key for your own use.
            //ThinkGeoCloudRasterMapsLayer worldMapKitLayer = new ThinkGeoCloudRasterMapsLayer("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~");
            //worldMapKitLayer.TileCache = null;
            //mapPrinterLayer.Layers.Add(worldMapKitLayer);
            ShapeFileFeatureLayer backgroundLayer = new ShapeFileFeatureLayer(@"data/Countries02_3857.shp", FileAccess.Read);

            backgroundLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            backgroundLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyle.CreateSimpleAreaStyle(GeoColors.White, GeoColors.Black);
            mapPrinterLayer.Layers.Add(backgroundLayer);

            // Setup the Countries mapping layer
            ShapeFileFeatureLayer shapefileFeatureLayer = new ShapeFileFeatureLayer(@"data/Countries02_3857.shp", FileAccess.Read);

            shapefileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            //Create the class break style for countries less than 70 million
            ClassBreakStyle classBreakStyle = new ClassBreakStyle("POP_CNTRY");

            // Create the style and class break for countries with greater and 70 million
            AreaStyle hatchAreaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, GeoColors.Green)));

            classBreakStyle.ClassBreaks.Add(new ClassBreak(70000000, hatchAreaStyle));

            // Add the class break style to the layer
            shapefileFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);

            // Add the new country layer to the MapPrinterLayer
            mapPrinterLayer.Layers.Add(shapefileFeatureLayer);

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

            printerInteractiveOverlay.PrinterLayers.Add("MapLayer", mapPrinterLayer);
        }
コード例 #5
0
        public static void ResetFixedExtent(MapPrinterLayer mapPrinterLayer, RectangleShape targetExtent)
        {
            mapPrinterLayer.MapExtent = targetExtent;
            var simplifyMapPrinterLayer = mapPrinterLayer as SimplifyMapPrinterLayer;

            if (simplifyMapPrinterLayer != null)
            {
                simplifyMapPrinterLayer.LastmapExtent = mapPrinterLayer.MapExtent;
            }
        }
コード例 #6
0
        public static ScaleBarPrinterLayer GetScaleBarPrinterLayer(MapPrinterLayer mapPrinterLayer, double width, double height, double centerX, double centerY)
        {
            ScaleBarPrinterLayer scaleBarPrinterLayer = new ScaleBarPrinterLayer(mapPrinterLayer);

            scaleBarPrinterLayer.MapUnit           = mapPrinterLayer.MapUnit;
            scaleBarPrinterLayer.BackgroundMask    = new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.Transparent));
            scaleBarPrinterLayer.UnitFamily        = UnitSystem.Metric;
            scaleBarPrinterLayer.AlternateBarBrush = new GeoSolidBrush(GeoColor.StandardColors.White);
            scaleBarPrinterLayer.Open();
            scaleBarPrinterLayer.SetPosition(width, height, centerX, centerY, PrintingUnit.Inch);
            return(scaleBarPrinterLayer);
        }
コード例 #7
0
        private void AddMapLayer()
        {
            // Create the MapPrinterLayer and set the position
            MapPrinterLayer mapPrinterLayer = new MapPrinterLayer();

            //Map Printer Layer is in feet (State Plane Texas North Central Feet NAD83)
            mapPrinterLayer.MapUnit = GeographyUnit.Feet;
            //Set the extent of the MapPrinterLayer with world coordinates.
            RectangleShape currentExtent = new RectangleShape(2276456, 6897886, 2280391, 6895437);

            mapPrinterLayer.MapExtent      = currentExtent;
            mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.Black, 1));
            mapPrinterLayer.Open();

            // Set the maps position slightly above the page center and 8 inches wide and 7 inches tall
            RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);

            mapPrinterLayer.SetPosition(8, 7, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1, PrintingUnit.Inch);

            //Setup the styles for the parcels layer.
            ShapeFileFeatureLayer parcelsLayer = new ShapeFileFeatureLayer(@"..\..\..\Data\Shapefile\parcels.shp", FileAccess.Read);
            //Creates a value style for the parcel type (residential 1, commercial 2, industrial 3).
            ValueStyle typeValueStyle = new ValueStyle();

            typeValueStyle.ColumnName = "PARCELTYPE";
            typeValueStyle.ValueItems.Add(new ValueItem("1", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelGreen))));
            typeValueStyle.ValueItems.Add(new ValueItem("2", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelOrange))));
            typeValueStyle.ValueItems.Add(new ValueItem("3", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelBlue))));
            parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(typeValueStyle);

            //Creates a value style for affected parcels by new proposal
            ValueStyle affectedValueStyle = new ValueStyle();

            affectedValueStyle.ColumnName = "AFFECTED";
            affectedValueStyle.ValueItems.Add(new ValueItem("YES", new AreaStyle(new GeoPen(GeoColors.DarkGreen, 4), new GeoSolidBrush(GeoColors.Transparent))));
            affectedValueStyle.ValueItems.Add(new ValueItem("D", new AreaStyle(new GeoPen(GeoColors.DarkRed, 4), new GeoSolidBrush(GeoColors.Transparent))));
            parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(affectedValueStyle);

            //Creates a text style to display tax id of parcels
            TextStyle textStyle = new TextStyle("TAXPIN", new GeoFont("Arial", 12, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColors.Black));

            textStyle.HaloPen = new GeoPen(GeoColors.White, 2);
            parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle);
            parcelsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Add the new parcels layer to the MapPrinterLayer
            mapPrinterLayer.Layers.Add(parcelsLayer);

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

            printerInteractiveOverlay.PrinterLayers.Add("MapLayer", mapPrinterLayer);
        }
コード例 #8
0
 public ScaleBarElementViewModel(MapPrinterLayer mapPrinterLayer)
 {
     this.mapPrinterLayer = mapPrinterLayer;
     background           = new AreaStyle();
     background.CustomAreaStyles.Add(new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.Transparent)));
     selectedUnitSystem = UnitSystem.Metric;
     color                     = new GeoSolidBrush(GeoColor.StandardColors.Black);
     alternatingColor          = new GeoSolidBrush(GeoColor.StandardColors.White);
     resizeMode                = PrinterResizeMode.Resizable;
     dragMode                  = PrinterDragMode.Draggable;
     PropertyChanged          += ScaleBarViewModelPropertyChanged;
     SelectedNumericFormatType = ScaleNumericFormatType.None;
 }
コード例 #9
0
        private void ScaleLineElementEntity_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Preview" || (MapPrinterLayer.MapUnit == GeographyUnit.DecimalDegree && !PrinterLayerHelper.CheckDecimalDegreeIsInRange(MapPrinterLayer.MapExtent)))
            {
                return;
            }
            if (!MapPrinterLayer.IsOpen)
            {
                MapPrinterLayer.Open();
            }
            try
            {
                ScaleLinePrinterLayer scaleLinePrinterLayer = new ScaleLinePrinterLayer(MapPrinterLayer);
                scaleLinePrinterLayer.BackgroundMask = BackgroundStyle as AreaStyle;
                scaleLinePrinterLayer.MapUnit        = MapPrinterLayer.MapUnit;
                scaleLinePrinterLayer.UnitSystem     = SelectedUnitSystem;
                var boundingBox = MapPrinterLayer.GetBoundingBox();
                var pageCenter  = boundingBox.GetCenterPoint();
                scaleLinePrinterLayer.SetPosition(1.25, .25, -3.25, -2.25, PrintingUnit.Inch);
                using (Bitmap bitmap = new Bitmap(220, 60))
                {
                    PlatformGeoCanvas canvas = new PlatformGeoCanvas();
                    scaleLinePrinterLayer.SafeProcess(() =>
                    {
                        var scaleLineBoundingBox = scaleLinePrinterLayer.GetBoundingBox();
                        canvas.BeginDrawing(bitmap, scaleLineBoundingBox, GeographyUnit.Meter);
                        scaleLinePrinterLayer.Draw(canvas, new Collection <SimpleCandidate>());
                    });

                    //scaleLinePrinterLayer.Open();
                    //var scaleLineBoundingBox = scaleLinePrinterLayer.GetBoundingBox();
                    //canvas.BeginDrawing(bitmap, scaleLineBoundingBox, GeographyUnit.Meter);
                    //scaleLinePrinterLayer.Draw(canvas, new Collection<SimpleCandidate>());
                    //scaleLinePrinterLayer.Close();
                    canvas.EndDrawing();
                    MemoryStream ms = new MemoryStream();
                    bitmap.Save(ms, ImageFormat.Png);

                    BitmapImage bitmapImage = new BitmapImage();
                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = ms;
                    bitmapImage.EndInit();
                    Preview = bitmapImage;
                }
            }
            catch (Exception ex)
            {
                GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
            }
        }
コード例 #10
0
        private void btnZoomOut_Click(object sender, RoutedEventArgs e)
        {
            // Grab the MapPrinterLayer and adjust the extent
            PrinterInteractiveOverlay printerOverlay  = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"];
            MapPrinterLayer           mapPrinterLayer = ((MapPrinterLayer)(printerOverlay.PrinterLayers["MapLayer"]));

            // Here we snap the current scale to the default zoomLevelSet when we zoom in
            ZoomLevelSet zoomLevelSet = new ZoomLevelSet();
            double       newScale     = ZoomLevelSet.GetHigherZoomLevelScale(MapUtil.GetScale(mapPrinterLayer.MapExtent, (float)mapPrinterLayer.GetBoundingBox().Width, mapPrinterLayer.MapUnit), zoomLevelSet);

            mapPrinterLayer.MapExtent = MapUtil.ZoomToScale(newScale, mapPrinterLayer.MapExtent, mapPrinterLayer.MapUnit, (float)mapPrinterLayer.GetBoundingBox().Width, (float)mapPrinterLayer.GetBoundingBox().Height);

            Map1.Refresh();
        }
コード例 #11
0
        private void AddScaleLineLayer()
        {
            // Get the PrinterInteractiveOverlay
            PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"];

            // Grab the MapPrinterLayer as we need to pass that into the scaleLinePrinterLayer so it
            // can be synced up to the map itself in real-time
            MapPrinterLayer mapPrinterLayer = (MapPrinterLayer)printerInteractiveOverlay.PrinterLayers["MapLayer"];

            //Create the scaleLinePrinterLayer and pass in the MapPrinterLayer
            ScaleLinePrinterLayer scaleLinePrinterLayer = new ScaleLinePrinterLayer(mapPrinterLayer);

            scaleLinePrinterLayer.MapUnit = GeographyUnit.Feet;

            // Set the scale line position offset from the page center and 1.25 inches wide and .25 inches tall
            RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);

            scaleLinePrinterLayer.SetPosition(1.25, .25, pageBoundingbox.GetCenterPoint().X - 3.25, pageBoundingbox.GetCenterPoint().Y - 2.25, PrintingUnit.Inch);

            // Add the ScaleLinePrinterLayer to the PrinterInteractiveOverlay
            printerInteractiveOverlay.PrinterLayers.Add("ScaleLineLayer", scaleLinePrinterLayer);
        }
コード例 #12
0
        public MapPrinterLayerProperty(MapPrinterLayer mapPrinterLayer)
        {
            InitializeComponent();

            this.mapPrinterLayer = mapPrinterLayer;
        }