|
@@ -0,0 +1,135 @@
|
|
|
+using InABox.Clients;
|
|
|
+using InABox.Core;
|
|
|
+using InABox.DynamicGrid;
|
|
|
+using InABox.WPF;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Data;
|
|
|
+using System.Windows.Documents;
|
|
|
+using System.Windows.Input;
|
|
|
+using System.Windows.Media;
|
|
|
+using System.Windows.Media.Imaging;
|
|
|
+using System.Windows.Navigation;
|
|
|
+using System.Windows.Shapes;
|
|
|
+
|
|
|
+namespace InABox.Wpf
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// Interaction logic for DocumentApprovalControl.xaml
|
|
|
+ /// </summary>
|
|
|
+ public partial class DocumentApprovalControl : UserControl, IDocumentEditor
|
|
|
+ {
|
|
|
+ public delegate void MarkupSelected(IEntityDocument document);
|
|
|
+ public event MarkupSelected OnMarkupSelected;
|
|
|
+
|
|
|
+ public delegate void MarkupComplete(IEntityDocument document);
|
|
|
+ public event MarkupComplete OnMarkupComplete;
|
|
|
+
|
|
|
+ public delegate void Approved(IEntityDocument document);
|
|
|
+ public event Approved OnApproved;
|
|
|
+
|
|
|
+ public delegate void Rejected(IEntityDocument document);
|
|
|
+ public event Rejected OnRejected;
|
|
|
+ public enum ControlMode
|
|
|
+ {
|
|
|
+ Markup,
|
|
|
+ Complete
|
|
|
+ }
|
|
|
+
|
|
|
+ ControlMode _mode;
|
|
|
+
|
|
|
+ public ControlMode Mode
|
|
|
+ {
|
|
|
+ get => _mode;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _mode = value;
|
|
|
+ if (_mode == ControlMode.Markup)
|
|
|
+ {
|
|
|
+ markUpButton.Content = "Mark Up";
|
|
|
+ markUpButton.IsEnabled = Document != null;
|
|
|
+ approveButton.IsEnabled = Document != null;
|
|
|
+ rejectButton.IsEnabled = Document != null;
|
|
|
+ }
|
|
|
+ else if (_mode == ControlMode.Complete)
|
|
|
+ {
|
|
|
+ markUpButton.Content = "Complete";
|
|
|
+ approveButton.IsEnabled = false;
|
|
|
+ rejectButton.IsEnabled = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetupButtons(bool markupVisible = true, bool approveVisible = true, bool rejectVisible = true)
|
|
|
+ {
|
|
|
+ markUpButton.Visibility = markupVisible? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ approveButton.Visibility = approveVisible? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ rejectButton.Visibility = rejectVisible? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ }
|
|
|
+
|
|
|
+ private IEntityDocument _document;
|
|
|
+ public IEntityDocument Document
|
|
|
+ {
|
|
|
+ get => _document;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _document = value;
|
|
|
+ Mode = ControlMode.Markup;
|
|
|
+ Render();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public DocumentApprovalControl()
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ Mode = ControlMode.Markup;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Render()
|
|
|
+ {
|
|
|
+ viewer.Children.Clear();
|
|
|
+ var table = new Client<Document>().Query(new Filter<Document>(x => x.ID).IsEqualTo(_document.DocumentLink.ID));
|
|
|
+ if (!table.Rows.Any())
|
|
|
+ return;
|
|
|
+ var data = table.Rows.FirstOrDefault().Get<Document, byte[]>(x => x.Data);
|
|
|
+ var images = ImageUtils.RenderPDFToImages(data);
|
|
|
+ foreach (var image in images)
|
|
|
+ {
|
|
|
+ viewer.Children.Add(new Image
|
|
|
+ {
|
|
|
+ Source = ImageUtils.LoadImage(image),
|
|
|
+ Margin = new Thickness(0, 0, 0, 20)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void MarkUpButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (Mode == ControlMode.Markup)
|
|
|
+ {
|
|
|
+ Mode = ControlMode.Complete;
|
|
|
+ MessageBox.Show("IMPORTANT - please save and overwrite the original file in the setouts folder when done, and press complete to refresh");
|
|
|
+ OnMarkupSelected?.Invoke(_document);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OnMarkupComplete?.Invoke(_document);
|
|
|
+ Mode = ControlMode.Markup;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ApproveButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ OnApproved?.Invoke(_document);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void RejectButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ OnRejected?.Invoke(_document);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|