|
@@ -2,14 +2,19 @@
|
|
|
using ComPDFKit.PDFAnnotation.Form;
|
|
|
using ComPDFKit.PDFDocument.Action;
|
|
|
using compdfkit_tools.Data;
|
|
|
+using compdfkit_tools.PDFControl;
|
|
|
using ComPDFKitViewer.AnnotEvent;
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Collections.ObjectModel;
|
|
|
+using System.ComponentModel;
|
|
|
using System.Net.NetworkInformation;
|
|
|
+using System.Runtime.CompilerServices;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Controls.Primitives;
|
|
|
+using System.Windows.Data;
|
|
|
using System.Windows.Documents.DocumentStructures;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Shapes;
|
|
@@ -20,7 +25,7 @@ namespace compdfkit_tools.Form
|
|
|
/// <summary>
|
|
|
/// FormBarControl.xaml 的交互逻辑
|
|
|
/// </summary>
|
|
|
- public partial class FormBarControl : UserControl
|
|
|
+ public partial class FormBarControl : UserControl, INotifyPropertyChanged
|
|
|
{
|
|
|
enum FromType
|
|
|
{
|
|
@@ -51,6 +56,37 @@ namespace compdfkit_tools.Form
|
|
|
{"Redo", "M16.7802 7.62131L17.3105 8.15164L16.7802 8.68197L13.1589 12.3033L12.0982 11.2426L14.4392 8.90164H7.74989C6.2311 8.90164 4.99989 10.1329 4.99989 11.6516C4.99989 13.1704 6.2311 14.4016 7.74989 14.4016H15.2499V15.9016H7.74989C5.40268 15.9016 3.49989 13.9988 3.49989 11.6516C3.49989 9.30443 5.40268 7.40164 7.74989 7.40164H14.4392L12.0982 5.06066L13.1589 4L16.7802 7.62131Z"},
|
|
|
};
|
|
|
|
|
|
+ public event PropertyChangedEventHandler PropertyChanged;
|
|
|
+ protected void OnPropertyChanged([CallerMemberName] string name = null)
|
|
|
+ {
|
|
|
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public bool CanUndo
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (pdfViewer != null)
|
|
|
+ {
|
|
|
+ return pdfViewer.UndoManager.CanUndo;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool CanRedo
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (pdfViewer != null)
|
|
|
+ {
|
|
|
+ return pdfViewer.UndoManager.CanRedo;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private CPDFViewer pdfViewer;
|
|
|
|
|
|
private FromPropertyControl fromPropertyControl = null;
|
|
@@ -149,9 +185,26 @@ namespace compdfkit_tools.Form
|
|
|
button.Tag = Tag;
|
|
|
button.Content = stackPanel;
|
|
|
button.Click += UndoRedo_Click;
|
|
|
+ BingUndoRedoTag(button, Tag);
|
|
|
FormGrid.Children.Add(button);
|
|
|
}
|
|
|
|
|
|
+ private void BingUndoRedoTag(UIElement sender, string Tag)
|
|
|
+ {
|
|
|
+ Binding binding = new Binding();
|
|
|
+ binding.Source = this;
|
|
|
+ if (Tag == "Undo")
|
|
|
+ {
|
|
|
+ binding.Path = new System.Windows.PropertyPath("CanUndo");
|
|
|
+ }
|
|
|
+ else if (Tag == "Redo")
|
|
|
+ {
|
|
|
+ binding.Path = new System.Windows.PropertyPath("CanRedo");
|
|
|
+ }
|
|
|
+ binding.Mode = BindingMode.OneWay;
|
|
|
+ (sender as Button).SetBinding(Button.IsEnabledProperty, binding);
|
|
|
+ }
|
|
|
+
|
|
|
private void CreateSeparator(double rotate)
|
|
|
{
|
|
|
RotateTransform rotateTransform = new RotateTransform();
|
|
@@ -173,9 +226,16 @@ namespace compdfkit_tools.Form
|
|
|
public void SetPDFViewer(CPDFViewer pdfViewer, FromPropertyControl FromProperty)
|
|
|
{
|
|
|
this.pdfViewer = pdfViewer;
|
|
|
+ this.pdfViewer.UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
|
|
|
+ this.pdfViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
|
|
|
fromPropertyControl = FromProperty;
|
|
|
}
|
|
|
|
|
|
+ private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
+ {
|
|
|
+ OnPropertyChanged(e.PropertyName);
|
|
|
+ }
|
|
|
+
|
|
|
public void CheckedButtonForName(string name)
|
|
|
{
|
|
|
foreach (UIElement child in FormGrid.Children)
|
|
@@ -296,7 +356,7 @@ namespace compdfkit_tools.Form
|
|
|
fromPropertyControl.SetPropertyForType(null, null);
|
|
|
pdfViewer.UndoManager.Redo();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
#endregion
|