|
@@ -28,30 +28,39 @@ using System.Windows.Media.Imaging;
|
|
using PDFReader_WPF.Helper;
|
|
using PDFReader_WPF.Helper;
|
|
using PDF_Master.Properties;
|
|
using PDF_Master.Properties;
|
|
using PDF_Master.Model.AnnotPanel;
|
|
using PDF_Master.Model.AnnotPanel;
|
|
|
|
+using System.Diagnostics;
|
|
|
|
|
|
namespace PDF_Master.ViewModels.Tools
|
|
namespace PDF_Master.ViewModels.Tools
|
|
{
|
|
{
|
|
- public class TextEditToolContentViewModel: BindableBase, INavigationAware
|
|
|
|
|
|
+ public class TextEditToolContentViewModel : BindableBase, INavigationAware
|
|
{
|
|
{
|
|
#region 属性与变量
|
|
#region 属性与变量
|
|
|
|
+
|
|
public ViewContentViewModel viewContentViewModel;
|
|
public ViewContentViewModel viewContentViewModel;
|
|
private CPDFViewer PDFViewer;
|
|
private CPDFViewer PDFViewer;
|
|
private IEventAggregator events;
|
|
private IEventAggregator events;
|
|
private IRegionManager regions;
|
|
private IRegionManager regions;
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 用于区分事件的唯一码
|
|
/// 用于区分事件的唯一码
|
|
/// </summary>
|
|
/// </summary>
|
|
private string unicode;
|
|
private string unicode;
|
|
|
|
+
|
|
private Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
|
|
private Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
|
|
|
|
|
|
private bool _isTextEdit = false;
|
|
private bool _isTextEdit = false;
|
|
|
|
+
|
|
public bool IsTextEdit
|
|
public bool IsTextEdit
|
|
{
|
|
{
|
|
get { return _isTextEdit; }
|
|
get { return _isTextEdit; }
|
|
- set { SetProperty(ref _isTextEdit, value);
|
|
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref _isTextEdit, value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
private bool _isImgEdit = false;
|
|
private bool _isImgEdit = false;
|
|
|
|
+
|
|
public bool IsImgEdit
|
|
public bool IsImgEdit
|
|
{
|
|
{
|
|
get { return _isImgEdit; }
|
|
get { return _isImgEdit; }
|
|
@@ -61,7 +70,8 @@ namespace PDF_Master.ViewModels.Tools
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private bool _flg=false;
|
|
|
|
|
|
+ private bool _flg = false;
|
|
|
|
+
|
|
public bool flg
|
|
public bool flg
|
|
{
|
|
{
|
|
get { return _flg; }
|
|
get { return _flg; }
|
|
@@ -72,6 +82,7 @@ namespace PDF_Master.ViewModels.Tools
|
|
/// 替换图片指令
|
|
/// 替换图片指令
|
|
/// </summary>
|
|
/// </summary>
|
|
private bool _ReplaceImgflg = false;
|
|
private bool _ReplaceImgflg = false;
|
|
|
|
+
|
|
public bool ReplaceImgflg
|
|
public bool ReplaceImgflg
|
|
{
|
|
{
|
|
get { return _ReplaceImgflg; }
|
|
get { return _ReplaceImgflg; }
|
|
@@ -82,32 +93,39 @@ namespace PDF_Master.ViewModels.Tools
|
|
/// 完成裁剪图片指令
|
|
/// 完成裁剪图片指令
|
|
/// </summary>
|
|
/// </summary>
|
|
private bool _CropImgflg = false;
|
|
private bool _CropImgflg = false;
|
|
|
|
+
|
|
public bool CropImgflg
|
|
public bool CropImgflg
|
|
{
|
|
{
|
|
get { return _CropImgflg; }
|
|
get { return _CropImgflg; }
|
|
set { SetProperty(ref _CropImgflg, value); }
|
|
set { SetProperty(ref _CropImgflg, value); }
|
|
}
|
|
}
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 刷新预览图片指令
|
|
/// 刷新预览图片指令
|
|
/// </summary>
|
|
/// </summary>
|
|
private bool _REImgflg = false;
|
|
private bool _REImgflg = false;
|
|
|
|
+
|
|
public bool REImgflg
|
|
public bool REImgflg
|
|
{
|
|
{
|
|
get { return _REImgflg; }
|
|
get { return _REImgflg; }
|
|
set { SetProperty(ref _REImgflg, value); }
|
|
set { SetProperty(ref _REImgflg, value); }
|
|
}
|
|
}
|
|
- #endregion
|
|
|
|
|
|
+
|
|
|
|
+ #endregion 属性与变量
|
|
|
|
|
|
#region Command
|
|
#region Command
|
|
|
|
+
|
|
// 添加文本、图像
|
|
// 添加文本、图像
|
|
public DelegateCommand<object> AddContentCommand { get; set; }
|
|
public DelegateCommand<object> AddContentCommand { get; set; }
|
|
|
|
+
|
|
public DelegateCommand AddTextCommand { get; set; }
|
|
public DelegateCommand AddTextCommand { get; set; }
|
|
public DelegateCommand AddImgCommand { get; set; }
|
|
public DelegateCommand AddImgCommand { get; set; }
|
|
public DelegateCommand EditTextModeCommand { get; set; }
|
|
public DelegateCommand EditTextModeCommand { get; set; }
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
+ #endregion Command
|
|
|
|
|
|
#region 初始化
|
|
#region 初始化
|
|
|
|
+
|
|
public TextEditToolContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
|
|
public TextEditToolContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
|
|
{
|
|
{
|
|
events = eventAggregator;
|
|
events = eventAggregator;
|
|
@@ -116,6 +134,7 @@ namespace PDF_Master.ViewModels.Tools
|
|
InitCommand();
|
|
InitCommand();
|
|
InitBtnToProperty();
|
|
InitBtnToProperty();
|
|
}
|
|
}
|
|
|
|
+
|
|
private void InitCommand()
|
|
private void InitCommand()
|
|
{
|
|
{
|
|
AddContentCommand = new DelegateCommand<object>(AddContent);
|
|
AddContentCommand = new DelegateCommand<object>(AddContent);
|
|
@@ -132,7 +151,8 @@ namespace PDF_Master.ViewModels.Tools
|
|
btnToProperty.Add("PropertyPanelContentEdit", "PropertyPanelContentEdit");
|
|
btnToProperty.Add("PropertyPanelContentEdit", "PropertyPanelContentEdit");
|
|
}
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
+ #endregion 初始化
|
|
|
|
+
|
|
#region 右键菜单
|
|
#region 右键菜单
|
|
|
|
|
|
//点击空白处时
|
|
//点击空白处时
|
|
@@ -155,7 +175,7 @@ namespace PDF_Master.ViewModels.Tools
|
|
{
|
|
{
|
|
var popMenu = App.Current.FindResource("SelectTextMenu") as ContextMenu;
|
|
var popMenu = App.Current.FindResource("SelectTextMenu") as ContextMenu;
|
|
CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
|
|
CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
|
|
-
|
|
|
|
|
|
+
|
|
//复制
|
|
//复制
|
|
customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
|
|
customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
|
|
//剪切
|
|
//剪切
|
|
@@ -169,7 +189,7 @@ namespace PDF_Master.ViewModels.Tools
|
|
|
|
|
|
return popMenu;
|
|
return popMenu;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//选中文字内容
|
|
//选中文字内容
|
|
private ContextMenu SelectTextContent(object sender)
|
|
private ContextMenu SelectTextContent(object sender)
|
|
{
|
|
{
|
|
@@ -209,10 +229,11 @@ namespace PDF_Master.ViewModels.Tools
|
|
////删除
|
|
////删除
|
|
//customMenu.SetMenuBinding(4, ApplicationCommands.Delete);
|
|
//customMenu.SetMenuBinding(4, ApplicationCommands.Delete);
|
|
|
|
|
|
-
|
|
|
|
return popMenu;
|
|
return popMenu;
|
|
}
|
|
}
|
|
- #endregion
|
|
|
|
|
|
+
|
|
|
|
+ #endregion 右键菜单
|
|
|
|
+
|
|
#region 图片右键菜单
|
|
#region 图片右键菜单
|
|
|
|
|
|
//选中图像时
|
|
//选中图像时
|
|
@@ -252,6 +273,7 @@ namespace PDF_Master.ViewModels.Tools
|
|
customMenu.SetMenuBinding(2, new DelegateCommand(RestoreCropImg));
|
|
customMenu.SetMenuBinding(2, new DelegateCommand(RestoreCropImg));
|
|
return popMenu;
|
|
return popMenu;
|
|
}
|
|
}
|
|
|
|
+
|
|
//多选图片右键
|
|
//多选图片右键
|
|
private ContextMenu SelectMoreImage(object sender)
|
|
private ContextMenu SelectMoreImage(object sender)
|
|
{
|
|
{
|
|
@@ -268,11 +290,13 @@ namespace PDF_Master.ViewModels.Tools
|
|
//导出
|
|
//导出
|
|
customMenu.SetMenuBinding(4, new DelegateCommand(ExportImg));
|
|
customMenu.SetMenuBinding(4, new DelegateCommand(ExportImg));
|
|
|
|
|
|
-
|
|
|
|
return popMenu;
|
|
return popMenu;
|
|
}
|
|
}
|
|
- #endregion
|
|
|
|
|
|
+
|
|
|
|
+ #endregion 图片右键菜单
|
|
|
|
+
|
|
#region 快捷键
|
|
#region 快捷键
|
|
|
|
+
|
|
private void ShortCut_KeyDown(object sender, KeyEventArgs e)
|
|
private void ShortCut_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
@@ -284,35 +308,33 @@ namespace PDF_Master.ViewModels.Tools
|
|
//缩小esc的操作范围
|
|
//缩小esc的操作范围
|
|
if (PDFViewer.ToolManager != null && PDFViewer.GetPDFEditCreateType() == ComPDFKit.PDFPage.CPDFEditType.EditText)
|
|
if (PDFViewer.ToolManager != null && PDFViewer.GetPDFEditCreateType() == ComPDFKit.PDFPage.CPDFEditType.EditText)
|
|
{
|
|
{
|
|
- if(PDFViewer.GetPDFEditSelectionCount(ComPDFKit.PDFPage.CPDFEditType.EditText) ==0)
|
|
|
|
- {
|
|
|
|
- PDFViewer.RemovePDFEditEmptyText();
|
|
|
|
- //只有在有画框的时候才进行
|
|
|
|
- if (PDFViewer.MouseMode == MouseModes.PDFEdit&& PDFViewer.ToolManager.HasTool == true)
|
|
|
|
|
|
+ if (PDFViewer.GetPDFEditSelectionCount(ComPDFKit.PDFPage.CPDFEditType.EditText) == 0)
|
|
{
|
|
{
|
|
- PDFViewer.RemoveTool(false);
|
|
|
|
- }
|
|
|
|
- else if (IsTextEdit == true || IsImgEdit == true)
|
|
|
|
- {
|
|
|
|
- IsImgEdit = false;
|
|
|
|
- IsTextEdit = false;
|
|
|
|
- PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.None);
|
|
|
|
|
|
+ PDFViewer.RemovePDFEditEmptyText();
|
|
|
|
+ //只有在有画框的时候才进行
|
|
|
|
+ if (PDFViewer.MouseMode == MouseModes.PDFEdit && PDFViewer.ToolManager.HasTool == true)
|
|
|
|
+ {
|
|
|
|
+ PDFViewer.RemoveTool(false);
|
|
|
|
+ }
|
|
|
|
+ else if (IsTextEdit == true || IsImgEdit == true)
|
|
|
|
+ {
|
|
|
|
+ IsImgEdit = false;
|
|
|
|
+ IsTextEdit = false;
|
|
|
|
+ PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.None);
|
|
|
|
|
|
- //文本和图像都框选
|
|
|
|
- PDFViewer.SetPDFEditType(ComPDFKit.PDFPage.CPDFEditType.EditText | ComPDFKit.PDFPage.CPDFEditType.EditImage);
|
|
|
|
- PDFViewer.SetMouseMode(MouseModes.PDFEdit);
|
|
|
|
- PDFViewer.ReloadDocument();
|
|
|
|
- ShowPropertyPanel(false);
|
|
|
|
- }
|
|
|
|
|
|
+ //文本和图像都框选
|
|
|
|
+ PDFViewer.SetPDFEditType(ComPDFKit.PDFPage.CPDFEditType.EditText | ComPDFKit.PDFPage.CPDFEditType.EditImage);
|
|
|
|
+ PDFViewer.SetMouseMode(MouseModes.PDFEdit);
|
|
|
|
+ PDFViewer.ReloadDocument();
|
|
|
|
+ ShowPropertyPanel(false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
{
|
|
{
|
|
PDFViewer.ClearSelectPDFEdit();
|
|
PDFViewer.ClearSelectPDFEdit();
|
|
PDFViewer.RemovePDFEditEmptyText();
|
|
PDFViewer.RemovePDFEditEmptyText();
|
|
PDFViewer.ReloadDocument();
|
|
PDFViewer.ReloadDocument();
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
else if (PDFViewer.ToolManager != null && PDFViewer.GetPDFEditCreateType() == ComPDFKit.PDFPage.CPDFEditType.EditImage)
|
|
else if (PDFViewer.ToolManager != null && PDFViewer.GetPDFEditCreateType() == ComPDFKit.PDFPage.CPDFEditType.EditImage)
|
|
{
|
|
{
|
|
if (PDFViewer.GetPDFEditSelectionCount(ComPDFKit.PDFPage.CPDFEditType.EditImage) == 0)
|
|
if (PDFViewer.GetPDFEditSelectionCount(ComPDFKit.PDFPage.CPDFEditType.EditImage) == 0)
|
|
@@ -341,32 +363,21 @@ namespace PDF_Master.ViewModels.Tools
|
|
PDFViewer.ReloadDocument();
|
|
PDFViewer.ReloadDocument();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
else if (PDFViewer.ToolManager != null)
|
|
else if (PDFViewer.ToolManager != null)
|
|
{
|
|
{
|
|
PDFViewer.ClearSelectPDFEdit();
|
|
PDFViewer.ClearSelectPDFEdit();
|
|
AddToPropertyPanel("PropertyPanelContentEdit", null);
|
|
AddToPropertyPanel("PropertyPanelContentEdit", null);
|
|
PDFViewer.ReloadDocument();
|
|
PDFViewer.ReloadDocument();
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
catch
|
|
catch
|
|
{
|
|
{
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
- #endregion
|
|
|
|
|
|
+
|
|
|
|
+ #endregion 快捷键
|
|
|
|
|
|
//模式选择进入
|
|
//模式选择进入
|
|
public void AddContent(object obj)
|
|
public void AddContent(object obj)
|
|
@@ -378,21 +389,21 @@ namespace PDF_Master.ViewModels.Tools
|
|
IsImgEdit = false;
|
|
IsImgEdit = false;
|
|
IsTextEdit = false;
|
|
IsTextEdit = false;
|
|
PDFViewer.SetPDFEditType(ComPDFKit.PDFPage.CPDFEditType.None);
|
|
PDFViewer.SetPDFEditType(ComPDFKit.PDFPage.CPDFEditType.None);
|
|
- PDFViewer.ReloadDocument();
|
|
|
|
|
|
+ PDFViewer.ReloadDocument();
|
|
App.mainWindowViewModel.OpenLogin();
|
|
App.mainWindowViewModel.OpenLogin();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var btn = obj as CustomIconToggleBtn;
|
|
var btn = obj as CustomIconToggleBtn;
|
|
EnterEditMode((bool)btn.IsChecked, btn.Tag.ToString());
|
|
EnterEditMode((bool)btn.IsChecked, btn.Tag.ToString());
|
|
}
|
|
}
|
|
|
|
+
|
|
//编辑按钮逻辑,暂时保留
|
|
//编辑按钮逻辑,暂时保留
|
|
private void EditTextMode()
|
|
private void EditTextMode()
|
|
{
|
|
{
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//对应模式的逻辑
|
|
//对应模式的逻辑
|
|
- private void EnterEditMode(bool isCheckMode,string modeType)
|
|
|
|
|
|
+ private void EnterEditMode(bool isCheckMode, string modeType)
|
|
{
|
|
{
|
|
if (isCheckMode)
|
|
if (isCheckMode)
|
|
{
|
|
{
|
|
@@ -435,7 +446,6 @@ namespace PDF_Master.ViewModels.Tools
|
|
PDFViewer.ReloadDocument();
|
|
PDFViewer.ReloadDocument();
|
|
AddToPropertyPanel("PropertyPanelContentEdit", null);
|
|
AddToPropertyPanel("PropertyPanelContentEdit", null);
|
|
ShowPropertyPanel(true);
|
|
ShowPropertyPanel(true);
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -449,7 +459,6 @@ namespace PDF_Master.ViewModels.Tools
|
|
PDFViewer.SetMouseMode(MouseModes.PDFEdit);
|
|
PDFViewer.SetMouseMode(MouseModes.PDFEdit);
|
|
PDFViewer.ReloadDocument();
|
|
PDFViewer.ReloadDocument();
|
|
ShowPropertyPanel(false);
|
|
ShowPropertyPanel(false);
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -464,12 +473,12 @@ namespace PDF_Master.ViewModels.Tools
|
|
{
|
|
{
|
|
EnterEditMode(true, "Image");
|
|
EnterEditMode(true, "Image");
|
|
}
|
|
}
|
|
|
|
+
|
|
//进入裁剪模式
|
|
//进入裁剪模式
|
|
private void CropMode()
|
|
private void CropMode()
|
|
{
|
|
{
|
|
if (TextEditEvent != null)
|
|
if (TextEditEvent != null)
|
|
{
|
|
{
|
|
-
|
|
|
|
TextEditEvent.ClipImage = true;
|
|
TextEditEvent.ClipImage = true;
|
|
TextEditEvent.UpdatePDFEditByEventArgs();
|
|
TextEditEvent.UpdatePDFEditByEventArgs();
|
|
flg = true;
|
|
flg = true;
|
|
@@ -496,16 +505,14 @@ namespace PDF_Master.ViewModels.Tools
|
|
TextEditEvent.RestoreClip();
|
|
TextEditEvent.RestoreClip();
|
|
events.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode));
|
|
events.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode));
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//完成裁剪
|
|
//完成裁剪
|
|
private void CropImg()
|
|
private void CropImg()
|
|
{
|
|
{
|
|
-
|
|
|
|
CropImgflg = true;
|
|
CropImgflg = true;
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
//导出图片
|
|
//导出图片
|
|
private void ExportImg()
|
|
private void ExportImg()
|
|
{
|
|
{
|
|
@@ -534,16 +541,19 @@ namespace PDF_Master.ViewModels.Tools
|
|
CommonHelper.ShowFileBrowser(strFilePath);
|
|
CommonHelper.ShowFileBrowser(strFilePath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //替换图片
|
|
|
|
- private void ReplaceImg()
|
|
|
|
|
|
+
|
|
|
|
+ //替换图片
|
|
|
|
+ private void ReplaceImg()
|
|
{
|
|
{
|
|
ReplaceImgflg = true;
|
|
ReplaceImgflg = true;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//选中的图像
|
|
//选中的图像
|
|
private System.Windows.Media.Imaging.BitmapSource _currentImg;
|
|
private System.Windows.Media.Imaging.BitmapSource _currentImg;
|
|
- public System.Windows.Media.Imaging.BitmapSource CurrentImg { get { return _currentImg; } set { SetProperty(ref _currentImg, value); } }
|
|
|
|
|
|
+
|
|
|
|
+ public System.Windows.Media.Imaging.BitmapSource CurrentImg
|
|
|
|
+ { get { return _currentImg; } set { SetProperty(ref _currentImg, value); } }
|
|
|
|
+
|
|
private void GetImagePreView()
|
|
private void GetImagePreView()
|
|
{
|
|
{
|
|
try
|
|
try
|
|
@@ -568,21 +578,17 @@ namespace PDF_Master.ViewModels.Tools
|
|
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
|
|
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
|
|
CurrentImg = bitmapSource;
|
|
CurrentImg = bitmapSource;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
catch
|
|
{
|
|
{
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
- #endregion
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
+ #endregion Command功能
|
|
|
|
|
|
//传参数给属性面板
|
|
//传参数给属性面板
|
|
- private void AddToPropertyPanel(string type, List<PDFEditEvent> e)
|
|
|
|
|
|
+ private void AddToPropertyPanel(string type, List<PDFEditEvent> e)
|
|
{
|
|
{
|
|
if (btnToProperty.ContainsKey(type))
|
|
if (btnToProperty.ContainsKey(type))
|
|
{
|
|
{
|
|
@@ -595,11 +601,11 @@ namespace PDF_Master.ViewModels.Tools
|
|
regions.RequestNavigate(RegionNames.PropertyRegionName, btnToProperty[type], parameters);
|
|
regions.RequestNavigate(RegionNames.PropertyRegionName, btnToProperty[type], parameters);
|
|
}));
|
|
}));
|
|
|
|
|
|
- if(e!=null)
|
|
|
|
|
|
+ if (e != null)
|
|
{
|
|
{
|
|
ShowPropertyPanel(true);
|
|
ShowPropertyPanel(true);
|
|
}
|
|
}
|
|
- else if(e==null&&IsImgEdit==false&&IsTextEdit==false)
|
|
|
|
|
|
+ else if (e == null && IsImgEdit == false && IsTextEdit == false)
|
|
{
|
|
{
|
|
ShowPropertyPanel(false);
|
|
ShowPropertyPanel(false);
|
|
}
|
|
}
|
|
@@ -629,13 +635,12 @@ namespace PDF_Master.ViewModels.Tools
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
-
|
|
|
|
PDFViewer.SetPDFEditType(ComPDFKit.PDFPage.CPDFEditType.None);
|
|
PDFViewer.SetPDFEditType(ComPDFKit.PDFPage.CPDFEditType.None);
|
|
PDFViewer.ReloadDocument();
|
|
PDFViewer.ReloadDocument();
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
{
|
|
{
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
@@ -652,7 +657,6 @@ namespace PDF_Master.ViewModels.Tools
|
|
PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
|
|
PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
|
|
PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
|
|
PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
|
|
|
|
|
|
-
|
|
|
|
//图片添加
|
|
//图片添加
|
|
PDFViewer.CustomNotifyHandler -= PDFViewer_CustomNotifyHandler;
|
|
PDFViewer.CustomNotifyHandler -= PDFViewer_CustomNotifyHandler;
|
|
PDFViewer.CustomNotifyHandler += PDFViewer_CustomNotifyHandler;
|
|
PDFViewer.CustomNotifyHandler += PDFViewer_CustomNotifyHandler;
|
|
@@ -669,14 +673,15 @@ namespace PDF_Master.ViewModels.Tools
|
|
private void PDFViewer_PDFEditHandler(object sender, List<PDFEditSelectionData> e)
|
|
private void PDFViewer_PDFEditHandler(object sender, List<PDFEditSelectionData> e)
|
|
{
|
|
{
|
|
PDFViewer.ClearSelectPDFEdit();
|
|
PDFViewer.ClearSelectPDFEdit();
|
|
- PDFViewer.SelectPDFEdit(e,true);
|
|
|
|
|
|
+ PDFViewer.SelectPDFEdit(e, true);
|
|
}
|
|
}
|
|
|
|
|
|
protected PDFEditEvent TextEditEvent;
|
|
protected PDFEditEvent TextEditEvent;
|
|
|
|
+
|
|
//左键激活逻辑
|
|
//左键激活逻辑
|
|
private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
|
|
private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
|
|
{
|
|
{
|
|
- PDFViewer.ToolManager.IgnoreMoveDistance =5;
|
|
|
|
|
|
+ PDFViewer.ToolManager.IgnoreMoveDistance = 5;
|
|
//判断是否已退出登录,限制编辑操作
|
|
//判断是否已退出登录,限制编辑操作
|
|
if (!App.IsLogin)
|
|
if (!App.IsLogin)
|
|
{
|
|
{
|
|
@@ -689,12 +694,11 @@ namespace PDF_Master.ViewModels.Tools
|
|
}
|
|
}
|
|
if (e != null && e.Count > 0)
|
|
if (e != null && e.Count > 0)
|
|
{
|
|
{
|
|
- TextEditEvent=e[0];
|
|
|
|
|
|
+ TextEditEvent = e[0];
|
|
bool isText = false;
|
|
bool isText = false;
|
|
bool isImg = false;
|
|
bool isImg = false;
|
|
foreach (var item in e)
|
|
foreach (var item in e)
|
|
{
|
|
{
|
|
-
|
|
|
|
if (item.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
|
|
if (item.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
|
|
{
|
|
{
|
|
isImg = true;
|
|
isImg = true;
|
|
@@ -705,26 +709,21 @@ namespace PDF_Master.ViewModels.Tools
|
|
isText = true;
|
|
isText = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
if (isText == true && isImg == false)
|
|
if (isText == true && isImg == false)
|
|
{
|
|
{
|
|
AddToPropertyPanel("Text", e);
|
|
AddToPropertyPanel("Text", e);
|
|
-
|
|
|
|
}
|
|
}
|
|
if (isText == false && isImg == true)
|
|
if (isText == false && isImg == true)
|
|
{
|
|
{
|
|
AddToPropertyPanel("Image", e);
|
|
AddToPropertyPanel("Image", e);
|
|
-
|
|
|
|
}
|
|
}
|
|
if (isText == true && isImg == true)
|
|
if (isText == true && isImg == true)
|
|
{
|
|
{
|
|
AddToPropertyPanel("TextAndImage", e);
|
|
AddToPropertyPanel("TextAndImage", e);
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ ///未事先设置 if里面的内容,单击添加文本会失败
|
|
//else if(IsTextEdit==true)
|
|
//else if(IsTextEdit==true)
|
|
//{
|
|
//{
|
|
// //单击添加文本
|
|
// //单击添加文本
|
|
@@ -735,12 +734,11 @@ namespace PDF_Master.ViewModels.Tools
|
|
//}
|
|
//}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ Trace.WriteLine("PropertyPanelContentEdit");
|
|
AddToPropertyPanel("PropertyPanelContentEdit", null);
|
|
AddToPropertyPanel("PropertyPanelContentEdit", null);
|
|
}
|
|
}
|
|
|
|
|
|
events.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode));
|
|
events.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode));
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//右键点击逻辑
|
|
//右键点击逻辑
|
|
@@ -756,34 +754,28 @@ namespace PDF_Master.ViewModels.Tools
|
|
if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)//点击空白区域
|
|
if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)//点击空白区域
|
|
{
|
|
{
|
|
e.PopupMenu = EmptyStateMenu(sender);
|
|
e.PopupMenu = EmptyStateMenu(sender);
|
|
-
|
|
|
|
}
|
|
}
|
|
else if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditText)
|
|
else if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditText)
|
|
{
|
|
{
|
|
-
|
|
|
|
-
|
|
|
|
//文字编辑
|
|
//文字编辑
|
|
if (e.PressOnBorder == true)
|
|
if (e.PressOnBorder == true)
|
|
{
|
|
{
|
|
e.PopupMenu = SelectTextBorder(sender);
|
|
e.PopupMenu = SelectTextBorder(sender);
|
|
}
|
|
}
|
|
-
|
|
|
|
- else if(e.PressOnSelectedText == true)
|
|
|
|
|
|
+ else if (e.PressOnSelectedText == true)
|
|
{
|
|
{
|
|
e.PopupMenu = SelectTextContent(sender);
|
|
e.PopupMenu = SelectTextContent(sender);
|
|
}
|
|
}
|
|
-
|
|
|
|
- else if(e.SelectText=="")
|
|
|
|
|
|
+ else if (e.SelectText == "")
|
|
{
|
|
{
|
|
- e.PopupMenu= EditTextContent(sender);
|
|
|
|
|
|
+ e.PopupMenu = EditTextContent(sender);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
e.PopupMenu = SelectTextContent(sender);
|
|
e.PopupMenu = SelectTextContent(sender);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
- else if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
|
|
|
|
|
|
+ else if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
|
|
{
|
|
{
|
|
if (e.IsClipState == true)
|
|
if (e.IsClipState == true)
|
|
{
|
|
{
|
|
@@ -793,15 +785,13 @@ namespace PDF_Master.ViewModels.Tools
|
|
{
|
|
{
|
|
e.PopupMenu = SelectImgPDFEdit(sender);
|
|
e.PopupMenu = SelectImgPDFEdit(sender);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- break;
|
|
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
|
|
default:
|
|
default:
|
|
e.DoCommand();
|
|
e.DoCommand();
|
|
break;
|
|
break;
|
|
-
|
|
|
|
}
|
|
}
|
|
if (e.PopupMenu != null)
|
|
if (e.PopupMenu != null)
|
|
{
|
|
{
|
|
@@ -810,7 +800,6 @@ namespace PDF_Master.ViewModels.Tools
|
|
flg = e.IsClipState;
|
|
flg = e.IsClipState;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//图片添加逻辑
|
|
//图片添加逻辑
|
|
private void PDFViewer_CustomNotifyHandler(object sender, CustomNotityData e)
|
|
private void PDFViewer_CustomNotifyHandler(object sender, CustomNotityData e)
|
|
{
|
|
{
|
|
@@ -818,15 +807,15 @@ namespace PDF_Master.ViewModels.Tools
|
|
if (e.NotifyType == CustomNotifyType.PDFEditImageCreate)
|
|
if (e.NotifyType == CustomNotifyType.PDFEditImageCreate)
|
|
{
|
|
{
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
- openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
|
|
|
|
- if (openFileDialog.ShowDialog() == true)
|
|
|
|
- {
|
|
|
|
- PDFViewer.AddPDFEditImage(CompressImage(openFileDialog.FileName, 800), 500,500);
|
|
|
|
|
|
+ openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
|
|
|
|
+ if (openFileDialog.ShowDialog() == true)
|
|
|
|
+ {
|
|
|
|
+ PDFViewer.AddPDFEditImage(CompressImage(openFileDialog.FileName, 800), 500, 500);
|
|
events.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode));
|
|
events.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode));
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
//图片调整大小
|
|
//图片调整大小
|
|
- else if(e.NotifyType == CustomNotifyType.PDFEditImageResize)
|
|
|
|
|
|
+ else if (e.NotifyType == CustomNotifyType.PDFEditImageResize)
|
|
{
|
|
{
|
|
REImgflg = true;
|
|
REImgflg = true;
|
|
events.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode));
|
|
events.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode));
|
|
@@ -888,7 +877,6 @@ namespace PDF_Master.ViewModels.Tools
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 根据图片数据判断图片类型
|
|
/// 根据图片数据判断图片类型
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -912,7 +900,6 @@ namespace PDF_Master.ViewModels.Tools
|
|
}
|
|
}
|
|
catch
|
|
catch
|
|
{
|
|
{
|
|
-
|
|
|
|
extension = FileExtension.VALIDFILE;
|
|
extension = FileExtension.VALIDFILE;
|
|
}
|
|
}
|
|
return extension;
|
|
return extension;
|
|
@@ -935,18 +922,17 @@ namespace PDF_Master.ViewModels.Tools
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
{
|
|
{
|
|
IsImgEdit = false;
|
|
IsImgEdit = false;
|
|
IsTextEdit = false;
|
|
IsTextEdit = false;
|
|
PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
|
|
PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
|
|
PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
|
|
PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
|
|
- PDFViewer.CustomNotifyHandler -= PDFViewer_CustomNotifyHandler;
|
|
|
|
|
|
+ PDFViewer.CustomNotifyHandler -= PDFViewer_CustomNotifyHandler;
|
|
PDFViewer.PDFEditHandler -= PDFViewer_PDFEditHandler;
|
|
PDFViewer.PDFEditHandler -= PDFViewer_PDFEditHandler;
|
|
KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
|
|
KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
|
|
ShowPropertyPanel(false);
|
|
ShowPropertyPanel(false);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|