Пример #1
0
 private void AddDataPieces(string path)
 {
     DataPieces.Add(new DataPiece
     {
         image = Create(path),
         name  = Path.GetFileName(path),
         fork  = DataPiece.Fork.Bitmap,
         path  = path,
         page  = new ReactiveProperty <string>((DataPieces.Count() + 1).ToString()
                                               .PadLeft(DataPieces.Count().ToString().Length, '0'))
     });
 }
Пример #2
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();
            });
        }
Пример #3
0
 private void AddDataPieces(Dictionary <string, byte[]> dic)
 {
     foreach (var key in dic.Keys)
     {
         DataPieces.Add(new DataPiece
         {
             image    = Create(dic[key]),
             name     = Path.GetFileName(key),
             fork     = DataPiece.Fork.Zip,
             byteData = dic[key],
             page     = new ReactiveProperty <string>((DataPieces.Count() + 1).ToString()
                                                      .PadLeft(DataPieces.Count().ToString().Length, '0'))
         });
     }
 }