public MainWindow(string pdf, int index) : this() { this.pdf = pdf; pageIndex.Minimum = 0; pageIndex.Maximum = PDFUtility.GetImages(pdf).Count() - 1; pageIndex.Value = index; }
async Task <Bitmap> GetBitmap() { while (string.IsNullOrEmpty(pdf)) { var dialog = new CommonOpenFileDialog(); var filter = new CommonFileDialogFilter("PDF", "pdf"); dialog.Filters.Add(filter); if (dialog.ShowDialog() != CommonFileDialogResult.Ok) { Application.Current.Shutdown(); return(null); } pdf = dialog.FileName; } var image = await Task.Run(() => PDFUtility.GetImages(pdf)); pageIndex.Maximum = image.Count() - 1; var index = (int)pageIndex.Value; var bitmap = await Task.Run(() => new Bitmap(image.ToArray()[index].image)); return(bitmap); }