|
@@ -23,152 +23,152 @@ using System.Windows.Markup;
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
namespace PDF_Master.ViewModels.Dialog.BOTA
|
|
|
-{
|
|
|
-public class AddAnnotationDialogViewModel : BindableBase, IDialogAware
|
|
|
-{
|
|
|
-private string title = "";
|
|
|
-
|
|
|
-public string Title
|
|
|
-{
|
|
|
-get { return title; }
|
|
|
-set { SetProperty(ref title, value); }
|
|
|
-}
|
|
|
-
|
|
|
-public event Action<IDialogResult> RequestClose;
|
|
|
-
|
|
|
- //private string markupContent;
|
|
|
-
|
|
|
- //public string MarkupContent
|
|
|
- //{
|
|
|
- // get { return markupContent; }
|
|
|
- // set
|
|
|
- // {
|
|
|
- // SetProperty(ref markupContent, value);
|
|
|
- // }
|
|
|
- //}
|
|
|
- private string contentText;
|
|
|
-
|
|
|
- public string ContentText
|
|
|
- {
|
|
|
- get { return contentText; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref contentText, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private string annotationName;
|
|
|
-
|
|
|
- public string AnnotationName
|
|
|
- {
|
|
|
- get { return annotationName; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref annotationName, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private Visibility tipVisibility = Visibility.Collapsed;
|
|
|
-
|
|
|
- public Visibility TipVisibility
|
|
|
- {
|
|
|
- get { return tipVisibility; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref tipVisibility, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public AnnotationHandlerEventArgs Annotation { get; set; }
|
|
|
- public AnnotAttribEvent AnnotEvent { get; set; }
|
|
|
-
|
|
|
- public DelegateCommand CreateCommnad { get; set; }
|
|
|
- public DelegateCommand CancelCommand { get; set; }
|
|
|
-
|
|
|
- public DelegateCommand<object> LostFocusCommand { get; set; }
|
|
|
-
|
|
|
- public DelegateCommand<object> KeyDownCommand { get; set; }
|
|
|
-
|
|
|
- public AddAnnotationDialogViewModel()
|
|
|
- {
|
|
|
+{
|
|
|
+ public class AddAnnotationDialogViewModel : BindableBase, IDialogAware
|
|
|
+ {
|
|
|
+ private string title = "";
|
|
|
+
|
|
|
+ public string Title
|
|
|
+ {
|
|
|
+ get { return title; }
|
|
|
+ set { SetProperty(ref title, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ public event Action<IDialogResult> RequestClose;
|
|
|
+
|
|
|
+ //private string markupContent;
|
|
|
+
|
|
|
+ //public string MarkupContent
|
|
|
+ //{
|
|
|
+ // get { return markupContent; }
|
|
|
+ // set
|
|
|
+ // {
|
|
|
+ // SetProperty(ref markupContent, value);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ private string contentText;
|
|
|
+
|
|
|
+ public string ContentText
|
|
|
+ {
|
|
|
+ get { return contentText; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref contentText, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private string annotationName;
|
|
|
+
|
|
|
+ public string AnnotationName
|
|
|
+ {
|
|
|
+ get { return annotationName; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref annotationName, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Visibility tipVisibility = Visibility.Collapsed;
|
|
|
+
|
|
|
+ public Visibility TipVisibility
|
|
|
+ {
|
|
|
+ get { return tipVisibility; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref tipVisibility, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public AnnotationHandlerEventArgs Annotation { get; set; }
|
|
|
+ public AnnotAttribEvent AnnotEvent { get; set; }
|
|
|
+
|
|
|
+ public DelegateCommand CreateCommnad { get; set; }
|
|
|
+ public DelegateCommand CancelCommand { get; set; }
|
|
|
+
|
|
|
+ public DelegateCommand<object> LostFocusCommand { get; set; }
|
|
|
+
|
|
|
+ public DelegateCommand<object> KeyDownCommand { get; set; }
|
|
|
+
|
|
|
+ public AddAnnotationDialogViewModel()
|
|
|
+ {
|
|
|
CancelCommand = new DelegateCommand(CancelEvent);
|
|
|
CreateCommnad = new DelegateCommand(CreateEvent);
|
|
|
- LostFocusCommand = new DelegateCommand<object>(LostFocusEvent);
|
|
|
- KeyDownCommand = new DelegateCommand<object>(KeyDown);
|
|
|
- }
|
|
|
-
|
|
|
- private void KeyDown(object obj)
|
|
|
- {
|
|
|
- if (obj is CompositeCommandParameter composite)
|
|
|
- {
|
|
|
- if (composite.EventArgs is System.Windows.Input.KeyEventArgs eventArgs)
|
|
|
- {
|
|
|
+ LostFocusCommand = new DelegateCommand<object>(LostFocusEvent);
|
|
|
+ KeyDownCommand = new DelegateCommand<object>(KeyDown);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void KeyDown(object obj)
|
|
|
+ {
|
|
|
+ if (obj is CompositeCommandParameter composite)
|
|
|
+ {
|
|
|
+ if (composite.EventArgs is System.Windows.Input.KeyEventArgs eventArgs)
|
|
|
+ {
|
|
|
if (eventArgs.Key == Key.Enter)
|
|
|
- {
|
|
|
- LostFocusEvent(obj);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void LostFocusEvent(object obj)
|
|
|
- {
|
|
|
- if (obj is CompositeCommandParameter composite)
|
|
|
- {
|
|
|
- if (composite.Parameter is TextBox textBox)
|
|
|
- {
|
|
|
+ {
|
|
|
+ LostFocusEvent(obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void LostFocusEvent(object obj)
|
|
|
+ {
|
|
|
+ if (obj is CompositeCommandParameter composite)
|
|
|
+ {
|
|
|
+ if (composite.Parameter is TextBox textBox)
|
|
|
+ {
|
|
|
Annotation.Content = textBox.Text;
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.NoteText, textBox.Text);
|
|
|
- AnnotEvent?.UpdateAnnot();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void CreateEvent()
|
|
|
- {
|
|
|
- DialogParameters valuePairs = new DialogParameters();
|
|
|
- valuePairs.Add(ParameterNames.Annotation, Annotation);
|
|
|
- valuePairs.Add(ParameterNames.AnnotEvent, AnnotEvent);
|
|
|
- RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
|
|
|
- }
|
|
|
-
|
|
|
- private void CancelEvent()
|
|
|
- {
|
|
|
- RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
|
|
|
- }
|
|
|
-
|
|
|
- public bool CanCloseDialog()
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- public void OnDialogClosed()
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
- public void OnDialogOpened(IDialogParameters parameters)
|
|
|
- {
|
|
|
- AnnotationHandlerEventArgs annotation;
|
|
|
- parameters.TryGetValue<AnnotationHandlerEventArgs>(ParameterNames.Annotation, out annotation);
|
|
|
-
|
|
|
- if (annotation != null)
|
|
|
- {
|
|
|
- Annotation = annotation;
|
|
|
- Dictionary<AnnotAttrib, object> annotAttribsList = annotation.AnnotHandlerEventArgs.GetAnnotAttrib();
|
|
|
- AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotation.AnnotHandlerEventArgs, annotAttribsList);
|
|
|
-
|
|
|
- ContentText = annotation.Content;
|
|
|
- AnnotationName = "页面" + (annotation.PageIndex + 1).ToString();
|
|
|
- if (string.IsNullOrEmpty(ContentText))
|
|
|
- {
|
|
|
- TipVisibility = Visibility.Visible;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- TipVisibility = Visibility.Collapsed;
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CreateEvent()
|
|
|
+ {
|
|
|
+ DialogParameters valuePairs = new DialogParameters();
|
|
|
+ valuePairs.Add(ParameterNames.Annotation, Annotation);
|
|
|
+ valuePairs.Add(ParameterNames.AnnotEvent, AnnotEvent);
|
|
|
+ RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CancelEvent()
|
|
|
+ {
|
|
|
+ RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool CanCloseDialog()
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void OnDialogClosed()
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void OnDialogOpened(IDialogParameters parameters)
|
|
|
+ {
|
|
|
+ AnnotationHandlerEventArgs annotation;
|
|
|
+ parameters.TryGetValue<AnnotationHandlerEventArgs>(ParameterNames.Annotation, out annotation);
|
|
|
+
|
|
|
+ if (annotation != null)
|
|
|
+ {
|
|
|
+ Annotation = annotation;
|
|
|
+ Dictionary<AnnotAttrib, object> annotAttribsList = annotation.AnnotHandlerEventArgs.GetAnnotAttrib();
|
|
|
+ AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotation.AnnotHandlerEventArgs, annotAttribsList);
|
|
|
+
|
|
|
+ ContentText = annotation.Content;
|
|
|
+ AnnotationName = "页面" + (annotation.PageIndex + 1).ToString();
|
|
|
+ if (string.IsNullOrEmpty(ContentText))
|
|
|
+ {
|
|
|
+ TipVisibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TipVisibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|