private void ScaleBarViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName != "Preview")
     {
         ScaleBarPrinterLayer scaleBarPrinterLayer = new ScaleBarPrinterLayer(MapPrinterLayer);
         scaleBarPrinterLayer.BackgroundMask          = Background as AreaStyle;
         scaleBarPrinterLayer.BarBrush                = Color;
         scaleBarPrinterLayer.AlternateBarBrush       = AlternatingColor;
         scaleBarPrinterLayer.TextStyle.NumericFormat = NumericFormatString;
         scaleBarPrinterLayer.UnitFamily              = SelectedUnitSystem;
         scaleBarPrinterLayer.DragMode                = DragMode;
         scaleBarPrinterLayer.ResizeMode              = ResizeMode;
         scaleBarPrinterLayer.Open();
         scaleBarPrinterLayer.MapUnit = MapPrinterLayer.MapUnit;
         scaleBarPrinterLayer.SetPosition(1.25, .25, -3.25, -2.25, PrintingUnit.Inch);
         var boundingBox = scaleBarPrinterLayer.GetBoundingBox();
         //using (Bitmap bitmap = new Bitmap((int)boundingBox.Width, (int)boundingBox.Height))
         using (Bitmap bitmap = new Bitmap(210, 56))
         {
             var ms = new MemoryStream();
             var gdiPlusGeoCanvas = new PlatformGeoCanvas();
             gdiPlusGeoCanvas.BeginDrawing(bitmap, boundingBox, GeographyUnit.Feet);
             scaleBarPrinterLayer.Draw(gdiPlusGeoCanvas, new Collection <SimpleCandidate>());
             gdiPlusGeoCanvas.EndDrawing();
             bitmap.Save(ms, ImageFormat.Png);
             BitmapImage previewImage = new BitmapImage();
             previewImage.BeginInit();
             previewImage.StreamSource = ms;
             previewImage.EndInit();
             Preview = previewImage;
         }
     }
 }
Example #2
0
        internal void SetProperties(PrinterLayer printerLayer)
        {
            ScaleBarPrinterLayer scaleBarPrinterLayer = printerLayer as ScaleBarPrinterLayer;

            if (scaleBarPrinterLayer != null)
            {
                viewModel.Background       = scaleBarPrinterLayer.BackgroundMask;
                viewModel.Color            = scaleBarPrinterLayer.BarBrush;
                viewModel.AlternatingColor = scaleBarPrinterLayer.AlternateBarBrush;

                switch (scaleBarPrinterLayer.TextStyle.NumericFormat)
                {
                case "C":
                    viewModel.SelectedNumericFormatType = ScaleNumericFormatType.Currency;
                    break;

                case "D":
                    viewModel.SelectedNumericFormatType = ScaleNumericFormatType.Decimal;
                    break;

                case "E":
                    viewModel.SelectedNumericFormatType = ScaleNumericFormatType.Scientific;
                    break;

                case "F":
                    viewModel.SelectedNumericFormatType = ScaleNumericFormatType.FixedPoint;
                    break;

                case "G":
                    viewModel.SelectedNumericFormatType = ScaleNumericFormatType.General;
                    break;

                case "N":
                    viewModel.SelectedNumericFormatType = ScaleNumericFormatType.Number;
                    break;

                case "P":
                    viewModel.SelectedNumericFormatType = ScaleNumericFormatType.Percent;
                    break;

                case "R":
                    viewModel.SelectedNumericFormatType = ScaleNumericFormatType.RoundTrip;
                    break;

                case "X":
                    viewModel.SelectedNumericFormatType = ScaleNumericFormatType.Hexadecimal;
                    break;

                case "":
                default:
                    viewModel.SelectedNumericFormatType = ScaleNumericFormatType.None;
                    break;
                }

                viewModel.SelectedUnitSystem = scaleBarPrinterLayer.UnitFamily;
                viewModel.DragMode           = scaleBarPrinterLayer.DragMode;
                viewModel.ResizeMode         = scaleBarPrinterLayer.ResizeMode;
            }
        }
