Example #1
0
        public Conv()
        {
            IsDrag = new ReactiveProperty <bool>(true).AddTo(Disposable);

            IsConvertingShare = new ReactiveProperty <bool>(true).AddTo(Disposable);

            ButtonStart = new AsyncReactiveCommand().AddTo(Disposable);
            ButtonStart = IsConvertingShare.ToAsyncReactiveCommand();
            ButtonStart.Subscribe(async _ =>
            {
                await Task.Run(() =>
                {
                    using (var Pdf = new iTextSharp())
                    {
                        Pdf.Output = SaveFile(Path.GetFileName(LastInput), Path.GetDirectoryName(LastInput));

                        if (Pdf.Output == string.Empty)
                        {
                            return;
                        }

                        Pdf.Open();

                        foreach (var dp in DataPieces.OrderBy(x => x.page.Value))
                        {
                            switch (dp.fork)
                            {
                            case DataPiece.Fork.Bitmap:
                                Pdf.AddToPdf(dp.path);
                                break;

                            case DataPiece.Fork.Zip:
                                Pdf.AddToPdf(dp.byteData);
                                break;
                            }
                        }
                    }
                });

                MessageBox.Show("完了");
            });

            ButtonRemoveAll = new AsyncReactiveCommand().AddTo(Disposable);
            ButtonRemoveAll = IsConvertingShare.ToAsyncReactiveCommand();
            ButtonRemoveAll.Subscribe(async _ =>
            {
                DataPieces.Clear();
            });
        }