Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
 protected override PrinterLayer GetPrinterLayerFromActiveMapCore(RectangleShape boudingBox)
 {
     if (scaleLineAdornmentLayer != null)
     {
         ScaleLinePrinterLayer scaleLinePrinterLayer = new ScaleLinePrinterLayer(mapPrinterLayer);
         LoadFromActiveMap(scaleLinePrinterLayer);
         double left = PrinterHelper.ConvertLength(scaleLineAdornmentLayer.XOffsetInPixel, PrintingUnit.Point, PrintingUnit.Inch);
         double top  = PrinterHelper.ConvertLength(scaleLineAdornmentLayer.YOffsetInPixel, PrintingUnit.Point, PrintingUnit.Inch);
         PrinterLayerAdapter.SetPosition(scaleLineAdornmentLayer.Location, boudingBox, scaleLinePrinterLayer, boudingBox.Width * 0.1, 0.5, left, top);
         return(scaleLinePrinterLayer);
     }
     else
     {
         return(null);
     }
 }
        public static RectangleShape GetFixedScaledExtent(RectangleShape bbox, double currentResolution, RectangleShape sourceExtent)
        {
            if (AppMenuUIPlugin.PreserveScale)
            {
                double widthDistanceInPoint  = PrinterHelper.ConvertLength(bbox.Width, PrintingUnit.Inch, PrintingUnit.Point);
                double heightDistanceInPoint = PrinterHelper.ConvertLength(bbox.Height, PrintingUnit.Inch, PrintingUnit.Point);

                double         halfWidthDistanceInMapUnit  = widthDistanceInPoint * .5 * currentResolution;
                double         halfHeightDistanceInMapUnit = heightDistanceInPoint * .5 * currentResolution;
                PointShape     currentCenter    = sourceExtent.GetCenterPoint();
                RectangleShape currentMapExtent = new RectangleShape(currentCenter.X - halfWidthDistanceInMapUnit, currentCenter.Y + halfHeightDistanceInMapUnit, currentCenter.X + halfWidthDistanceInMapUnit, currentCenter.Y - halfHeightDistanceInMapUnit);
                return(currentMapExtent);
            }
            else
            {
                return(sourceExtent);
            }
        }
Exemplo n.º 4
0
 private void CbxUnit_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (IsLoaded)
     {
         if (ResultUnit == PrintingUnit.Inch)
         {
             MarginLeft   = Math.Round(PrinterHelper.ConvertLength(MarginLeft, PrintingUnit.Centimeter, PrintingUnit.Inch), 1);
             MarginTop    = Math.Round(PrinterHelper.ConvertLength(MarginTop, PrintingUnit.Centimeter, PrintingUnit.Inch), 1);
             MarginRight  = Math.Round(PrinterHelper.ConvertLength(MarginRight, PrintingUnit.Centimeter, PrintingUnit.Inch), 1);
             MarginBottom = Math.Round(PrinterHelper.ConvertLength(MarginBottom, PrintingUnit.Centimeter, PrintingUnit.Inch), 1);
         }
         else
         {
             MarginLeft   = Math.Round(PrinterHelper.ConvertLength(MarginLeft, PrintingUnit.Inch, PrintingUnit.Centimeter), 1);
             MarginTop    = Math.Round(PrinterHelper.ConvertLength(MarginTop, PrintingUnit.Inch, PrintingUnit.Centimeter), 1);
             MarginRight  = Math.Round(PrinterHelper.ConvertLength(MarginRight, PrintingUnit.Inch, PrintingUnit.Centimeter), 1);
             MarginBottom = Math.Round(PrinterHelper.ConvertLength(MarginBottom, PrintingUnit.Inch, PrintingUnit.Centimeter), 1);
         }
     }
 }
