private static void OnAdornmentLocationPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { AdornmentLogo currentLogo = (AdornmentLogo)sender; AdornmentLocation newLocation = (AdornmentLocation)e.NewValue; switch (newLocation) { case AdornmentLocation.UseOffsets: case AdornmentLocation.UpperLeft: currentLogo.HorizontalAlignment = HorizontalAlignment.Left; currentLogo.VerticalAlignment = VerticalAlignment.Top; break; case AdornmentLocation.UpperCenter: currentLogo.HorizontalAlignment = HorizontalAlignment.Center; currentLogo.VerticalAlignment = VerticalAlignment.Top; break; case AdornmentLocation.UpperRight: currentLogo.VerticalAlignment = VerticalAlignment.Top; currentLogo.HorizontalAlignment = HorizontalAlignment.Right; break; case AdornmentLocation.CenterLeft: currentLogo.HorizontalAlignment = HorizontalAlignment.Left; currentLogo.VerticalAlignment = VerticalAlignment.Center; break; case AdornmentLocation.Center: currentLogo.HorizontalAlignment = HorizontalAlignment.Center; currentLogo.VerticalAlignment = VerticalAlignment.Center; break; case AdornmentLocation.CenterRight: currentLogo.HorizontalAlignment = HorizontalAlignment.Right; currentLogo.VerticalAlignment = VerticalAlignment.Center; break; case AdornmentLocation.LowerLeft: currentLogo.HorizontalAlignment = HorizontalAlignment.Left; currentLogo.VerticalAlignment = VerticalAlignment.Bottom; break; case AdornmentLocation.LowerCenter: currentLogo.HorizontalAlignment = HorizontalAlignment.Center; currentLogo.VerticalAlignment = VerticalAlignment.Bottom; break; case AdornmentLocation.LowerRight: default: currentLogo.HorizontalAlignment = HorizontalAlignment.Right; currentLogo.VerticalAlignment = VerticalAlignment.Bottom; break; } }
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 VerticalAlignment GetVerticalAlignment(AdornmentLocation location) { if (location == AdornmentLocation.Center || location == AdornmentLocation.CenterLeft || location == AdornmentLocation.CenterRight) { return(VerticalAlignment.Center); } else if (location == AdornmentLocation.LowerCenter || location == AdornmentLocation.LowerLeft || location == AdornmentLocation.LowerRight) { return(VerticalAlignment.Bottom); } else { return(VerticalAlignment.Top); } }
private HorizontalAlignment GetHorizontalAlignment(AdornmentLocation location) { if (location == AdornmentLocation.Center || location == AdornmentLocation.LowerCenter || location == AdornmentLocation.UpperCenter) { return(HorizontalAlignment.Center); } else if (location == AdornmentLocation.CenterLeft || location == AdornmentLocation.LowerLeft || location == AdornmentLocation.UpperLeft) { return(HorizontalAlignment.Left); } else { return(HorizontalAlignment.Right); } }
public static void SetPosition(AdornmentLocation location, RectangleShape boudingBox, PrinterLayer printerLayer, double width, double height, double left, double top) { switch (location) { case AdornmentLocation.UseOffsets: printerLayer.SetPosition(width, height, 0, 0, PrintingUnit.Inch); break; case AdornmentLocation.UpperLeft: printerLayer.SetPosition(width, height, boudingBox.UpperLeftPoint.X + width * 0.5 + left, boudingBox.UpperLeftPoint.Y - height * 0.5 - top, PrintingUnit.Inch); break; case AdornmentLocation.UpperCenter: printerLayer.SetPosition(width, height, left, boudingBox.UpperLeftPoint.Y - height * 0.5 - top, PrintingUnit.Inch); break; case AdornmentLocation.UpperRight: printerLayer.SetPosition(width, height, boudingBox.UpperRightPoint.X - width * 0.5 + left, boudingBox.UpperLeftPoint.Y - height * 0.5 - top, PrintingUnit.Inch); break; case AdornmentLocation.CenterLeft: printerLayer.SetPosition(width, height, boudingBox.UpperLeftPoint.X + width * 0.5 + left, -top, PrintingUnit.Inch); break; case AdornmentLocation.Center: printerLayer.SetPosition(width, height, left, -top, PrintingUnit.Inch); break; case AdornmentLocation.CenterRight: printerLayer.SetPosition(width, height, boudingBox.UpperRightPoint.X - width * 0.5 + left, -top, PrintingUnit.Inch); break; case AdornmentLocation.LowerLeft: printerLayer.SetPosition(width, height, boudingBox.UpperLeftPoint.X + width * 0.5 + left, boudingBox.LowerLeftPoint.Y + height * 0.5 - top, PrintingUnit.Inch); break; case AdornmentLocation.LowerCenter: printerLayer.SetPosition(width, height, left, boudingBox.LowerLeftPoint.Y + height * 0.5 - top, PrintingUnit.Inch); break; case AdornmentLocation.LowerRight: printerLayer.SetPosition(width, height, boudingBox.UpperRightPoint.X - width * 0.5 + left, boudingBox.LowerLeftPoint.Y + height * 0.5 - top, PrintingUnit.Inch); break; } }