internal static bool CheckDecimalDegreeIsInRange(RectangleShape extent) { var uLPoint = extent.UpperLeftPoint; var lRPoint = extent.LowerRightPoint; if (PrinterLayerHelper.CheckDecimalDegreeLatitudeIsInRange(uLPoint.Y) && PrinterLayerHelper.CheckDecimalDegreeLongitudeIsInRange(uLPoint.X) && PrinterLayerHelper.CheckDecimalDegreeLatitudeIsInRange(lRPoint.Y) && PrinterLayerHelper.CheckDecimalDegreeLongitudeIsInRange(lRPoint.X)) { return(true); } else { return(false); } }
private void SetPropertiesInGeneral(LegendAdornmentLayer legendLayer, LegendPrinterLayer legendPrinterLayer) { legendPrinterLayer.LegendItems.Clear(); foreach (var item in legendLayer.LegendItems) { var copiedItem = PrinterLayerHelper.CloneDeep <LegendItem>(item); if (copiedItem != null) { copiedItem.SetDrawingLevel(); legendPrinterLayer.LegendItems.Add(copiedItem); } } legendPrinterLayer.Width = legendLayer.Width; legendPrinterLayer.Height = legendLayer.Height; legendPrinterLayer.BackgroundMask = PrinterLayerHelper.CloneDeep <AreaStyle>(legendLayer.BackgroundMask); legendPrinterLayer.BackgroundMask.SetDrawingLevel(); legendPrinterLayer.Title = legendLayer.Title; legendPrinterLayer.Footer = legendLayer.Footer; legendPrinterLayer.XOffsetInPixel = legendLayer.XOffsetInPixel; legendPrinterLayer.YOffsetInPixel = legendLayer.YOffsetInPixel; }
public static IEnumerable <LayoutViewModel> GetAllLayouts(RectangleShape portraitPageBoudingBox, RectangleShape landscapePageBoudingBox, PrinterPageSize pageSize) { LayoutViewModel entity1 = new LayoutViewModel() { Orientation = FilterPageOrientation.Portrait, PageSize = pageSize, Image = string.Format(CultureInfo.InvariantCulture, imagePathFormat, 1, "small"), Description = GisEditor.LanguageManager.GetStringResource("NewLayoutViewModelSimpleLayoutDescription") }; var titleWidth = portraitPageBoudingBox.Width * 0.25; var titleHeight = titleWidth * 0.5; entity1.PrinterLayers.Add(PrinterLayerHelper.GetMapPrinterLayer(portraitPageBoudingBox.Width * 0.8, portraitPageBoudingBox.Height * 0.8, 0, -titleHeight * 0.7)); entity1.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Title", titleWidth, titleHeight, 0, portraitPageBoudingBox.UpperLeftPoint.Y - titleHeight)); yield return(entity1); LayoutViewModel entity2 = new LayoutViewModel() { Orientation = FilterPageOrientation.Portrait, PageSize = pageSize, Image = string.Format(CultureInfo.InvariantCulture, imagePathFormat, 2, "small"), Description = GisEditor.LanguageManager.GetStringResource("NewLayoutViewModelTitleImageTextDescription") }; entity2.PrinterLayers.Add(PrinterLayerHelper.GetMapPrinterLayer(portraitPageBoudingBox.Width * 0.8, portraitPageBoudingBox.Height * 0.5, 0, 0)); entity2.PrinterLayers.Add(PrinterLayerHelper.GetImagePrinterLayer(portraitPageBoudingBox.Width * 0.2, portraitPageBoudingBox.Width * 0.2, -portraitPageBoudingBox.Width * 0.25, portraitPageBoudingBox.LowerLeftPoint.Y + titleHeight)); entity2.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Text", titleWidth, titleHeight, portraitPageBoudingBox.Width * 0.25, portraitPageBoudingBox.LowerLeftPoint.Y + titleHeight)); entity2.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Title", titleWidth, titleHeight, 0, portraitPageBoudingBox.UpperLeftPoint.Y - titleHeight)); yield return(entity2); LayoutViewModel entity3 = new LayoutViewModel() { Orientation = FilterPageOrientation.Portrait, PageSize = pageSize, Image = string.Format(CultureInfo.InvariantCulture, imagePathFormat, 3, "small"), Description = GisEditor.LanguageManager.GetStringResource("NewLayoutViewModelFeatureTitleDescription") }; entity3.PrinterLayers.Add(PrinterLayerHelper.GetMapPrinterLayer(portraitPageBoudingBox.Width * 0.8, portraitPageBoudingBox.Height * 0.5, 0, titleHeight * 0.5)); entity3.PrinterLayers.Add(PrinterLayerHelper.GetDataGridPrinterLayer(portraitPageBoudingBox.Width * 0.8, portraitPageBoudingBox.Height * 0.2, 0, portraitPageBoudingBox.LowerLeftPoint.Y + titleHeight * 1.5)); entity3.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Title", titleWidth, titleHeight, 0, portraitPageBoudingBox.UpperLeftPoint.Y - titleHeight)); yield return(entity3); LayoutViewModel entity4 = new LayoutViewModel() { Orientation = FilterPageOrientation.Portrait, PageSize = pageSize, Image = string.Format(CultureInfo.InvariantCulture, imagePathFormat, 4, "small"), Description = GisEditor.LanguageManager.GetStringResource("NewLayoutViewModelCondensedLayoutDescription") }; var map = PrinterLayerHelper.GetMapPrinterLayer(portraitPageBoudingBox.Width * 0.9, portraitPageBoudingBox.Height * 0.5, 0, titleHeight * 0.5); entity4.PrinterLayers.Add(map); entity4.PrinterLayers.Add(PrinterLayerHelper.GetLegendPrinterLayer(portraitPageBoudingBox.Width * 0.3, portraitPageBoudingBox.Height * 0.2, portraitPageBoudingBox.Width * -0.3, portraitPageBoudingBox.LowerLeftPoint.Y + titleHeight * 1.5)); entity4.PrinterLayers.Add(PrinterLayerHelper.GetScaleBarPrinterLayer(map, portraitPageBoudingBox.Width * 0.2, portraitPageBoudingBox.Height * 0.02, 0, portraitPageBoudingBox.LowerLeftPoint.Y + titleHeight * 2.5)); entity4.PrinterLayers.Add(PrinterLayerHelper.GetImagePrinterLayer(portraitPageBoudingBox.Width * 0.3, portraitPageBoudingBox.Height * 0.18, 0, portraitPageBoudingBox.LowerLeftPoint.Y + titleHeight * 1.5)); entity4.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Text", portraitPageBoudingBox.Width * 0.3, portraitPageBoudingBox.Height * 0.2, portraitPageBoudingBox.Width * 0.3, portraitPageBoudingBox.LowerLeftPoint.Y + titleHeight * 1.8)); entity4.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Title", titleWidth, titleHeight, 0, portraitPageBoudingBox.UpperLeftPoint.Y - titleHeight)); yield return(entity4); LayoutViewModel entity5 = new LayoutViewModel() { Orientation = FilterPageOrientation.Landscape, PageSize = pageSize, Image = string.Format(CultureInfo.InvariantCulture, imagePathFormat, 5, "small"), Description = GisEditor.LanguageManager.GetStringResource("NewLayoutViewModelSimpleLayoutDescription") }; entity5.PrinterLayers.Add(PrinterLayerHelper.GetMapPrinterLayer(landscapePageBoudingBox.Width * 0.9, landscapePageBoudingBox.Height * 0.7, 0, -titleHeight)); entity5.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Title", titleWidth, titleHeight, 0, landscapePageBoudingBox.UpperLeftPoint.Y - titleHeight)); yield return(entity5); LayoutViewModel entity6 = new LayoutViewModel() { Orientation = FilterPageOrientation.Landscape, PageSize = pageSize, Image = string.Format(CultureInfo.InvariantCulture, imagePathFormat, 6, "small"), Description = GisEditor.LanguageManager.GetStringResource("NewLayoutViewModelTitleImageTextDescription") }; entity6.PrinterLayers.Add(PrinterLayerHelper.GetMapPrinterLayer(landscapePageBoudingBox.Width * 0.65, landscapePageBoudingBox.Height * 0.7, -landscapePageBoudingBox.Width * 0.15, -titleHeight)); entity6.PrinterLayers.Add(PrinterLayerHelper.GetImagePrinterLayer(landscapePageBoudingBox.Width * 0.2, landscapePageBoudingBox.Width * 0.2, landscapePageBoudingBox.Width * 0.3, landscapePageBoudingBox.Height * 0.15)); entity6.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Text", titleWidth, titleHeight, landscapePageBoudingBox.Width * 0.3, landscapePageBoudingBox.Height * -0.25)); entity6.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Title", titleWidth, titleHeight, 0, landscapePageBoudingBox.UpperLeftPoint.Y - titleHeight)); yield return(entity6); LayoutViewModel entity7 = new LayoutViewModel() { Orientation = FilterPageOrientation.Landscape, PageSize = pageSize, Image = string.Format(CultureInfo.InvariantCulture, imagePathFormat, 7, "small"), Description = GisEditor.LanguageManager.GetStringResource("NewLayoutViewModelFeatureTitleDescription") }; entity7.PrinterLayers.Add(PrinterLayerHelper.GetMapPrinterLayer(landscapePageBoudingBox.Width * 0.6, landscapePageBoudingBox.Height * 0.7, landscapePageBoudingBox.Width * -0.16, -titleHeight * 0.8)); entity7.PrinterLayers.Add(PrinterLayerHelper.GetDataGridPrinterLayer(landscapePageBoudingBox.Width * 0.3, landscapePageBoudingBox.Height * 0.7, landscapePageBoudingBox.Width * 0.32, -titleHeight * 0.8)); entity7.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Title", titleWidth, titleHeight, 0, landscapePageBoudingBox.UpperLeftPoint.Y - titleHeight)); yield return(entity7); LayoutViewModel entity8 = new LayoutViewModel() { Orientation = FilterPageOrientation.Landscape, PageSize = pageSize, Image = string.Format(CultureInfo.InvariantCulture, imagePathFormat, 8, "small"), Description = GisEditor.LanguageManager.GetStringResource("NewLayoutViewModelFeatureTitleDescription") }; var map8 = PrinterLayerHelper.GetMapPrinterLayer(landscapePageBoudingBox.Width * 0.6, landscapePageBoudingBox.Height * 0.7, landscapePageBoudingBox.Width * -0.16, -titleHeight * 0.8); entity8.PrinterLayers.Add(map8); entity8.PrinterLayers.Add(PrinterLayerHelper.GetScaleBarPrinterLayer(map8, landscapePageBoudingBox.Width * 0.15, landscapePageBoudingBox.Height * 0.1, landscapePageBoudingBox.Width * -0.36, landscapePageBoudingBox.Height * -0.45)); entity8.PrinterLayers.Add(PrinterLayerHelper.GetImagePrinterLayer(landscapePageBoudingBox.Width * 0.2, landscapePageBoudingBox.Height * 0.2, landscapePageBoudingBox.Width * 0.3, landscapePageBoudingBox.Height * 0.25)); entity8.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Text", landscapePageBoudingBox.Width * 0.2, landscapePageBoudingBox.Height * 0.2, landscapePageBoudingBox.Width * 0.3, 0)); entity8.PrinterLayers.Add(PrinterLayerHelper.GetLegendPrinterLayer(landscapePageBoudingBox.Width * 0.2, landscapePageBoudingBox.Height * 0.3, landscapePageBoudingBox.Width * 0.3, landscapePageBoudingBox.Height * -0.25)); entity8.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Title", titleWidth, titleHeight, 0, landscapePageBoudingBox.UpperLeftPoint.Y - titleHeight)); yield return(entity8); LayoutViewModel entity9 = new LayoutViewModel() { Orientation = FilterPageOrientation.Landscape, PageSize = pageSize, Image = string.Format(CultureInfo.InvariantCulture, imagePathFormat, 9, "small"), Description = GisEditor.LanguageManager.GetStringResource("NewLayoutViewModelSimpleLayoutDescription") }; entity9.PrinterLayers.Add(PrinterLayerHelper.GetMapPrinterLayer(landscapePageBoudingBox.Width * 0.9, landscapePageBoudingBox.Height * 0.7, 0, -titleHeight)); entity9.PrinterLayers.Add(PrinterLayerHelper.GetLabelPrinterLayer("Title", titleWidth, titleHeight, 0, landscapePageBoudingBox.UpperLeftPoint.Y - titleHeight)); entity9.PrinterLayers.Add(PrinterLayerHelper.GetCurrentDatePrinterLayer(2, 1, 3.5, -3.5)); yield return(entity9); }
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)); } }
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(); } }