protected override PrinterLayer GetPrinterLayerFromActiveMapCore(RectangleShape boudingBox) { if (wpfMap != null) { SimplifyMapPrinterLayer mapPrinterLayer = new SimplifyMapPrinterLayer(); LoadFromActiveMap(mapPrinterLayer); if (AppMenuUIPlugin.PreserveScale) { mapPrinterLayer.SetPosition(wpfMap.ActualWidth, wpfMap.ActualHeight, 0, 0, PrintingUnit.Point); } else { mapPrinterLayer.SetPosition(boudingBox.Width - 2, boudingBox.Height - 2, 0, 0, PrintingUnit.Inch); } //RectangleShape currentMapExtent = GetFixedScaledExtent(boudingBox, wpfMap.CurrentResolution, wpfMap.CurrentExtent); //ResetFixedExtent(mapPrinterLayer, currentMapExtent); mapPrinterLayer.SetDescriptionLayerBackground(); mapPrinterLayer.MapImageCache = new GeoImage(new MemoryStream(BoundingBoxSelectorMapTool.GetCroppedMapPreviewImage(wpfMap, new System.Windows.Int32Rect(0, 0, (int)wpfMap.RenderSize.Width, (int)wpfMap.RenderSize.Height)))); mapPrinterLayer.LastmapExtent = mapPrinterLayer.MapExtent; return(mapPrinterLayer); } else { return(null); } }
internal static void SetDescriptionLayerBackground(this SimplifyMapPrinterLayer mapPrinterLayer, PointShape centerPoint = null) { if (mapPrinterLayer.Layers.Count == 0) { mapPrinterLayer.BackgroundMask.Advanced.FillCustomBrush = new GeoLinearGradientBrush(GeoColor.FromHtml("#FFFFFF"), GeoColor.FromHtml("#E6E6E6"), GeoLinearGradientDirection.BottomToTop); mapPrinterLayer.BackgroundMask.OutlinePen = new GeoPen(GeoColor.StandardColors.Black); mapPrinterLayer.BackgroundMask.DrawingLevel = DrawingLevel.LabelLevel; } }
public static MapPrinterLayer GetMapPrinterLayer(double width, double height, double centerX, double centerY) { var mapPrinterLayer = new SimplifyMapPrinterLayer { Name = "Map1", DrawingExceptionMode = DrawingExceptionMode.DrawException }; mapPrinterLayer.Open(); var adapter = new MapPrinterLayerAdapter(GisEditor.ActiveMap); adapter.LoadFromActiveMap(mapPrinterLayer); mapPrinterLayer.SetDescriptionLayerBackground(); mapPrinterLayer.SetPosition(width, height, centerX, centerY, PrintingUnit.Inch); return(mapPrinterLayer); }
public static PrinterLayerAdapter Create(PrinterLayer printerLayer, SimplifyMapPrinterLayer mapPrinterLayer) { var imagePrinterLayer = printerLayer as ImagePrinterLayer; if (printerLayer is SimplifyMapPrinterLayer) { return(new MapPrinterLayerAdapter(GisEditor.ActiveMap)); } else if (imagePrinterLayer != null) { var northArrow = GisEditor.ActiveMap.MapTools.OfType <NorthArrowMapTool>().FirstOrDefault(); if (northArrow != null) { return(new ImagePrinterLayerAdapter(northArrow)); } else { return(new ImagePrinterLayerAdapter(GisEditor.ActiveMap.MapTools.OfType <AdornmentLogo>().FirstOrDefault())); } } else if (printerLayer is LabelPrinterLayer) { return(new LabelPrinterLayerAdapter(GisEditor.ActiveMap.FixedAdornmentOverlay.Layers.OfType <TitleAdornmentLayer>().FirstOrDefault())); } else if (printerLayer is LegendPrinterLayer) { var legendLayer = GisEditor.ActiveMap.FixedAdornmentOverlay.Layers.OfType <LegendManagerAdornmentLayer>().SelectMany(l => l.LegendLayers.Select(ll => ll.ToLegendAdornmentLayer())).FirstOrDefault(); return(new LegendPrinterLayerAdapter(legendLayer)); } else if (printerLayer is ScaleBarPrinterLayer) { return(new ScaleBarPrinterLayerAdapter(mapPrinterLayer, GisEditor.ActiveMap.FixedAdornmentOverlay.Layers.OfType <ScaleBarAdornmentLayer>().FirstOrDefault())); } else if (printerLayer is ScaleLinePrinterLayer) { return(new ScaleLinePrinterLayerAdapter(mapPrinterLayer, GisEditor.ActiveMap.FixedAdornmentOverlay.Layers.OfType <ScaleLineAdornmentLayer>().FirstOrDefault())); } else { return(new PrinterLayerAdapter()); } }
internal static void AddBaseOverlays(WpfMap map, SimplifyMapPrinterLayer mapPrinterLayer) { var osmOverlay = map.Overlays.OfType <OpenStreetMapOverlay>().FirstOrDefault(); if (osmOverlay != null && osmOverlay.IsVisible) { OpenStreetMapLayer osmLayer = new OpenStreetMapLayer(); osmLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException; osmLayer.TimeoutInSeconds = 5; osmLayer.DrawingException += new EventHandler <DrawingExceptionLayerEventArgs>(osmLayer_DrawingException); mapPrinterLayer.Layers.Add(osmLayer); } var bingOverlay = map.Overlays.OfType <BingMapsOverlay>().FirstOrDefault(); if (bingOverlay != null && bingOverlay.IsVisible) { BingMapsLayer bingMapsLayer = new BingMapsLayer(bingOverlay.ApplicationId, (Layers.BingMapsMapType)bingOverlay.MapType); bingMapsLayer.TileCache = null; bingMapsLayer.TimeoutInSeconds = 5; bingMapsLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException; bingMapsLayer.DrawingException += new EventHandler <DrawingExceptionLayerEventArgs>(BingMapsLayer_DrawingException); mapPrinterLayer.Layers.Add(bingMapsLayer); } var wmlkOverlay = map.Overlays.OfType <WorldMapKitMapOverlay>().FirstOrDefault(); if (wmlkOverlay != null && wmlkOverlay.IsVisible) { WorldMapKitLayer worldMapKitLayer = new WorldMapKitLayer(wmlkOverlay.ClientId, wmlkOverlay.PrivateKey); worldMapKitLayer.TimeoutInSecond = 5; worldMapKitLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException; worldMapKitLayer.DrawingException += new EventHandler <DrawingExceptionLayerEventArgs>(WorldMapKitLayer_DrawingException); worldMapKitLayer.TileCache = null; worldMapKitLayer.Projection = wmlkOverlay.Projection; mapPrinterLayer.Layers.Add(worldMapKitLayer); } }
public ScaleBarPrinterLayerAdapter(SimplifyMapPrinterLayer mapPrinterLayer, ScaleBarAdornmentLayer scaleBarAdornmentLayer) { this.mapPrinterLayer = mapPrinterLayer; this.scaleBarAdornmentLayer = scaleBarAdornmentLayer; }
public static PrintDocument GetPrintDocument(GisEditorWpfMap printMap, PrinterGeoCanvas printerGeoCanvas) { var printerOverlay = printMap.InteractiveOverlays.OfType <PrinterInteractiveOverlay>().FirstOrDefault(); var pagePrinterLayer = printerOverlay.PrinterLayers.OfType <PagePrinterLayer>().FirstOrDefault(); PrintDocument printDocument = new PrintDocument(); printDocument.DefaultPageSettings.PaperSize = GetPrintPreviewPaperSize(pagePrinterLayer); printDocument.DefaultPageSettings.Landscape = true; var printHeight = printDocument.DefaultPageSettings.PaperSize.Height; var printWidth = printDocument.DefaultPageSettings.PaperSize.Width; var drawingArea = new Rectangle(0, 0, printHeight, printWidth); if (pagePrinterLayer.Orientation == PrinterOrientation.Portrait) { printDocument.DefaultPageSettings.Landscape = false; drawingArea = new Rectangle(0, 0, printWidth, printHeight); } printerGeoCanvas.DrawingArea = drawingArea; printerGeoCanvas.BeginDrawing(printDocument, pagePrinterLayer.GetBoundingBox(), printMap.MapUnit); try { SetLegendIsPrinting(true, printerOverlay); SetDescriptionLabelVisible(false, printerOverlay); Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>(); foreach (PrinterLayer printerLayer in printerOverlay.PrinterLayers.Where(l => !(l is PagePrinterLayer))) { printerLayer.IsDrawing = true; if (printerLayer is DatePrinterLayer) { string currentDate = DateTime.Now.ToString(((DatePrinterLayer)printerLayer).DateFormat); ((DatePrinterLayer)printerLayer).DateString = currentDate; } if (printerLayer is ProjectPathPrinterLayer) { string projectPath = ((ProjectPathPrinterLayer)printerLayer).ProjectPath; Uri uri = GisEditor.ProjectManager.ProjectUri; if (!File.Exists(projectPath) && File.Exists(uri.LocalPath)) { ((ProjectPathPrinterLayer)printerLayer).ProjectPath = uri.LocalPath; } } SimplifyMapPrinterLayer mapPrinterLayer = null; if (printerLayer.GetType() == typeof(SimplifyMapPrinterLayer)) { printerLayer.IsDrawing = false; mapPrinterLayer = printerLayer as SimplifyMapPrinterLayer; if (mapPrinterLayer.BackgroundMask != null) { mapPrinterLayer.BackgroundMask.DrawingLevel = DrawingLevel.LevelOne; } mapPrinterLayer.DrawingMode = MapPrinterDrawingMode.Vector; } printerLayer.Draw(printerGeoCanvas, labelsInAllLayers); printerLayer.IsDrawing = false; printerGeoCanvas.Flush(); if (printerLayer is DatePrinterLayer) { ((DatePrinterLayer)printerLayer).DateString = DateElementViewModel.DefaultDate.ToString(((DatePrinterLayer)printerLayer).DateFormat); } } foreach (var item in printerOverlay.PrinterLayers.Where(l => l.GetType() == typeof(SimplifyMapPrinterLayer))) { (item as SimplifyMapPrinterLayer).DrawingMode = MapPrinterDrawingMode.Raster; } return(printDocument); } catch (Exception ex) { GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex)); return(printDocument); } finally { SetLegendIsPrinting(false, printerOverlay); SetDescriptionLabelVisible(true, printerOverlay); } }
protected override void LoadFromActiveMapCore(PrinterLayer printerLayer) { SimplifyMapPrinterLayer mapPrinterLayer = null; if (wpfMap != null && (mapPrinterLayer = printerLayer as SimplifyMapPrinterLayer) != null) { if (DoesLoadLayers) { PrinterLayerHelper.AddBaseOverlays(wpfMap, mapPrinterLayer); var allLayers = wpfMap.Overlays.OfType <LayerOverlay>().SelectMany(layerOverlay => layerOverlay.Layers); var allLayerTypes = GisEditor.LayerManager.GetLayerPlugins().Select(layerPlugin => layerPlugin.GetLayerType()); foreach (var layer in allLayers) { if (allLayerTypes.Contains(layer.GetType())) { mapPrinterLayer.Layers.Add(layer); } } var measureOverlay = wpfMap .InteractiveOverlays.OfType <MeasureTrackInteractiveOverlay>().FirstOrDefault(); if (measureOverlay != null && measureOverlay.ShapeLayer.MapShapes.Count > 0) { mapPrinterLayer.Layers.Add(measureOverlay.ShapeLayer); } var annotationOverlay = wpfMap.InteractiveOverlays.OfType <AnnotationTrackInteractiveOverlay>().FirstOrDefault(); if (annotationOverlay != null && annotationOverlay.TrackShapeLayer.InternalFeatures.Count > 0) { annotationOverlay.TrackShapeLayer.Name = "AnnotationLayer"; mapPrinterLayer.Layers.Add(annotationOverlay.TrackShapeLayer); } if (CurrentOverlays.PopupOverlay != null && CurrentOverlays.PopupOverlay.Popups.Count > 0) { var imageByte = GetCroppedMapPopupOverlayPreviewImage(wpfMap, new System.Windows.Int32Rect(0, 0, (int)GisEditor.ActiveMap.RenderSize.Width, (int)GisEditor.ActiveMap.RenderSize.Height)); MemoryRasterLayer layer = new MemoryRasterLayer(new MemoryStream(imageByte)); mapPrinterLayer.Layers.Add(layer); } } mapPrinterLayer.Name = wpfMap.Name; mapPrinterLayer.MapUnit = wpfMap.MapUnit; mapPrinterLayer.DragMode = PrinterDragMode.Draggable; mapPrinterLayer.ResizeMode = PrinterResizeMode.Resizable; mapPrinterLayer.MapExtent = wpfMap.CurrentExtent; //RectangleShape currentMapExtent = GetFixedScaledExtent(boudingBox, wpfMap.CurrentResolution, wpfMap.CurrentExtent); //ResetFixedExtent(mapPrinterLayer, currentMapExtent); mapPrinterLayer.BackgroundMask.Advanced.FillCustomBrush = null; mapPrinterLayer.BackgroundMask.OutlinePen = new GeoPen(GeoColor.StandardColors.Black); var backgroundBrush = wpfMap.BackgroundOverlay.BackgroundBrush as GeoSolidBrush; if (backgroundBrush != null) { mapPrinterLayer.BackgroundMask.FillSolidBrush = backgroundBrush; } else { mapPrinterLayer.BackgroundMask.FillSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.Transparent); } mapPrinterLayer.BackgroundMask.SetDrawingLevel(); } }