Example #3
0
 public static void LoadFromViewModel(this ScaleBarPrinterLayer scaleBarPrinterLayer, ScaleBarElementViewModel scaleBarElementEntity)
 {
     scaleBarPrinterLayer.BackgroundMask          = scaleBarElementEntity.Background;
     scaleBarPrinterLayer.BarBrush                = scaleBarElementEntity.Color;
     scaleBarPrinterLayer.AlternateBarBrush       = scaleBarElementEntity.AlternatingColor;
     scaleBarPrinterLayer.TextStyle.NumericFormat = scaleBarElementEntity.NumericFormatString;
     scaleBarPrinterLayer.UnitFamily              = scaleBarElementEntity.SelectedUnitSystem;
     scaleBarPrinterLayer.DragMode                = scaleBarElementEntity.DragMode;
     scaleBarPrinterLayer.ResizeMode              = scaleBarElementEntity.ResizeMode;
     scaleBarPrinterLayer.MapUnit = scaleBarPrinterLayer.MapPrinterLayer.MapUnit;
 }
Example #4
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);
        }
        internal static ScaleBarPrinterLayer GetScaleBarPrinterLayer(ScaleBarElementViewModel scaleBarViewModel)
        {
            ScaleBarPrinterLayer scaleBarPrinterLayer = new ScaleBarPrinterLayer(scaleBarViewModel.MapPrinterLayer)
            {
                DrawingExceptionMode = DrawingExceptionMode.DrawException
            };

            scaleBarPrinterLayer.LoadFromViewModel(scaleBarViewModel);
            scaleBarPrinterLayer.Open();
            RectangleShape pageBoundingbox = scaleBarViewModel.MapPrinterLayer.GetPosition(PrintingUnit.Inch);
            var            pageCenter      = pageBoundingbox.LowerLeftPoint;

            scaleBarPrinterLayer.SetPosition(1.25, .25, pageCenter.X + 0.75, pageCenter.Y + .5, PrintingUnit.Inch);
            return(scaleBarPrinterLayer);
        }
        protected override PrinterLayer GetPrinterLayerFromActiveMapCore(RectangleShape boudingBox)
        {
            if (scaleBarAdornmentLayer != null)
            {
                ScaleBarPrinterLayer printerLayer = new ScaleBarPrinterLayer(this.mapPrinterLayer);
                LoadFromActiveMap(printerLayer);
                double left = PrinterHelper.ConvertLength(scaleBarAdornmentLayer.XOffsetInPixel, PrintingUnit.Point, PrintingUnit.Inch);
                double top  = PrinterHelper.ConvertLength(scaleBarAdornmentLayer.YOffsetInPixel, PrintingUnit.Point, PrintingUnit.Inch);
                PrinterLayerAdapter.SetPosition(scaleBarAdornmentLayer.Location, boudingBox, printerLayer, boudingBox.Width * 0.1, 0.5, left, top);

                return(printerLayer);
            }
            else
            {
                return(null);
            }
        }
        protected override void LoadFromActiveMapCore(PrinterLayer printerLayer)
        {
            ScaleBarPrinterLayer scaleBarPrinterLayer = null;

            if (scaleBarAdornmentLayer != null && (scaleBarPrinterLayer = printerLayer as ScaleBarPrinterLayer) != null)
            {
                scaleBarPrinterLayer.AlternateBarBrush = scaleBarAdornmentLayer.AlternateBarBrush;
                var backgroundStyle = scaleBarAdornmentLayer.BackgroundMask.CloneDeep() as AreaStyle;
                if (backgroundStyle != null)
                {
                    backgroundStyle.SetDrawingLevel();
                    scaleBarPrinterLayer.BackgroundMask = backgroundStyle;
                }
                scaleBarPrinterLayer.BarBrush = scaleBarAdornmentLayer.BarBrush;
                scaleBarPrinterLayer.TextStyle.NumericFormat = scaleBarAdornmentLayer.TextStyle.NumericFormat;
                scaleBarPrinterLayer.UnitFamily      = scaleBarAdornmentLayer.UnitFamily;
                scaleBarPrinterLayer.MapPrinterLayer = mapPrinterLayer;
                scaleBarPrinterLayer.MapUnit         = scaleBarPrinterLayer.MapPrinterLayer.MapUnit;
            }
        }