|
@@ -883,7 +883,7 @@ namespace PDF_Master.ViewModels
|
|
|
dialogs = dialogService;
|
|
|
events = eventAggregator;
|
|
|
unicode = App.mainWindowViewModel.SelectedItem.Unicode;
|
|
|
- Load = new DelegateCommand(()=> { LoadControl(); });
|
|
|
+ Load = new DelegateCommand(() => { LoadControl(); });
|
|
|
MouseDown = new DelegateCommand(MouseDownEvent);
|
|
|
SaveFile = new DelegateCommand(() => { saveFile(); }, CanSaveExcute).ObservesProperty(() => CanSave);
|
|
|
SaveAsFlattenCommand = new DelegateCommand(saveAsFlatten);
|
|
@@ -2020,9 +2020,9 @@ namespace PDF_Master.ViewModels
|
|
|
if (PDFViewer != null)
|
|
|
{
|
|
|
//防止部分情况PDFViewer.CurrentIndex获取异常问题
|
|
|
- if (PDFViewer.Document.PageCount > 0)
|
|
|
- {
|
|
|
- events.GetEvent<PageEditSelectedItemEvent>().Publish(new PageEditSelectedItemEventArgs() { Unicode = unicode, SelectedItemIndex = PDFViewer.CurrentIndex });
|
|
|
+ if (PDFViewer.Document.PageCount > 0)
|
|
|
+ {
|
|
|
+ events.GetEvent<PageEditSelectedItemEvent>().Publish(new PageEditSelectedItemEventArgs() { Unicode = unicode, SelectedItemIndex = PDFViewer.CurrentIndex, IsSingle = true });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2040,7 +2040,7 @@ namespace PDF_Master.ViewModels
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
- #endregion part1
|
|
|
+ #endregion 方案一,比较耗时,需要遍历
|
|
|
|
|
|
break;
|
|
|
|
|
@@ -2060,7 +2060,7 @@ namespace PDF_Master.ViewModels
|
|
|
//缩略图选中页面,要和当前显示的页面,一致
|
|
|
if (PDFViewer != null)
|
|
|
{
|
|
|
- events.GetEvent<PageEditSelectedItemEvent>().Publish(new PageEditSelectedItemEventArgs() { Unicode = unicode, SelectedItemIndex = PDFViewer.CurrentIndex });
|
|
|
+ events.GetEvent<PageEditSelectedItemEvent>().Publish(new PageEditSelectedItemEventArgs() { Unicode = unicode, SelectedItemIndex = PDFViewer.CurrentIndex, IsSingle = true });
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -2758,7 +2758,7 @@ namespace PDF_Master.ViewModels
|
|
|
//是否取消了水印保存步骤
|
|
|
bool flg = false;
|
|
|
//删掉Settings.Default.UserDate.isInFreeUseTime == false,没有试用期策略了
|
|
|
- if ((!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1) && (App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).IsUsedVIP== true)
|
|
|
+ if ((!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1) && (App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).IsUsedVIP == true)
|
|
|
{
|
|
|
DialogParameters value = new DialogParameters();
|
|
|
value.Add(ParameterNames.ViewContentViewModel, this);
|
|
@@ -2766,15 +2766,14 @@ namespace PDF_Master.ViewModels
|
|
|
{
|
|
|
if (dialogResult.Result == ButtonResult.OK)
|
|
|
{
|
|
|
- flg = true;
|
|
|
+ flg = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- flg= false;
|
|
|
+ flg = false;
|
|
|
}
|
|
|
});
|
|
|
- return flg;
|
|
|
-
|
|
|
+ return flg;
|
|
|
}
|
|
|
|
|
|
if ((string.IsNullOrEmpty(PDFViewer.Document.FilePath) || mainViewModel.NewFile) && !autosave)
|
|
@@ -3022,17 +3021,16 @@ namespace PDF_Master.ViewModels
|
|
|
/// <summary>
|
|
|
/// 另存为或新文档保存逻辑
|
|
|
/// </summary>
|
|
|
- public bool saveAsFile(Action RedactionAction = null, String IsFormSave=null)
|
|
|
+ public bool saveAsFile(Action RedactionAction = null, String IsFormSave = null)
|
|
|
{
|
|
|
//是否来自savefile方法
|
|
|
- if(IsFormSave=="FormSave")
|
|
|
+ if (IsFormSave == "FormSave")
|
|
|
{
|
|
|
var dlg = new Microsoft.Win32.SaveFileDialog();
|
|
|
dlg.Filter = Properties.Resources.OpenDialogFilter;
|
|
|
dlg.FileName = PDFViewer.Document.FileName;
|
|
|
if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
|
|
|
{
|
|
|
-
|
|
|
bool result = false;
|
|
|
if (RedactionAction != null)
|
|
|
{
|
|
@@ -3065,49 +3063,45 @@ namespace PDF_Master.ViewModels
|
|
|
}
|
|
|
|
|
|
PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
|
|
|
- Uri resourceUri = new Uri("pack://application:,,,/PDF Master;component/Resources/Service/Warermark.png");
|
|
|
- StreamResourceInfo resourceInfo = Application.GetResourceStream(resourceUri);
|
|
|
- if (resourceInfo != null)
|
|
|
+ Uri resourceUri = new Uri("pack://application:,,,/PDF Master;component/Resources/Service/Warermark.png");
|
|
|
+ StreamResourceInfo resourceInfo = Application.GetResourceStream(resourceUri);
|
|
|
+ if (resourceInfo != null)
|
|
|
+ {
|
|
|
+ using (Stream stream = resourceInfo.Stream)
|
|
|
{
|
|
|
- using (Stream stream = resourceInfo.Stream)
|
|
|
+ BitmapFrame frame = null;
|
|
|
+ int width = 0;
|
|
|
+ int height = 0;
|
|
|
+ BitmapDecoder decoder = BitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.Default);
|
|
|
+ if (decoder != null && decoder.Frames.Count > 0)
|
|
|
{
|
|
|
- BitmapFrame frame = null;
|
|
|
- int width = 0;
|
|
|
- int height = 0;
|
|
|
- BitmapDecoder decoder = BitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.Default);
|
|
|
- if (decoder != null && decoder.Frames.Count > 0)
|
|
|
- {
|
|
|
- frame = decoder.Frames[0];
|
|
|
- }
|
|
|
- if (frame != null)
|
|
|
- {
|
|
|
- var ImageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
|
|
|
- width = frame.PixelWidth;
|
|
|
- height = frame.PixelHeight;
|
|
|
- frame.CopyPixels(ImageArray, frame.PixelWidth * 4, 0);
|
|
|
- watermark = PDFViewer.Document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
|
|
|
- watermark.SetImage(ImageArray, width, height);
|
|
|
- watermark.SetScale(1);
|
|
|
- watermark.SetRotation(0);
|
|
|
- watermark.SetOpacity(255);
|
|
|
- watermark.SetFront(true);
|
|
|
- watermark.SetVertalign(C_Watermark_Vertalign.WATERMARK_VERTALIGN_TOP);
|
|
|
- watermark.SetHorizalign(C_Watermark_Horizalign.WATERMARK_HORIZALIGN_LEFT);
|
|
|
- watermark.SetFullScreen(false);
|
|
|
- watermark.SetVertOffset(0);
|
|
|
- watermark.SetHorizOffset(0);
|
|
|
- watermark.SetHorizontalSpacing(0);
|
|
|
- watermark.SetVerticalSpacing(0);
|
|
|
- string setpages = $"0-{PDFViewer.Document.PageCount.ToString()}";
|
|
|
- watermark.SetPages(setpages);
|
|
|
- watermark.UpdateWatermark();
|
|
|
- PDFViewer.Document.ReleasePages();
|
|
|
- PDFViewer.ReloadDocument();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ frame = decoder.Frames[0];
|
|
|
+ }
|
|
|
+ if (frame != null)
|
|
|
+ {
|
|
|
+ var ImageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
|
|
|
+ width = frame.PixelWidth;
|
|
|
+ height = frame.PixelHeight;
|
|
|
+ frame.CopyPixels(ImageArray, frame.PixelWidth * 4, 0);
|
|
|
+ watermark = PDFViewer.Document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
|
|
|
+ watermark.SetImage(ImageArray, width, height);
|
|
|
+ watermark.SetScale(1);
|
|
|
+ watermark.SetRotation(0);
|
|
|
+ watermark.SetOpacity(255);
|
|
|
+ watermark.SetFront(true);
|
|
|
+ watermark.SetVertalign(C_Watermark_Vertalign.WATERMARK_VERTALIGN_TOP);
|
|
|
+ watermark.SetHorizalign(C_Watermark_Horizalign.WATERMARK_HORIZALIGN_LEFT);
|
|
|
+ watermark.SetFullScreen(false);
|
|
|
+ watermark.SetVertOffset(0);
|
|
|
+ watermark.SetHorizOffset(0);
|
|
|
+ watermark.SetHorizontalSpacing(0);
|
|
|
+ watermark.SetVerticalSpacing(0);
|
|
|
+ string setpages = $"0-{PDFViewer.Document.PageCount.ToString()}";
|
|
|
+ watermark.SetPages(setpages);
|
|
|
+ watermark.UpdateWatermark();
|
|
|
+ PDFViewer.Document.ReleasePages();
|
|
|
+ PDFViewer.ReloadDocument();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -3132,7 +3126,6 @@ namespace PDF_Master.ViewModels
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
bool flg = false;
|
|
|
//删掉Settings.Default.UserDate.isInFreeUseTime == false,没有试用期策略了
|
|
|
if ((!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1) && (App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).IsUsedVIP == true)
|
|
@@ -3156,7 +3149,7 @@ namespace PDF_Master.ViewModels
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
var dlg = new Microsoft.Win32.SaveFileDialog();
|
|
|
dlg.Filter = Properties.Resources.OpenDialogFilter;
|
|
|
dlg.FileName = PDFViewer.Document.FileName;
|
|
@@ -3195,7 +3188,7 @@ namespace PDF_Master.ViewModels
|
|
|
|
|
|
PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
|
|
|
//是否需要加水印
|
|
|
- if(flg==true)
|
|
|
+ if (flg == true)
|
|
|
{
|
|
|
Uri resourceUri = new Uri("pack://application:,,,/PDF Master;component/Resources/Service/Warermark.png");
|
|
|
StreamResourceInfo resourceInfo = Application.GetResourceStream(resourceUri);
|
|
@@ -3235,15 +3228,10 @@ namespace PDF_Master.ViewModels
|
|
|
watermark.UpdateWatermark();
|
|
|
PDFViewer.Document.ReleasePages();
|
|
|
PDFViewer.ReloadDocument();
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
result = PDFViewer.Document.WriteToFilePath(dlg.FileName);
|
|
|
if (result)
|
|
@@ -3263,9 +3251,7 @@ namespace PDF_Master.ViewModels
|
|
|
}
|
|
|
else
|
|
|
return false;
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/// <summary>
|