12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using Prism.Commands;
- using Prism.Mvvm;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Media;
- using System.Windows;
- using PDF_Office.Model.PropertyPanel.AnnotPanel;
- using System.Windows.Controls;
- using Prism.Regions;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Office.Model;
- using Microsoft.Win32;
- using PDF_Office.CustomControl;
- namespace PDF_Office.ViewModels.Tools
- {
- public class TextEditToolContentViewModel: BindableBase, INavigationAware
- {
- #region Command
- public DelegateCommand<object> AddContentCommand { get; set; }
- #endregion
- public TextEditToolContentViewModel()
- {
- InitCommand();
- }
- private void InitCommand()
- {
- AddContentCommand = new DelegateCommand<object>(AddContent);
- }
- public void AddContent(object obj)
- {
- if (PDFViewer == null || obj == null || obj as CustomIconToggleBtn == null) return;
- var btn = obj as CustomIconToggleBtn;
- if(btn.IsChecked == true)
- {
- if (btn.Tag.ToString() == "Text")
- {
- PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
- }
- else
- {
- OpenFileDialog openFileDialog = new OpenFileDialog();
- openFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
- openFileDialog.Multiselect = true;
- if ((bool)openFileDialog.ShowDialog())
- {
- if (string.IsNullOrEmpty(openFileDialog.FileName) == false)
- {
- PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
- PDFViewer.AddPDFEditImage(openFileDialog.FileName);
- }
- }
- btn.IsChecked = false;
- }
- }
- else
- {
- PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.None);
- PDFViewer.SetMouseMode(MouseModes.PDFEdit);
- }
- }
- private CPDFViewer PDFViewer;
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
- if (PDFViewer != null)
- {
- }
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
-
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
-
- }
- }
- }
|