public async Task ExecuteAsync() { if (this.ToAddressList.Count(x => x.IsSelected) <= 0) { this.Status = "宛て先を選択してください"; return; } if (this.FromAddressList.Count(x => x.IsSelected) <= 0) { this.Status = "差出人を選択してください"; return; } this.Status = "PDF 作成中..."; try { await Task.Run(() => { this._pdfContext.OutputPath = this.OutputPath; this._pdfContext.FileName = this.FileName; this._pdfContext.PdfSizeSet = this.PdfSize; this._pdfContext.Dpi = this.Dpi; this._pdfContext.IsVisibleSeparateLine = this.IsVisibleLine; this._labelContext.OutlineWidth = this.LineWidth; this._labelContext.MarginRatio = this.MarginRatio; this._labelContext.ParPage = this.ParPage; var context = new PdfBuildingContext { PdfContext = this._pdfContext, LabelContext = this._labelContext, ToAddressList = this.ToAddressList.Where(x => x.IsSelected), FromAddress = this.FromAddressList.FirstOrDefault(x => x.IsSelected) }; var builder = new PdfBuilder(context); builder.Build(); }); } catch (Exception ex) when(ex is LayoutException || ex is LabelException || ex is PdfException) { this.Status = ex.Message; return; } catch { this.Status = "不明なエラー"; return; } this.Status = "出力終了"; }
protected override void Initialize(PdfBuilder builder) { builder.Build("Test.Example.xaml", Assembly.GetExecutingAssembly()); }