|
|
@@ -100,7 +100,23 @@ public partial class DataEntryList : UserControl, ICorePanel, IDockPanel
|
|
|
|
|
|
private readonly object _viewListLock = new object();
|
|
|
|
|
|
- private List<Tuple<ImageSource, DataEntryDocument>> ViewDocuments { get; } = new();
|
|
|
+ private class ViewDocument
|
|
|
+ {
|
|
|
+ public ImageSource Image { get; set; }
|
|
|
+
|
|
|
+ public DataEntryDocument Document { get; set; }
|
|
|
+
|
|
|
+ public int PageNumber { get; set; }
|
|
|
+
|
|
|
+ public ViewDocument(ImageSource image, DataEntryDocument document, int page)
|
|
|
+ {
|
|
|
+ Image = image;
|
|
|
+ Document = document;
|
|
|
+ PageNumber = page;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ViewDocument> ViewDocuments { get; } = new();
|
|
|
public ObservableCollection<ImageSource> ViewList { get; init; } = new();
|
|
|
|
|
|
private List<DataEntryDocumentWindow> OpenWindows = new();
|
|
|
@@ -260,9 +276,11 @@ public partial class DataEntryList : UserControl, ICorePanel, IDockPanel
|
|
|
{
|
|
|
if (bitmaps.TryGetValue(scan.Document.ID, out var list))
|
|
|
{
|
|
|
+ int page = 1;
|
|
|
foreach (var bitmap in list)
|
|
|
{
|
|
|
- ViewDocuments.Add(new(bitmap, scan));
|
|
|
+ ViewDocuments.Add(new(bitmap, scan, page));
|
|
|
+ page++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -270,9 +288,9 @@ public partial class DataEntryList : UserControl, ICorePanel, IDockPanel
|
|
|
lock (_viewListLock)
|
|
|
{
|
|
|
ViewList.Clear();
|
|
|
- foreach(var (image, _) in ViewDocuments)
|
|
|
+ foreach(var doc in ViewDocuments)
|
|
|
{
|
|
|
- ViewList.Add(image);
|
|
|
+ ViewList.Add(doc.Image);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -618,14 +636,37 @@ public partial class DataEntryList : UserControl, ICorePanel, IDockPanel
|
|
|
OpenImageWindow(image);
|
|
|
}
|
|
|
|
|
|
- private void RotateDocument(Document doc)
|
|
|
+ private void RotateDocument(Document doc, int pageNumber)
|
|
|
{
|
|
|
var extension = Path.GetExtension(doc.FileName).ToLower();
|
|
|
if (extension == ".pdf")
|
|
|
{
|
|
|
var loadeddoc = new PdfLoadedDocument(doc.Data);
|
|
|
- foreach (var page in loadeddoc.GetPages())
|
|
|
+
|
|
|
+ bool allPages = loadeddoc.PageCount() > 1;
|
|
|
+ if (allPages)
|
|
|
{
|
|
|
+ allPages = MessageWindow.New()
|
|
|
+ .Message("Do you want to rotate all pages in this PDF?")
|
|
|
+ .Title("Rotate all?")
|
|
|
+ .AddYesButton("All pages")
|
|
|
+ .AddNoButton("Just this page")
|
|
|
+ .Display().Result == MessageWindowResult.Yes;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(allPages)
|
|
|
+ {
|
|
|
+ foreach (var page in loadeddoc.GetPages())
|
|
|
+ {
|
|
|
+ var rotation = (int)page.Rotation;
|
|
|
+ rotation = (rotation + 1) % 4;
|
|
|
+ page.Rotation = (PdfPageRotateAngle)rotation;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(pageNumber <= loadeddoc.PageCount())
|
|
|
+ {
|
|
|
+ var page = loadeddoc.GetPage(pageNumber - 1);
|
|
|
+
|
|
|
var rotation = (int)page.Rotation;
|
|
|
rotation = (rotation + 1) % 4;
|
|
|
page.Rotation = (PdfPageRotateAngle)rotation;
|
|
|
@@ -667,17 +708,17 @@ public partial class DataEntryList : UserControl, ICorePanel, IDockPanel
|
|
|
{
|
|
|
if (sender is not MenuItem item || item.Tag is not ImageSource image) return;
|
|
|
|
|
|
- var document = ViewDocuments.FirstOrDefault(x => x.Item1 == image)?.Item2;
|
|
|
+ var document = ViewDocuments.FirstOrDefault(x => x.Image == image);
|
|
|
if (document is null)
|
|
|
{
|
|
|
MessageWindow.ShowError("An error occurred", "Document does not exist in ViewDocuments list");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- var doc = DataEntryCache.Cache.LoadDocuments(CoreUtils.One(document.Document.ID), checkTimestamp: true).First();
|
|
|
+ var doc = DataEntryCache.Cache.LoadDocuments(CoreUtils.One(document.Document.Document.ID), checkTimestamp: true).First();
|
|
|
try
|
|
|
{
|
|
|
- RotateDocument(doc);
|
|
|
+ RotateDocument(doc, document.PageNumber);
|
|
|
}
|
|
|
catch(Exception err)
|
|
|
{
|
|
|
@@ -689,10 +730,10 @@ public partial class DataEntryList : UserControl, ICorePanel, IDockPanel
|
|
|
|
|
|
if (Path.GetExtension(doc.FileName) == ".pdf")
|
|
|
{
|
|
|
- document.Thumbnail = ImageUtils.GetPDFThumbnail(doc.Data, 256, 256);
|
|
|
+ document.Document.Thumbnail = ImageUtils.GetPDFThumbnail(doc.Data, 256, 256);
|
|
|
}
|
|
|
|
|
|
- new Client<DataEntryDocument>().Save(document, "");
|
|
|
+ new Client<DataEntryDocument>().Save(document.Document, "");
|
|
|
|
|
|
DataEntryCache.Cache.Add(new DataEntryCachedDocument(doc));
|
|
|
|