private void GetLayoutTemplates(PaperSize paperSize) { string path = _folderService.GetBookTemplateFolder(paperSize.ToString()); Layouts = new ObservableCollection <BookLayout>(_bookLayoutService.LoadLayoutsFromDirectory(path)); BitmapSource image = new BitmapImage(new Uri("pack://application:,,,/Resources/Img/MemoriesWhite.jpg")); Layouts.Insert(0, new BookLayout { Name = "빈 책", PreviewSource = ByteArrayToImageSourceConverter.SourceToByteArray(image) }); }
public override void OnDialogOpened(IDialogParameters parameters) { base.OnDialogOpened(parameters); string path = _folderService.GetPageTemplateFolder(parameters.GetValue <PaperSize>("PaperSize").ToString()); Layouts = new ObservableCollection <BookPageLayout>(_bookPageLayoutService.LoadPageLayoutsFromDirectory(path)); BitmapSource image = new BitmapImage(new Uri("pack://application:,,,/Resources/Img/MemoriesWhite.jpg")); Layouts.Insert(0, new BookPageLayout { Name = "빈 페이지", PreviewSource = ByteArrayToImageSourceConverter.SourceToByteArray(image) }); }
private void SelectImage(FrameworkElement element) { byte[] source; bool isImage = false; if (element is MMCenterImage image) { isImage = true; source = ByteArrayToImageSourceConverter.SourceToByteArray((BitmapSource)image.ImageSource); } else { source = Background; } _dialogService.ShowSelectImageDialog(new DialogParameters { { ParameterNames.SelectedImage, source } }, (result) => { if (result.Result != ButtonResult.OK) { return; } byte[] selectedImgae = result.Parameters.GetValue <byte[]>(ParameterNames.SelectedImage); if (isImage) { (element as MMCenterImage).ImageSource = (selectedImgae == null) ? null : (BitmapSource) new ImageSourceConverter().ConvertFrom(selectedImgae); } else { Background = selectedImgae; } }); }
public void SetSourceFromPath(string path) { Preview = path; Source = ByteArrayToImageSourceConverter.SourceToByteArray(new BitmapImage(new Uri(path, UriKind.Relative))); }
/// <summary> /// Extract source from image control /// </summary> /// <param name="image">source image</param> /// <returns></returns> private static byte[] GetSourceFromImage(BitmapSource source) { return(source == null ? null : ByteArrayToImageSourceConverter.SourceToByteArray(source)); }