// 物件PDF編集メソッド(Listview内外のコマンドから呼ばれる) private void PdfEdit(RentLivingPdf rlpdf) { // PDF編集Windowへ渡す為のArgをセット OpenRentLivingPdfWindowEventArgs ag = new OpenRentLivingPdfWindowEventArgs(); ag.Id = rlpdf.RentPdfId; ag.RentLivingPdfObject = rlpdf; ag.RentLivingPdfs = RentLivingEdit.RentLivingPdfs; ag.IsEdit = true; // PDF編集Windowを開く OpenRentLivingPdfWindow?.Invoke(this, ag); }
public async void PdfAddCommand_Execute() { if (RentLivingEdit == null) { return; } var files = _openDialogService.GetOpenZumenPdfFileDialog("図面の追加"); if (files != null) { foreach (String filePath in files) { string fileName = filePath.Trim(); if (!string.IsNullOrEmpty(fileName)) { FileInfo fi = new FileInfo(fileName); if (fi.Exists) { // 図面ファイルのPDFデータの読み込み byte[] PdfData; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); long len = fs.Length; // ByteArrayに変換 BinaryReader br = new BinaryReader(fs); PdfData = br.ReadBytes((int)fs.Length); br.Close(); // RentLivingPdfオブジェクトの作成 RentLivingPdf rlZumen = new RentLivingPdf(RentLivingEdit.RentId, RentLivingEdit.RentLivingId, Guid.NewGuid().ToString()); rlZumen.PdfData = PdfData; rlZumen.FileSize = len; // 画像を作成。 BitmapImage bitimg = await Methods.BitmapImageFromPdf(PdfData); rlZumen.Picture = bitimg; // ByteArrayに変換 byte[] ImageData = Methods.BitmapImageToByteArray(bitimg); rlZumen.PictureData = ImageData; // TODO: //rlZumen.DateTimeAdded = DateTime.Now; rlZumen.DateTimePublished = DateTime.Now; rlZumen.DateTimeVerified = DateTime.Now; // 画面閉じる際の確認用のフラグ。 rlZumen.IsNew = true; // DBに保存する為のフラグ。 rlZumen.IsModified = true; // 物件のPDFリストに追加。 //RentLivingEdit.RentLivingPdfs.Add(rlZumen); fs.Close(); // PDF編集Windowへ渡す為のArgをセット OpenRentLivingPdfWindowEventArgs ag = new OpenRentLivingPdfWindowEventArgs(); ag.Id = rlZumen.RentPdfId; ag.RentLivingPdfObject = rlZumen; ag.RentLivingPdfs = RentLivingEdit.RentLivingPdfs; ag.IsEdit = false; // PDF編集Windowを開く OpenRentLivingPdfWindow?.Invoke(this, ag); } } } } }