Browse Source

Added ButtonsVisible (default true) to enable provision of a PDFViewer without editing functions

Frank van den Bos 2 years ago
parent
commit
df1cbf5f8d

+ 6 - 1
InABox.DynamicGrid/PDF/DocumentEditor.xaml.cs

@@ -36,11 +36,14 @@ namespace InABox.DynamicGrid
 
         //public bool PrintAllowed { get; set; }
         public bool SaveAllowed { get; set; }
+        public bool ButtonsVisible { get; set; }
         public string Watermark { get; set; }
 
+        private bool bClosing = false;
+        
         private void Documents_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            if (!bReady)
+            if (!bReady || (!ButtonsVisible && bClosing))
                 return;
 
             for (var i = 0; i < e.RemovedItems.Count; i++)
@@ -72,6 +75,7 @@ namespace InABox.DynamicGrid
                             var pdf = new PDFEditorControl();
                             //pdf.PrintAllowed = PrintAllowed;
                             pdf.SaveAllowed = SaveAllowed;
+                            pdf.ButtonsVisible = ButtonsVisible;
                             pdf.Watermark = Watermark;
                             editor = pdf;
                         }
@@ -94,6 +98,7 @@ namespace InABox.DynamicGrid
 
         protected override void OnClosing(CancelEventArgs e)
         {
+            bClosing = true;
             base.OnClosing(e);
             Documents.SelectedIndex = -1;
         }

+ 5 - 1
InABox.DynamicGrid/PDF/PDFEditorControl.xaml.cs

@@ -43,6 +43,8 @@ namespace InABox.DynamicGrid
         public PDFEditorControl()
         {
             InitializeComponent();
+            SaveAllowed = false;
+            ButtonsVisible = true;
 
             PdfViewer.ReferencePath =
                 AppDomain.CurrentDomain.BaseDirectory; // System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "pdfium");
@@ -55,6 +57,8 @@ namespace InABox.DynamicGrid
         //public bool PrintAllowed { get; set; }
 
         public bool SaveAllowed { get; set; }
+        
+        public bool ButtonsVisible { get; set; }
 
         public string Watermark { get; set; }
 
@@ -584,7 +588,7 @@ namespace InABox.DynamicGrid
 
         private void UpdateButtons(Image selected)
         {
-            PDFButtonStack.Width = Document != null && Document.Superceded.IsEmpty()
+            PDFButtonStack.Width = Document != null && Document.Superceded.IsEmpty() && ButtonsVisible
                 ? new GridLength(44, GridUnitType.Pixel)
                 : new GridLength(0, GridUnitType.Pixel);