|
@@ -1,155 +0,0 @@
|
|
|
-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,
|
|
|
- Locked
|
|
|
- }
|
|
|
-
|
|
|
- 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";
|
|
|
- markUpButton.IsEnabled = Document != null;
|
|
|
- approveButton.IsEnabled = false;
|
|
|
- rejectButton.IsEnabled = false;
|
|
|
- }
|
|
|
- else if (_mode == ControlMode.Locked)
|
|
|
- {
|
|
|
- markUpButton.Content = "Locked";
|
|
|
- markUpButton.IsEnabled = false;
|
|
|
- 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;
|
|
|
- Render();
|
|
|
- }
|
|
|
- }
|
|
|
- public DocumentApprovalControl()
|
|
|
- {
|
|
|
- InitializeComponent();
|
|
|
- Mode = ControlMode.Markup;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// This currently only caters to PDFs - add to this if needed to account for other document types
|
|
|
- /// </summary>
|
|
|
- private void Render()
|
|
|
- {
|
|
|
- viewer.Children.Clear();
|
|
|
- if(Document is null)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- var table = new Client<Document>().Query(
|
|
|
- new Filter<Document>(x => x.ID).IsEqualTo(Document.DocumentLink.ID),
|
|
|
- new Columns<Document>(x => x.Data));
|
|
|
- var first = table.Rows.FirstOrDefault();
|
|
|
- if (first is null)
|
|
|
- return;
|
|
|
- var data = first.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 - press save in your document editor, then press the Complete Button in PRS");
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|