|
|
@@ -4,12 +4,17 @@ using System.ComponentModel;
|
|
|
using System.Linq;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
+using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using Comal.Classes;
|
|
|
using InABox.Clients;
|
|
|
using InABox.Configuration;
|
|
|
using InABox.Core;
|
|
|
+using InABox.DynamicGrid;
|
|
|
using InABox.Wpf;
|
|
|
+using InABox.WPF;
|
|
|
+using Syncfusion.Pdf.Parsing;
|
|
|
+using Syncfusion.UI.Xaml.Diagram;
|
|
|
using Syncfusion.Windows.Tools.Controls;
|
|
|
|
|
|
namespace PRSDesktop
|
|
|
@@ -100,15 +105,20 @@ namespace PRSDesktop
|
|
|
|
|
|
private BitmapImage ExtractImage(Guid id, int page)
|
|
|
{
|
|
|
- MessageBox.Show("PDF Functions broken in .NET6");
|
|
|
- // var doc = _documents.FirstOrDefault(x => x.ID.Equals(id));
|
|
|
- // if (doc != null)
|
|
|
- // {
|
|
|
- // PdfLoadedDocument pdf = new PdfLoadedDocument(doc.Data);
|
|
|
- // var dpi = VisualTreeHelper.GetDpi(this);
|
|
|
- // var bitmap = pdf.ExportAsImage(page).AsBitmapImage();
|
|
|
- // return bitmap;
|
|
|
- // }
|
|
|
+ //MessageBox.Show("PDF Functions broken in .NET6");
|
|
|
+ var doc = _documents.FirstOrDefault(x => x.ID.Equals(id));
|
|
|
+ if (doc != null)
|
|
|
+ {
|
|
|
+ var images = ImageUtils.PDFToBitmapArray(doc.Data);
|
|
|
+ return images[page].AsBitmapImage();
|
|
|
+ //var bmp = ImageUtils.PDFToBitmap(doc.Data, page);
|
|
|
+ //var img = ImageUtils.BitmapImageFromBytes(bmp);
|
|
|
+ //return img;
|
|
|
+ // PdfLoadedDocument pdf = new PdfLoadedDocument(doc.Data);
|
|
|
+ // var dpi = VisualTreeHelper.GetDpi(this);
|
|
|
+ // var bitmap = pdf.ExportAsImage(page).AsBitmapImage();
|
|
|
+ // return bitmap;
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -146,67 +156,68 @@ namespace PRSDesktop
|
|
|
|
|
|
private void TabChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
|
{
|
|
|
+ QuoteDiagramSymbolCache.Refresh();
|
|
|
}
|
|
|
|
|
|
private void AddDiagram_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- MessageBox.Show("PDF Functions broken in .NET6");
|
|
|
-
|
|
|
- // Filter<QuoteDocument> extensions = new Filter<QuoteDocument>(x => x.DocumentLink.FileName).EndsWith(".pdf").Or(x => x.DocumentLink.FileName).EndsWith(".PDF");
|
|
|
- // //.Or(x => x.DocumentLink.FileName).EndsWith(".bmp").Or(x => x.DocumentLink.FileName).EndsWith(".BMP")
|
|
|
- // //.Or(x => x.DocumentLink.FileName).EndsWith(".png").Or(x => x.DocumentLink.FileName).EndsWith(".PNG")
|
|
|
- // //.Or(x => x.DocumentLink.FileName).EndsWith(".jpg").Or(x => x.DocumentLink.FileName).EndsWith(".JPG")
|
|
|
- // //.Or(x => x.DocumentLink.FileName).EndsWith(".jpeg").Or(x => x.DocumentLink.FileName).EndsWith(".JPEG");
|
|
|
- //
|
|
|
- // MultiSelectDialog<QuoteDocument> dlg = new MultiSelectDialog<QuoteDocument>(new Filter<QuoteDocument>(x => x.EntityLink.ID).IsEqualTo(QuoteID) /*.And(extensions) */, null, false);
|
|
|
- // if (dlg.ShowDialog() == true)
|
|
|
- // {
|
|
|
- // QuoteDocument qdoc = dlg.Items().FirstOrDefault();
|
|
|
- // var doc = _documents.FirstOrDefault(x => x.ID.Equals(qdoc.DocumentLink.ID));
|
|
|
- // if (doc == null)
|
|
|
- // {
|
|
|
- // doc = new Client<Document>().Load(new Filter<Document>(x => x.ID).IsEqualTo(qdoc.DocumentLink.ID)).FirstOrDefault();
|
|
|
- // _documents.Add(doc);
|
|
|
- // }
|
|
|
- //
|
|
|
- // PdfLoadedDocument pdf = new PdfLoadedDocument(doc.Data);
|
|
|
- // int firstpage = 1;
|
|
|
- // int lastpage = pdf.Pages.Count;
|
|
|
- // if (pdf.Pages.Count > 1)
|
|
|
- // {
|
|
|
- // MessageBoxResult mr = MessageBox.Show("This PDF contains multiple pages. Do you want to import all pages?", "Multi-Page PDF Found", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
|
|
|
- // if (mr == MessageBoxResult.Cancel)
|
|
|
- // return;
|
|
|
- // if (mr == MessageBoxResult.No)
|
|
|
- // {
|
|
|
- // if (NumberEdit.Execute("Select PDF Page", firstpage, lastpage, ref firstpage))
|
|
|
- // lastpage = firstpage;
|
|
|
- // else
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // for (int iPage = firstpage; iPage <= lastpage; iPage++)
|
|
|
- // {
|
|
|
- // QuoteDiagram diagram = new QuoteDiagram();
|
|
|
- // if ((firstpage == lastpage) && (firstpage == 1))
|
|
|
- // diagram.Description = System.IO.Path.GetFileNameWithoutExtension(doc.FileName);
|
|
|
- // else
|
|
|
- // diagram.Description = String.Format("{0} {1}", System.IO.Path.GetFileNameWithoutExtension(doc.FileName), iPage);
|
|
|
- // diagram.Document.ID = qdoc.ID;
|
|
|
- // diagram.Document.Synchronise(qdoc);
|
|
|
- // diagram.Document.DocumentLink.ID = qdoc.DocumentLink.ID;
|
|
|
- // diagram.Document.DocumentLink.Synchronise(qdoc.DocumentLink);
|
|
|
- // diagram.DocumentPage = iPage - 1;
|
|
|
- // diagram.Quote.ID = QuoteID;
|
|
|
- // new Client<QuoteDiagram>().Save(diagram, "");
|
|
|
- // _diagrams.Add(diagram);
|
|
|
- // var bmp = ExtractImage(diagram.Document.DocumentLink.ID, iPage-1);
|
|
|
- // CreateDrawing(diagram, bmp);
|
|
|
- //
|
|
|
- //
|
|
|
- // }
|
|
|
- // }
|
|
|
+ //MessageBox.Show("PDF Functions broken in .NET6");
|
|
|
+
|
|
|
+ Filter<QuoteDocument> extensions = new Filter<QuoteDocument>(x => x.DocumentLink.FileName).EndsWith(".pdf").Or(x => x.DocumentLink.FileName).EndsWith(".PDF");
|
|
|
+ //.Or(x => x.DocumentLink.FileName).EndsWith(".bmp").Or(x => x.DocumentLink.FileName).EndsWith(".BMP")
|
|
|
+ //.Or(x => x.DocumentLink.FileName).EndsWith(".png").Or(x => x.DocumentLink.FileName).EndsWith(".PNG")
|
|
|
+ //.Or(x => x.DocumentLink.FileName).EndsWith(".jpg").Or(x => x.DocumentLink.FileName).EndsWith(".JPG")
|
|
|
+ //.Or(x => x.DocumentLink.FileName).EndsWith(".jpeg").Or(x => x.DocumentLink.FileName).EndsWith(".JPEG");
|
|
|
+
|
|
|
+ MultiSelectDialog<QuoteDocument> dlg = new MultiSelectDialog<QuoteDocument>(new Filter<QuoteDocument>(x => x.EntityLink.ID).IsEqualTo(Master.ID) /*.And(extensions) */, null, false);
|
|
|
+ if (dlg.ShowDialog() == true)
|
|
|
+ {
|
|
|
+ QuoteDocument qdoc = dlg.Items().FirstOrDefault();
|
|
|
+ var doc = _documents.FirstOrDefault(x => x.ID.Equals(qdoc.DocumentLink.ID));
|
|
|
+ if (doc == null)
|
|
|
+ {
|
|
|
+ doc = new Client<Document>().Load(new Filter<Document>(x => x.ID).IsEqualTo(qdoc.DocumentLink.ID)).FirstOrDefault();
|
|
|
+ _documents.Add(doc);
|
|
|
+ }
|
|
|
+
|
|
|
+ var array = ImageUtils.PDFToBitmapArray(doc.Data);
|
|
|
+
|
|
|
+ int firstpage = 1;
|
|
|
+ int lastpage = array.Length;
|
|
|
+ if (array.Length > 1)
|
|
|
+ {
|
|
|
+ MessageBoxResult mr = MessageBox.Show("This PDF contains multiple pages. Do you want to import all pages?", "Multi-Page PDF Found", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
|
|
|
+ if (mr == MessageBoxResult.Cancel)
|
|
|
+ return;
|
|
|
+ if (mr == MessageBoxResult.No)
|
|
|
+ {
|
|
|
+ if (NumberEdit.Execute("Select PDF Page", firstpage, lastpage, ref firstpage))
|
|
|
+ lastpage = firstpage;
|
|
|
+ else
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int iPage = firstpage; iPage <= lastpage; iPage++)
|
|
|
+ {
|
|
|
+ QuoteDiagram diagram = new QuoteDiagram();
|
|
|
+ if ((firstpage == lastpage) && (firstpage == 1))
|
|
|
+ diagram.Description = System.IO.Path.GetFileNameWithoutExtension(doc.FileName);
|
|
|
+ else
|
|
|
+ diagram.Description = String.Format("{0} {1}", System.IO.Path.GetFileNameWithoutExtension(doc.FileName), iPage);
|
|
|
+ diagram.Document.ID = qdoc.ID;
|
|
|
+ diagram.Document.Synchronise(qdoc);
|
|
|
+ diagram.Document.DocumentLink.ID = qdoc.DocumentLink.ID;
|
|
|
+ diagram.Document.DocumentLink.Synchronise(qdoc.DocumentLink);
|
|
|
+ diagram.DocumentPage = iPage - 1;
|
|
|
+ diagram.Quote.ID = Master.ID;
|
|
|
+ new Client<QuoteDiagram>().Save(diagram, "");
|
|
|
+ _diagrams.Add(diagram);
|
|
|
+ CreateDrawing(diagram, array[iPage-1].AsBitmapImage());
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void DeleteDiagram_Click(object sender, RoutedEventArgs e)
|