예제 #1
0
        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)
            });
        }
예제 #2
0
        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)
            });
        }
예제 #3
0
        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;
                }
            });
        }
예제 #4
0
 public void SetSourceFromPath(string path)
 {
     Preview = path;
     Source  = ByteArrayToImageSourceConverter.SourceToByteArray(new BitmapImage(new Uri(path, UriKind.Relative)));
 }
예제 #5
0
 /// <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));
 }