Exemplo n.º 5
0
        protected override PrinterLayer GetPrinterLayerFromActiveMapCore(RectangleShape boudingBox)
        {
            if (this.titleAdornmentLayer != null)
            {
                LabelPrinterLayer printerLayer = new LabelPrinterLayer();
                LoadFromActiveMap(printerLayer);
                var newScreenBBox = new PlatformGeoCanvas().MeasureText(printerLayer.Text, printerLayer.Font);
                var scaledWidth   = newScreenBBox.Width * 1.1;
                var scaledHeight  = newScreenBBox.Height * 1.1;

                double width  = PrinterHelper.ConvertLength(scaledWidth, PrintingUnit.Point, PrintingUnit.Inch);
                double height = PrinterHelper.ConvertLength(scaledHeight, PrintingUnit.Point, PrintingUnit.Inch);
                double left   = PrinterHelper.ConvertLength(titleAdornmentLayer.XOffsetInPixel, PrintingUnit.Point, PrintingUnit.Inch);
                double top    = PrinterHelper.ConvertLength(titleAdornmentLayer.YOffsetInPixel, PrintingUnit.Point, PrintingUnit.Inch);
                SetPosition(titleAdornmentLayer.Location, boudingBox, printerLayer, width, height, left, top);
                return(printerLayer);
            }
            else
            {
                return(null);
            }
        }
 protected override PrinterLayer GetPrinterLayerFromActiveMapCore(RectangleShape boudingBox)
 {
     if (legendAdornmentLayer != null)
     {
         LegendPrinterLayer printerLayer = new GisEditorLegendPrinterLayer();
         double             width        = 0;
         double             height       = 0;
         SetPropertiesInGeneral(legendAdornmentLayer, printerLayer);
         width   = width > legendAdornmentLayer.Width ? width : legendAdornmentLayer.Width;
         height += legendAdornmentLayer.Height;
         width   = PrinterHelper.ConvertLength(width, PrintingUnit.Point, PrintingUnit.Inch);
         height  = PrinterHelper.ConvertLength(height, PrintingUnit.Point, PrintingUnit.Inch);
         double left = PrinterHelper.ConvertLength(legendAdornmentLayer.XOffsetInPixel, PrintingUnit.Point, PrintingUnit.Inch);
         double top  = PrinterHelper.ConvertLength(legendAdornmentLayer.YOffsetInPixel, PrintingUnit.Point, PrintingUnit.Inch);
         SetPosition(legendAdornmentLayer.Location, boudingBox, printerLayer, width, height, left, top);
         return(printerLayer);
     }
     else
     {
         return(null);
     }
 }
        protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers)
        {
            base.DrawCore(canvas, labelsInAllLayers);
            var    pageBindingBox = GetBoundingBox();
            double leftInPoint    = PrinterHelper.ConvertLength(left, marginUnit, PrintingUnit.Point);
            double topInPoint     = PrinterHelper.ConvertLength(top, marginUnit, PrintingUnit.Point);
            double rightInPoint   = PrinterHelper.ConvertLength(right, marginUnit, PrintingUnit.Point);
            double bottomInPoint  = PrinterHelper.ConvertLength(bottom, marginUnit, PrintingUnit.Point);

            PointShape     upperLeft     = new PointShape(pageBindingBox.UpperLeftPoint.X + leftInPoint, pageBindingBox.UpperLeftPoint.Y - topInPoint);
            PointShape     lowerRight    = new PointShape(pageBindingBox.LowerRightPoint.X - rightInPoint, pageBindingBox.LowerRightPoint.Y + bottomInPoint);
            RectangleShape newBindingBox = new RectangleShape(upperLeft, lowerRight);

            var columnsCount = columns;
            var rowsCount    = rows;

            double widthIncrease  = newBindingBox.Width / columnsCount;
            double heightIncrease = newBindingBox.Height / rowsCount;

            if (useCellSize)
            {
                double width  = PrinterHelper.ConvertLength(cellWidth, cellUnit, PrintingUnit.Point);
                double height = PrinterHelper.ConvertLength(cellHeight, cellUnit, PrintingUnit.Point);

                if (newBindingBox.Width < width ||
                    newBindingBox.Height < height)
                {
                    return;
                }

                columnsCount = (int)(newBindingBox.Width / width);
                rowsCount    = (int)(newBindingBox.Height / height);

                widthIncrease  = width;
                heightIncrease = height;
            }

            double horizontalLineX1 = newBindingBox.UpperLeftPoint.X;
            double horizontalLineX2 = newBindingBox.UpperRightPoint.X;

            for (int i = 0; i <= rowsCount; i++)
            {
                LineShape horizontalLine            = new LineShape();
                var       horizontalLineFirstPoint  = new Vertex(horizontalLineX1, newBindingBox.UpperLeftPoint.Y - (i) * heightIncrease);
                var       horizontalLineSecondPoint = new Vertex(horizontalLineX2, newBindingBox.UpperRightPoint.Y - (i) * heightIncrease);
                horizontalLine.Vertices.Add(horizontalLineFirstPoint);
                horizontalLine.Vertices.Add(horizontalLineSecondPoint);
                canvas.DrawLine(horizontalLine, drawingPen, DrawingLevel.LabelLevel);
            }

            LineShape lastHorizontalLine            = new LineShape();
            var       lastHorizontalLineFirstPoint  = new Vertex(horizontalLineX1, newBindingBox.LowerLeftPoint.Y);
            var       lastHorizontalLineSecondPoint = new Vertex(horizontalLineX2, newBindingBox.LowerRightPoint.Y);

            lastHorizontalLine.Vertices.Add(lastHorizontalLineFirstPoint);
            lastHorizontalLine.Vertices.Add(lastHorizontalLineSecondPoint);
            canvas.DrawLine(lastHorizontalLine, drawingPen, DrawingLevel.LabelLevel);

            double verticalLineY1 = newBindingBox.UpperLeftPoint.Y;
            double verticalLineY2 = newBindingBox.LowerRightPoint.Y;

            for (int i = 0; i <= columnsCount; i++)
            {
                LineShape verticalLine            = new LineShape();
                var       verticalLineX           = newBindingBox.UpperLeftPoint.X + (i) * widthIncrease;
                var       verticalLineFirstPoint  = new Vertex(verticalLineX, verticalLineY1);
                var       verticalLineSecondPoint = new Vertex(verticalLineX, verticalLineY2);
                verticalLine.Vertices.Add(verticalLineFirstPoint);
                verticalLine.Vertices.Add(verticalLineSecondPoint);
                canvas.DrawLine(verticalLine, drawingPen, DrawingLevel.LabelLevel);
            }

            LineShape lastVerticalLine                = new LineShape();
            var       lastVerticalLineFirstPoint      = new Vertex(newBindingBox.UpperRightPoint.X, verticalLineY1);
            var       lastVerticalLineLineSecondPoint = new Vertex(newBindingBox.UpperRightPoint.X, verticalLineY2);

            lastVerticalLine.Vertices.Add(lastVerticalLineFirstPoint);
            lastVerticalLine.Vertices.Add(lastVerticalLineLineSecondPoint);
            canvas.DrawLine(lastVerticalLine, drawingPen, DrawingLevel.LabelLevel);
        }