public static void LoadFromViewModel(this ProjectPathPrinterLayer projectPathPrinterLayer, ProjectPathElementViewModel projectPathElementViewModel) { DrawingFontStyles drawingFontStyles = DrawingFontStyles.Regular; if (projectPathElementViewModel.IsBold) { drawingFontStyles = drawingFontStyles | DrawingFontStyles.Bold; } if (projectPathElementViewModel.IsItalic) { drawingFontStyles = drawingFontStyles | DrawingFontStyles.Italic; } if (projectPathElementViewModel.IsStrikeout) { drawingFontStyles = drawingFontStyles | DrawingFontStyles.Strikeout; } if (projectPathElementViewModel.IsUnderline) { drawingFontStyles = drawingFontStyles | DrawingFontStyles.Underline; } GeoFont font = new GeoFont(projectPathElementViewModel.FontName.Source, projectPathElementViewModel.FontSize, drawingFontStyles); projectPathPrinterLayer.ProjectPath = projectPathElementViewModel.ProjectPath; projectPathPrinterLayer.Font = font; projectPathPrinterLayer.TextBrush = projectPathElementViewModel.FontColor; projectPathPrinterLayer.DragMode = projectPathElementViewModel.DragMode; projectPathPrinterLayer.ResizeMode = projectPathElementViewModel.ResizeMode; }
private void RefreshPreview(string propertyName) { if (propertyName != "Preview" && !string.IsNullOrEmpty(ProjectPath.Trim())) { ProjectPathPrinterLayer projectPathPrinterLayer = new ProjectPathPrinterLayer(); projectPathPrinterLayer.LoadFromViewModel(this); using (Bitmap bitmap = new Bitmap(460, 50)) { PlatformGeoCanvas canvas = new PlatformGeoCanvas(); canvas.BeginDrawing(bitmap, new RectangleShape(-180, 90, 180, -90), GeographyUnit.Meter); projectPathPrinterLayer.SafeProcess(() => { projectPathPrinterLayer.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); } } }
internal void SetProperties(ProjectPathPrinterLayer printerLayer) { viewModel.ProjectPath = printerLayer.ProjectPath; 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; }