|
@@ -1,24 +1,31 @@
|
|
using ComPDFKit.PDFWatermark;
|
|
using ComPDFKit.PDFWatermark;
|
|
using ComPDFKitViewer.PdfViewer;
|
|
using ComPDFKitViewer.PdfViewer;
|
|
using PDF_Office.CustomControl;
|
|
using PDF_Office.CustomControl;
|
|
|
|
+using PDF_Office.EventAggregators;
|
|
using PDF_Office.Helper;
|
|
using PDF_Office.Helper;
|
|
|
|
+using PDF_Office.Model;
|
|
using PDF_Office.Model.EditTools.Watermark;
|
|
using PDF_Office.Model.EditTools.Watermark;
|
|
using PDF_Office.Model.PageEdit;
|
|
using PDF_Office.Model.PageEdit;
|
|
using Prism.Commands;
|
|
using Prism.Commands;
|
|
|
|
+using Prism.Events;
|
|
using Prism.Mvvm;
|
|
using Prism.Mvvm;
|
|
using Prism.Regions;
|
|
using Prism.Regions;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
|
|
+using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Windows;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.EditTools.Watermark
|
|
namespace PDF_Office.ViewModels.EditTools.Watermark
|
|
{
|
|
{
|
|
public class WatermarkCreateFileContentViewModel : BindableBase, INavigationAware
|
|
public class WatermarkCreateFileContentViewModel : BindableBase, INavigationAware
|
|
{
|
|
{
|
|
- public WatermarkInfo WatermarkInfo = new WatermarkInfo();
|
|
|
|
|
|
+ public WatermarkInfo WatermarkInfo = new WatermarkInfo();
|
|
|
|
|
|
- public CPDFViewer currentViewer;
|
|
|
|
|
|
+ private CPDFViewer PDFViewer;
|
|
|
|
+
|
|
|
|
+ IEventAggregator eventAggregator;
|
|
|
|
|
|
private List<string> _opacityList = new List<string>();
|
|
private List<string> _opacityList = new List<string>();
|
|
public List<string> OpacityList
|
|
public List<string> OpacityList
|
|
@@ -170,7 +177,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public string PageRangeText{get;set;} = "0";
|
|
|
|
|
|
+ public string PageRangeText { get; set; } = "0";
|
|
|
|
|
|
private int _pageRangeSelectIndex = 0;
|
|
private int _pageRangeSelectIndex = 0;
|
|
public int PageRangeSelectIndex
|
|
public int PageRangeSelectIndex
|
|
@@ -179,7 +186,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
|
|
set
|
|
set
|
|
{
|
|
{
|
|
SetProperty(ref _pageRangeSelectIndex, value);
|
|
SetProperty(ref _pageRangeSelectIndex, value);
|
|
- EditToolsHelper.GetPageRange(PageRangeSelectIndex, currentViewer.Document,ref WatermarkInfo.PageRange, PageRangeText);
|
|
|
|
|
|
+ EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -204,6 +211,13 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private Visibility _creatFileVisible = Visibility.Collapsed;
|
|
|
|
+ public Visibility CreatFileVisible
|
|
|
|
+ {
|
|
|
|
+ get { return _creatFileVisible; }
|
|
|
|
+ set { SetProperty(ref _creatFileVisible, value); }
|
|
|
|
+ }
|
|
|
|
+
|
|
private ObservableDictionary<string, bool> _getLocationFromNumber = new ObservableDictionary<string, bool>();
|
|
private ObservableDictionary<string, bool> _getLocationFromNumber = new ObservableDictionary<string, bool>();
|
|
public ObservableDictionary<string, bool> GetLocationFromNumber
|
|
public ObservableDictionary<string, bool> GetLocationFromNumber
|
|
{
|
|
{
|
|
@@ -216,15 +230,17 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
|
|
|
|
|
|
public DelegateCommand OpenFileCommand { get; set; }
|
|
public DelegateCommand OpenFileCommand { get; set; }
|
|
|
|
|
|
- public WatermarkCreateFileContentViewModel()
|
|
|
|
|
|
+ public WatermarkCreateFileContentViewModel(IEventAggregator eventAggregator)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ this.eventAggregator = eventAggregator;
|
|
|
|
+ WatermarkInfo.WatermarkType=C_Watermark_Type.WATERMARK_TYPE_IMG;
|
|
ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
|
|
ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
|
|
OpenFileCommand = new DelegateCommand(OpenFile);
|
|
OpenFileCommand = new DelegateCommand(OpenFile);
|
|
InitList();
|
|
InitList();
|
|
WatermarkInfo.WatermarkHorizalign = C_Watermark_Horizalign.WATERMARK_HORIZALIGN_CENTER;
|
|
WatermarkInfo.WatermarkHorizalign = C_Watermark_Horizalign.WATERMARK_HORIZALIGN_CENTER;
|
|
WatermarkInfo.WatermarkVertalign = C_Watermark_Vertalign.WATERMARK_VERTALIGN_CENTER;
|
|
WatermarkInfo.WatermarkVertalign = C_Watermark_Vertalign.WATERMARK_VERTALIGN_CENTER;
|
|
InitLocationButtonMatrix();
|
|
InitLocationButtonMatrix();
|
|
|
|
+ eventAggregator.GetEvent<ConfirmEditToolsWatermarkEvent>().Subscribe(ConfirmEditToolsWatermark);
|
|
}
|
|
}
|
|
|
|
|
|
private void SetIsFront(int Index)
|
|
private void SetIsFront(int Index)
|
|
@@ -274,14 +290,32 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public void OpenFile(){
|
|
|
|
|
|
+ public void ConfirmEditToolsWatermark(EnumTextOrFile enumTextOrFile)
|
|
|
|
+ {
|
|
|
|
+ if (enumTextOrFile == EnumTextOrFile.StatusFile)
|
|
|
|
+ {
|
|
|
|
+ eventAggregator.GetEvent<SetWatermarkEvent>().Publish(WatermarkInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void OpenFile()
|
|
|
|
+ {
|
|
System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
|
|
System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
|
|
dlg.Multiselect = false;
|
|
dlg.Multiselect = false;
|
|
- dlg.Filter = "PDF|*.png;*.jpg;";
|
|
|
|
|
|
+ dlg.Filter = "PDF|*.png;*.jpg;*.pdf";
|
|
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
{
|
|
- FileNameText = dlg.FileName;
|
|
|
|
- EditToolsHelper.ChooseFile(dlg.FileName, ref WatermarkInfo);
|
|
|
|
|
|
+ FileNameText = dlg.SafeFileName;
|
|
|
|
+ FileInfo file = new FileInfo(dlg.FileName);
|
|
|
|
+ if (file.Extension == ".pdf")
|
|
|
|
+ {
|
|
|
|
+ EditToolsHelper.ChooseFile(dlg.FileName, ref WatermarkInfo, PDFViewer.Document);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ EditToolsHelper.ChooseFile(dlg.FileName, ref WatermarkInfo);
|
|
|
|
+ }
|
|
|
|
+ CreatFileVisible=Visibility.Visible;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -296,6 +330,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
{
|
|
{
|
|
|
|
+ navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|