private void RefreshPreview(string propertyName)
        {
            if (propertyName != "Preview" && !string.IsNullOrEmpty(selectedFormat.Trim()))
            {
                DatePrinterLayer datePrinterLayer = new DatePrinterLayer();
                datePrinterLayer.LoadFromViewModel(this);
                using (Bitmap bitmap = new Bitmap(460, 50))
                {
                    PlatformGeoCanvas canvas = new PlatformGeoCanvas();
                    canvas.BeginDrawing(bitmap, new RectangleShape(-180, 90, 180, -90), GeographyUnit.Meter);

                    datePrinterLayer.SafeProcess(() =>
                    {
                        datePrinterLayer.Draw(canvas, new Collection <SimpleCandidate>());
                    });

                    canvas.EndDrawing();
                    MemoryStream ms = new MemoryStream();
                    bitmap.Save(ms, ImageFormat.Png);
                    BitmapImage bitmapImage = new BitmapImage();
                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = ms;
                    bitmapImage.EndInit();
                    preview = bitmapImage;
                    RaisePropertyChanged(() => Preview);
                }
            }
        }
Ejemplo n.º 2
0
        public static void LoadFromViewModel(this DatePrinterLayer datePrinterLayer, DateElementViewModel dateElementViewModel)
        {
            DrawingFontStyles drawingFontStyles = DrawingFontStyles.Regular;

            if (dateElementViewModel.IsBold)
            {
                drawingFontStyles = drawingFontStyles | DrawingFontStyles.Bold;
            }
            if (dateElementViewModel.IsItalic)
            {
                drawingFontStyles = drawingFontStyles | DrawingFontStyles.Italic;
            }
            if (dateElementViewModel.IsStrikeout)
            {
                drawingFontStyles = drawingFontStyles | DrawingFontStyles.Strikeout;
            }
            if (dateElementViewModel.IsUnderline)
            {
                drawingFontStyles = drawingFontStyles | DrawingFontStyles.Underline;
            }

            GeoFont font = new GeoFont(dateElementViewModel.FontName.Source, dateElementViewModel.FontSize, drawingFontStyles);

            datePrinterLayer.DateString = dateElementViewModel.SelectedFormat;
            datePrinterLayer.DateFormat = dateElementViewModel.FormatPairs[dateElementViewModel.SelectedFormat];
            datePrinterLayer.Font       = font;
            datePrinterLayer.TextBrush  = dateElementViewModel.FontColor;
            datePrinterLayer.DragMode   = dateElementViewModel.DragMode;
            datePrinterLayer.ResizeMode = dateElementViewModel.ResizeMode;
        }
 internal void SetProperties(DatePrinterLayer printerLayer)
 {
     viewModel.SelectedFormat = DateElementViewModel.DefaultDate.ToString(printerLayer.DateFormat);
     viewModel.FontName       = new FontFamily(printerLayer.Font.FontName);
     viewModel.FontSize       = printerLayer.Font.Size;
     viewModel.IsBold         = (printerLayer.Font.Style & DrawingFontStyles.Bold) == DrawingFontStyles.Bold;
     viewModel.IsItalic       = (printerLayer.Font.Style & DrawingFontStyles.Italic) == DrawingFontStyles.Italic;
     viewModel.IsStrikeout    = (printerLayer.Font.Style & DrawingFontStyles.Strikeout) == DrawingFontStyles.Strikeout;
     viewModel.IsUnderline    = (printerLayer.Font.Style & DrawingFontStyles.Underline) == DrawingFontStyles.Underline;
     viewModel.FontColor      = printerLayer.TextBrush;
     viewModel.DragMode       = printerLayer.DragMode;
     viewModel.ResizeMode     = printerLayer.ResizeMode;
 }
Ejemplo n.º 4
0
        public static DatePrinterLayer GetCurrentDatePrinterLayer(double width, double height, double centerX, double centerY)
        {
            DatePrinterLayer datePrinterLayer = new DatePrinterLayer {
                DrawingExceptionMode = DrawingExceptionMode.DrawException
            };

            datePrinterLayer.LoadFromViewModel(new DateElementViewModel()
            {
                SelectedFormat = DateTime.Now.ToShortDateString(), FontSize = 12
            });
            datePrinterLayer.Open();
            datePrinterLayer.SetPosition(width, height, centerX, centerY, PrintingUnit.Inch);
            return(datePrinterLayer);
        }