|
@@ -28,15 +28,16 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
{
|
|
|
public TextEditToolContentViewModel TextEditToolContentViewModel;
|
|
|
private IEventAggregator events;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 用于区分事件的唯一码
|
|
|
/// </summary>
|
|
|
private string unicode;
|
|
|
+
|
|
|
#region 快捷键
|
|
|
+
|
|
|
private void ShortCut_KeyDown(object sender, KeyEventArgs e)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
if (e.Key == Key.Escape)
|
|
|
{
|
|
|
if (PDFViewer != null)
|
|
@@ -44,33 +45,34 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
if (PDFViewer.ToolManager != null && IsCrop == true)
|
|
|
{
|
|
|
CancelCropImg();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- else if(e.Key==Key.Enter)
|
|
|
+ else if (e.Key == Key.Enter)
|
|
|
{
|
|
|
CropImg();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+ #endregion 快捷键
|
|
|
|
|
|
- #endregion
|
|
|
#region 属性和变量
|
|
|
+
|
|
|
//防止自动保存属性值
|
|
|
private bool isCanSave = false;
|
|
|
- public event EventHandler ClearCheckedAglin;
|
|
|
|
|
|
+ public event EventHandler ClearCheckedAglin;
|
|
|
|
|
|
#region 是否为多选内容
|
|
|
+
|
|
|
private bool _isMultiSelectImage = false;
|
|
|
- public bool IsMultiSelectImage { get { return _isMultiSelectImage; } set { SetProperty(ref _isMultiSelectImage, value); } }
|
|
|
- #endregion
|
|
|
-
|
|
|
- private string _opacity1= "Opacity";
|
|
|
+ public bool IsMultiSelectImage
|
|
|
+ { get { return _isMultiSelectImage; } set { SetProperty(ref _isMultiSelectImage, value); } }
|
|
|
+
|
|
|
+ #endregion 是否为多选内容
|
|
|
+
|
|
|
+ private string _opacity1 = "Opacity";
|
|
|
+
|
|
|
public string Opacity
|
|
|
{
|
|
|
get { return _opacity1; }
|
|
@@ -79,30 +81,34 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
|
|
|
//不透明度
|
|
|
private double _opacity;
|
|
|
+
|
|
|
public double OpacityUI
|
|
|
{
|
|
|
get { return _opacity; }
|
|
|
set { SetProperty(ref _opacity, value); }
|
|
|
}
|
|
|
+
|
|
|
private int _OpacitySelectedIndex = 1;
|
|
|
+
|
|
|
public int OpacitySelectedIndex
|
|
|
{
|
|
|
get { return _OpacitySelectedIndex; }
|
|
|
set { SetProperty(ref _OpacitySelectedIndex, value); }
|
|
|
}
|
|
|
+
|
|
|
private double _transpent;
|
|
|
+
|
|
|
public double Transpent
|
|
|
{
|
|
|
get { return _transpent; }
|
|
|
set
|
|
|
{
|
|
|
SetProperty(ref _transpent, value);
|
|
|
- if (Transpent == 100|| Transpent == 75||Transpent == 50|| (Transpent == 25))
|
|
|
+ if (Transpent == 100 || Transpent == 75 || Transpent == 50 || (Transpent == 25))
|
|
|
{
|
|
|
TextEditEvent.Transparency = (int)((_transpent * 255) / 100.0);
|
|
|
TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
OpacityUI = _transpent / 100.0;
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -110,11 +116,13 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//是否为图片裁剪状态
|
|
|
private bool _isCrop = false;
|
|
|
- public bool IsCrop { get { return _isCrop; } set { SetProperty(ref _isCrop, value); } }
|
|
|
- public TextEditToolContentViewModel _viewModel1;
|
|
|
|
|
|
+ public bool IsCrop
|
|
|
+ { get { return _isCrop; } set { SetProperty(ref _isCrop, value); } }
|
|
|
+ public TextEditToolContentViewModel _viewModel1;
|
|
|
|
|
|
//public ImageEditPropertyViewModel(TextEditToolContentViewModel viewModel1)
|
|
|
//{
|
|
@@ -122,16 +130,15 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
// _viewModel1.PropertyChanged += OnViewModel1PropertyChanged;
|
|
|
//}
|
|
|
|
|
|
-
|
|
|
private void OnViewModel1PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
{
|
|
|
if (e.PropertyName == "flg")
|
|
|
{
|
|
|
IsCrop = _viewModel1.flg;
|
|
|
}
|
|
|
- if(e.PropertyName== "ReplaceImgflg")
|
|
|
+ if (e.PropertyName == "ReplaceImgflg")
|
|
|
{
|
|
|
- if(_viewModel1.ReplaceImgflg==true)
|
|
|
+ if (_viewModel1.ReplaceImgflg == true)
|
|
|
{
|
|
|
ReplaceImg();
|
|
|
_viewModel1.ReplaceImgflg = false;
|
|
@@ -157,18 +164,23 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
|
|
|
//选中的图像
|
|
|
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); } }
|
|
|
|
|
|
- #endregion
|
|
|
+ #endregion 属性和变量
|
|
|
|
|
|
#region Command
|
|
|
+
|
|
|
//替换
|
|
|
public DelegateCommand ReplaceImgCommand { get; set; }
|
|
|
+
|
|
|
//导出
|
|
|
public DelegateCommand ExportImgCommand { get; set; }
|
|
|
+
|
|
|
//裁剪
|
|
|
public DelegateCommand CropImgCommand { get; set; }
|
|
|
+
|
|
|
//对齐
|
|
|
public DelegateCommand<object> ImgAlignCheckedCommand { get; set; }
|
|
|
|
|
@@ -183,16 +195,19 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
|
|
|
//上下翻转
|
|
|
public DelegateCommand UpsidedownCommand { get; set; }
|
|
|
+
|
|
|
//裁剪状态
|
|
|
public DelegateCommand CropModeCommand { get; set; }
|
|
|
+
|
|
|
//取消裁剪状态
|
|
|
public DelegateCommand CancelCropCommand { get; set; }
|
|
|
|
|
|
//还原裁剪状态
|
|
|
public DelegateCommand RestoreCropCommand { get; set; }
|
|
|
-
|
|
|
+
|
|
|
//添加文本
|
|
|
public DelegateCommand AddTextCommand { get; set; }
|
|
|
+
|
|
|
//添加图片
|
|
|
public DelegateCommand AddImgCommand { get; set; }
|
|
|
|
|
@@ -200,7 +215,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
public DelegateCommand TranspentslidCommand { get; set; }
|
|
|
|
|
|
public DelegateCommand EditImgModeCommand { get; set; }
|
|
|
- #endregion
|
|
|
+
|
|
|
+ #endregion Command
|
|
|
|
|
|
public ImageEditPropertyViewModel(IEventAggregator eventAggregator)
|
|
|
{
|
|
@@ -208,16 +224,16 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
events = eventAggregator;
|
|
|
unicode = App.mainWindowViewModel.SelectedItem.Unicode;
|
|
|
}
|
|
|
+
|
|
|
private void InitCommand()
|
|
|
{
|
|
|
-
|
|
|
AddTextCommand = new DelegateCommand(AddText);
|
|
|
AddImgCommand = new DelegateCommand(AddImg);
|
|
|
ReplaceImgCommand = new DelegateCommand(ReplaceImg);
|
|
|
ExportImgCommand = new DelegateCommand(ExportImg);
|
|
|
CropImgCommand = new DelegateCommand(CropImg);
|
|
|
ImgAlignCheckedCommand = new DelegateCommand<object>(ImgAlignChecked);
|
|
|
- TranspentslidCommand = new DelegateCommand(Transpentslid);
|
|
|
+ TranspentslidCommand = new DelegateCommand(Transpentslid);
|
|
|
AntiClockwiseCommand = new DelegateCommand(AntiClockwise);
|
|
|
ClockwiseCommand = new DelegateCommand(Clockwise);
|
|
|
FlipleftrightCommand = new DelegateCommand(Flipleftright);
|
|
@@ -225,14 +241,13 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
CropModeCommand = new DelegateCommand(CropMode);
|
|
|
CancelCropCommand = new DelegateCommand(CancelCropImg);
|
|
|
RestoreCropCommand = new DelegateCommand(RestoreCropImg);
|
|
|
- EditImgModeCommand = new DelegateCommand(EditImgMode);
|
|
|
+ EditImgModeCommand = new DelegateCommand(EditImgMode);
|
|
|
}
|
|
|
|
|
|
#region Command实现
|
|
|
-
|
|
|
|
|
|
//不透明度滑动左键松开
|
|
|
- private void Transpentslid()
|
|
|
+ private void Transpentslid()
|
|
|
{
|
|
|
if (TextEditEvent != null && isCanSave)
|
|
|
{
|
|
@@ -247,19 +262,17 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- TextEditEvent.Transparency = (int)((_transpent * 255)/100.0);
|
|
|
+ TextEditEvent.Transparency = (int)((_transpent * 255) / 100.0);
|
|
|
TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
OpacityUI = _transpent / 100.0;
|
|
|
TextEditEvent.SaveClip();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//点击编辑按钮,暂时保留
|
|
|
private void EditImgMode()
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//添加文本模式
|
|
@@ -284,6 +297,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 压缩
|
|
|
/// </summary>
|
|
@@ -339,7 +353,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 根据图片数据判断图片类型
|
|
|
/// </summary>
|
|
@@ -363,7 +376,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
-
|
|
|
extension = FileExtension.VALIDFILE;
|
|
|
}
|
|
|
return extension;
|
|
@@ -382,7 +394,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//进入裁剪模式
|
|
|
private void CropMode()
|
|
|
{
|
|
@@ -471,20 +482,18 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
TextEditEvent.ReplaceImagePath = openFileDialog.FileName;
|
|
|
TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
ReplaceimgTask();
|
|
|
- Transpent =100;
|
|
|
+ Transpent = 100;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//此处只有异步 ReplaceimgTask()才有作用
|
|
|
private async void ReplaceimgTask()
|
|
|
{
|
|
|
- await Task.Delay(100);
|
|
|
+ await Task.Delay(10);
|
|
|
GetImagePreView();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//顺时针旋转
|
|
|
private void Clockwise()
|
|
|
{
|
|
@@ -509,9 +518,9 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
private void Upsidedown()
|
|
|
{
|
|
|
TextEditEvent.VerticalMirror = true;
|
|
|
-
|
|
|
+
|
|
|
TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
- GetImagePreView();
|
|
|
+ GetImagePreView();
|
|
|
}
|
|
|
|
|
|
//旋转逻辑
|
|
@@ -533,9 +542,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
+ #endregion Command实现
|
|
|
|
|
|
#region 布局处理
|
|
|
+
|
|
|
private void ImgAlignChecked(object obj)
|
|
|
{
|
|
|
if (obj != null)
|
|
@@ -545,36 +555,44 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
case "AlignLeft":
|
|
|
PDFViewer.SetPDFEditAligment(AlignModes.AlignLeft);
|
|
|
break;
|
|
|
+
|
|
|
case "AlignHorizonCenter":
|
|
|
PDFViewer.SetPDFEditAligment(AlignModes.AlignHorizonCenter);
|
|
|
break;
|
|
|
+
|
|
|
case "AlignRight":
|
|
|
PDFViewer.SetPDFEditAligment(AlignModes.AlignRight);
|
|
|
break;
|
|
|
+
|
|
|
case "DistributeHorizontal":
|
|
|
PDFViewer.SetPDFEditAligment(AlignModes.DistributeHorizontal);
|
|
|
break;
|
|
|
+
|
|
|
case "AlignTop":
|
|
|
PDFViewer.SetPDFEditAligment(AlignModes.AlignTop);
|
|
|
break;
|
|
|
+
|
|
|
case "AlignVerticalCenter":
|
|
|
PDFViewer.SetPDFEditAligment(AlignModes.AlignVerticalCenter);
|
|
|
break;
|
|
|
+
|
|
|
case "AlignBottom":
|
|
|
PDFViewer.SetPDFEditAligment(AlignModes.AlignBottom);
|
|
|
break;
|
|
|
+
|
|
|
case "DistributeVertical":
|
|
|
PDFViewer.SetPDFEditAligment(AlignModes.DistributeVertical);
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
- #endregion
|
|
|
+
|
|
|
+ #endregion 布局处理
|
|
|
+
|
|
|
protected List<PDFEditEvent> TextEditEventList;
|
|
|
+
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
|
{
|
|
|
-
|
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
|
navigationContext.Parameters.TryGetValue<List<PDFEditEvent>>(ParameterNames.AnnotEvent, out TextEditEventList);
|
|
|
navigationContext.Parameters.TryGetValue<TextEditToolContentViewModel>(ParameterNames.TextEditToolContentViewModel, out TextEditToolContentViewModel);
|
|
@@ -598,14 +616,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
|
|
|
private void PDFViewer_LostFocus(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
-
|
|
|
TextEditEvent.ClipImage = false;
|
|
|
TextEditEvent.CancelClip();
|
|
|
TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
IsCrop = false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//获取图片参数
|
|
|
private void LoadedPDFEdit()
|
|
|
{
|
|
@@ -643,9 +659,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
#region 右键菜单
|
|
|
+
|
|
|
//点击空白处时
|
|
|
private ContextMenu EmptyStateMenu(object sender)
|
|
|
{
|
|
@@ -660,6 +675,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
|
|
|
return popMenu;
|
|
|
}
|
|
|
+
|
|
|
//选中图像时
|
|
|
private ContextMenu SelectImgPDFEdit(object sender)
|
|
|
{
|
|
@@ -697,6 +713,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
customMenu.SetMenuBinding(2, RestoreCropCommand);
|
|
|
return popMenu;
|
|
|
}
|
|
|
+
|
|
|
//多选图片右键
|
|
|
private ContextMenu SelectMoreImage(object sender)
|
|
|
{
|
|
@@ -713,17 +730,16 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
//导出
|
|
|
customMenu.SetMenuBinding(4, ExportImgCommand);
|
|
|
|
|
|
-
|
|
|
return popMenu;
|
|
|
- }
|
|
|
- #endregion
|
|
|
+ }
|
|
|
|
|
|
+ #endregion 右键菜单
|
|
|
|
|
|
//左键点击逻辑
|
|
|
private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
|
|
|
{
|
|
|
//退出编辑模式
|
|
|
- IsCrop = false;
|
|
|
+ IsCrop = false;
|
|
|
TextEditEvent.ClipImage = false;
|
|
|
TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
}
|
|
@@ -731,7 +747,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
//右键逻辑
|
|
|
private void PDFViewer_PDFEditCommandHandler(object sender, PDFEditCommand e)
|
|
|
{
|
|
|
-
|
|
|
if (e == null)
|
|
|
return;
|
|
|
|
|
@@ -748,21 +763,19 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
// {
|
|
|
// e.PopupMenu = SelectImgPDFEdit(sender);
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
//}
|
|
|
- //else
|
|
|
+ //else
|
|
|
if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)
|
|
|
{
|
|
|
e.PopupMenu = EmptyStateMenu(sender);
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
e.DoCommand();
|
|
|
break;
|
|
|
-
|
|
|
}
|
|
|
if (e.PopupMenu != null)
|
|
|
{
|
|
@@ -796,17 +809,15 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
CurrentImg = bitmapSource;
|
|
|
events.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
|
|
|
|
|
|
+ public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
|
+ { return true; }
|
|
|
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
{
|
|
@@ -820,4 +831,4 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
PDFViewer.LostFocus -= PDFViewer_LostFocus;
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|