|
@@ -23,6 +23,7 @@ using PDF_Office.Views;
|
|
|
using Prism.Events;
|
|
|
using PDF_Office.EventAggregators;
|
|
|
using PDF_Office.Views.EditTools.Background;
|
|
|
+using PDF_Office.Views.PageEdit;
|
|
|
|
|
|
namespace PDF_Office.ViewModels
|
|
|
{
|
|
@@ -30,7 +31,7 @@ namespace PDF_Office.ViewModels
|
|
|
{
|
|
|
#region 属性、变量
|
|
|
|
|
|
- private CPDFViewer PDFViewer { get; set; }
|
|
|
+ public CPDFViewer PDFViewer { get; set; }
|
|
|
|
|
|
private MainContentViewModel mainViewModel { get; set; }
|
|
|
|
|
@@ -60,25 +61,50 @@ namespace PDF_Office.ViewModels
|
|
|
public string BottomToolRegionName { get; set; }
|
|
|
|
|
|
private bool _isInPageEdit = false;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 是否处于页面编辑模式,用于执行undo redo 的具体操作
|
|
|
/// </summary>
|
|
|
public bool isInPageEdit
|
|
|
{
|
|
|
get { return _isInPageEdit; }
|
|
|
- set { _isInPageEdit = value;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _isInPageEdit = value;
|
|
|
if (!value)
|
|
|
{
|
|
|
CanRedo = PDFViewer.UndoManager.CanRedo;
|
|
|
CanUndo = PDFViewer.UndoManager.CanUndo;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public Action PageEditUndo { get; set; }
|
|
|
|
|
|
public Action PageEditRedo { get; set; }
|
|
|
|
|
|
+ private Visibility readModeContentVisibility = Visibility.Collapsed;
|
|
|
+
|
|
|
+ public Visibility ReadModeContentVisibility
|
|
|
+ {
|
|
|
+ get { return readModeContentVisibility; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref readModeContentVisibility, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Visibility rectangleReadModeVisibility = Visibility.Collapsed;
|
|
|
+
|
|
|
+ public Visibility RectangleReadModeVisibility
|
|
|
+ {
|
|
|
+ get { return rectangleReadModeVisibility; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref rectangleReadModeVisibility, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
///工具条
|
|
|
///0:收起
|
|
@@ -467,6 +493,7 @@ namespace PDF_Office.ViewModels
|
|
|
case "BackgroundContent":
|
|
|
ToolContentVisible = Visibility.Visible;
|
|
|
break;
|
|
|
+
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -625,31 +652,31 @@ namespace PDF_Office.ViewModels
|
|
|
{
|
|
|
//在构造函数中使用Region需要借助Dispatcher 确保UI已经加载完成,加载BOTA区域
|
|
|
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
|
|
- {
|
|
|
- NavigationParameters parameters = new NavigationParameters();
|
|
|
- parameters.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
|
- parameters.Add(ParameterNames.ViewContentViewModel, this);
|
|
|
-
|
|
|
- region.RequestNavigate(BOTARegionName, "BOTAContent", parameters);
|
|
|
- region.RequestNavigate(BottomToolRegionName, "BottomToolContent", parameters);
|
|
|
- region.RequestNavigate(ReadModeRegionName, "ReadModeContent", parameters);
|
|
|
-
|
|
|
- //TODO 根据上一次关闭记录的菜单,选中TabItem
|
|
|
- EnterSelectedBar("TabItemAnnotation");
|
|
|
- }
|
|
|
- ));
|
|
|
+ {
|
|
|
+ NavigationParameters parameters = new NavigationParameters();
|
|
|
+ parameters.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
|
+ parameters.Add(ParameterNames.ViewContentViewModel, this);
|
|
|
+
|
|
|
+ region.RequestNavigate(BOTARegionName, "BOTAContent", parameters);
|
|
|
+ region.RequestNavigate(BottomToolRegionName, "BottomToolContent", parameters);
|
|
|
+ region.RequestNavigate(ReadModeRegionName, "ReadModeContent", parameters);
|
|
|
+
|
|
|
+ //TODO 根据上一次关闭记录的菜单,选中TabItem
|
|
|
+ EnterSelectedBar("TabItemAnnotation");
|
|
|
+ }
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
public void SelectedPrpoertyPanel(string Content, AnnotPropertyPanel annotPropertyPanel)
|
|
|
{
|
|
|
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
|
|
- {
|
|
|
- NavigationParameters parameters = new NavigationParameters();
|
|
|
- parameters.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
|
- parameters.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
|
|
|
- region.RequestNavigate(PropertyRegionName, Content, parameters);
|
|
|
- }
|
|
|
- ));
|
|
|
+ {
|
|
|
+ NavigationParameters parameters = new NavigationParameters();
|
|
|
+ parameters.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
|
+ parameters.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
|
|
|
+ region.RequestNavigate(PropertyRegionName, Content, parameters);
|
|
|
+ }
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -714,48 +741,48 @@ namespace PDF_Office.ViewModels
|
|
|
{
|
|
|
PDFViewer.UndoManager.CanSave = false;
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
|
- {
|
|
|
- //TODO:更新缩略图
|
|
|
- //OpenFileInfo info = SettingHelper.GetFileInfo(PdfViewer.Document.FilePath);
|
|
|
- //try
|
|
|
- //{
|
|
|
- // if (!string.IsNullOrEmpty(info.ThumbImgPath) && !PdfViewer.Document.IsEncrypted)//加密的文档不获取缩略图
|
|
|
- // {
|
|
|
- // var size = PdfViewer.Document.GetPageSize(0);
|
|
|
- // System.Drawing.Bitmap bitmap = ToolMethod.RenderPageBitmapNoWait(PdfViewer.Document, (int)size.Width, (int)size.Height, 0, true, true);
|
|
|
- // string folderPath = System.IO.Path.Combine(App.CurrentPath, "CoverImage");
|
|
|
- // if (File.Exists(folderPath))
|
|
|
- // File.Delete(folderPath);
|
|
|
- // DirectoryInfo folder = new DirectoryInfo(folderPath);
|
|
|
- // if (!folder.Exists)
|
|
|
- // folder.Create();
|
|
|
- // string imagePath = info.ThumbImgPath;
|
|
|
- // if (!File.Exists(imagePath))//由加密文档变为非加密文档时 新建一个路径
|
|
|
- // {
|
|
|
- // string imageName = Guid.NewGuid().ToString();
|
|
|
- // imagePath = System.IO.Path.Combine(folderPath, imageName);
|
|
|
- // using (FileStream stream = new FileStream(imagePath, FileMode.Create))
|
|
|
- // {
|
|
|
- // bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // using (FileStream stream = new FileStream(imagePath, FileMode.Open))
|
|
|
- // {
|
|
|
- // bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // info.ThumbImgPath = imagePath;
|
|
|
- // SettingHelper.SetFileInfo(info);
|
|
|
- // }
|
|
|
- //}
|
|
|
- //catch
|
|
|
- //{
|
|
|
- // info.ThumbImgPath = null;
|
|
|
- // SettingHelper.SetFileInfo(info);
|
|
|
- //}
|
|
|
- });
|
|
|
+ {
|
|
|
+ //TODO:更新缩略图
|
|
|
+ //OpenFileInfo info = SettingHelper.GetFileInfo(PdfViewer.Document.FilePath);
|
|
|
+ //try
|
|
|
+ //{
|
|
|
+ // if (!string.IsNullOrEmpty(info.ThumbImgPath) && !PdfViewer.Document.IsEncrypted)//加密的文档不获取缩略图
|
|
|
+ // {
|
|
|
+ // var size = PdfViewer.Document.GetPageSize(0);
|
|
|
+ // System.Drawing.Bitmap bitmap = ToolMethod.RenderPageBitmapNoWait(PdfViewer.Document, (int)size.Width, (int)size.Height, 0, true, true);
|
|
|
+ // string folderPath = System.IO.Path.Combine(App.CurrentPath, "CoverImage");
|
|
|
+ // if (File.Exists(folderPath))
|
|
|
+ // File.Delete(folderPath);
|
|
|
+ // DirectoryInfo folder = new DirectoryInfo(folderPath);
|
|
|
+ // if (!folder.Exists)
|
|
|
+ // folder.Create();
|
|
|
+ // string imagePath = info.ThumbImgPath;
|
|
|
+ // if (!File.Exists(imagePath))//由加密文档变为非加密文档时 新建一个路径
|
|
|
+ // {
|
|
|
+ // string imageName = Guid.NewGuid().ToString();
|
|
|
+ // imagePath = System.IO.Path.Combine(folderPath, imageName);
|
|
|
+ // using (FileStream stream = new FileStream(imagePath, FileMode.Create))
|
|
|
+ // {
|
|
|
+ // bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // using (FileStream stream = new FileStream(imagePath, FileMode.Open))
|
|
|
+ // {
|
|
|
+ // bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // info.ThumbImgPath = imagePath;
|
|
|
+ // SettingHelper.SetFileInfo(info);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //catch
|
|
|
+ //{
|
|
|
+ // info.ThumbImgPath = null;
|
|
|
+ // SettingHelper.SetFileInfo(info);
|
|
|
+ //}
|
|
|
+ });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -800,7 +827,7 @@ namespace PDF_Office.ViewModels
|
|
|
//提示文件被其他软件占用 无法保存
|
|
|
//MessageBoxEx.Show(App.MainPageLoader.GetString("Main_TheFileOccupiedWarning"), "", Winform.MessageBoxButtons.OKCancel, new string[] { App.MainPageLoader.GetString("Main_SaveAs"), App.MainPageLoader.GetString("Main_Cancel") })
|
|
|
}
|
|
|
- ;
|
|
|
+ ;
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -968,6 +995,89 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public async void RbtnReadMode(ViewContent viewContent)
|
|
|
+ {
|
|
|
+ App.IsBookMode = true;
|
|
|
+ ReadModeContentVisibility = Visibility.Visible;
|
|
|
+ RectangleReadModeVisibility = Visibility.Collapsed;
|
|
|
+ IsLoading = Visibility.Visible;
|
|
|
+ await Task.Delay(1);
|
|
|
+
|
|
|
+ //region.AddToRegion(ToolContentRegionName, PDFViewer);
|
|
|
+
|
|
|
+ //if (region.Regions.ContainsRegionWithName(ToolContentRegionName))
|
|
|
+ //{
|
|
|
+ // if (!region.Regions[ToolContentRegionName].Views.Contains(PDFViewer))
|
|
|
+ // {
|
|
|
+ // region.AddToRegion(ToolContentRegionName, PDFViewer);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // var contentRegion = region.Regions[ToolContentRegionName];
|
|
|
+ // contentRegion.Remove(PDFViewer);
|
|
|
+ // //if (region.Regions[ToolContentRegionName].Views.Contains(PageEditContent))
|
|
|
+ // //{
|
|
|
+ // // contentRegion.Remove(PageEditContent);
|
|
|
+ // //}
|
|
|
+
|
|
|
+ // region.AddToRegion(ToolContentRegionName, PDFViewer);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ NavigationParameters param = new NavigationParameters();
|
|
|
+ param.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
|
+ param.Add(ParameterNames.ViewContentViewModel, this);
|
|
|
+ region.RequestNavigate(ToolContentRegionName, "ReadViewContent", param);
|
|
|
+
|
|
|
+ //ShowContent(CurrentBar, true);
|
|
|
+ if (GridToolRow != 0)
|
|
|
+ {
|
|
|
+ GridToolRow = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (GridToolRowSpan != 4)
|
|
|
+ {
|
|
|
+ GridToolRowSpan = 4;
|
|
|
+ }
|
|
|
+ //isInPageEdit = true;
|
|
|
+ UpdateShowContent("TabItemPageEdit");
|
|
|
+ IsLoading = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async void UnReadModel()
|
|
|
+ {
|
|
|
+ App.IsBookMode = false;
|
|
|
+ ReadModeContentVisibility = Visibility.Collapsed;
|
|
|
+ RectangleReadModeVisibility = Visibility.Collapsed;
|
|
|
+ IsLoading = Visibility.Visible;
|
|
|
+ await Task.Delay(1);
|
|
|
+ //region.AddToRegion(ViwerRegionName, PDFViewer);
|
|
|
+
|
|
|
+ if (region.Regions.ContainsRegionWithName(ViwerRegionName))
|
|
|
+ {
|
|
|
+ if (region.Regions[ViwerRegionName].Views.Contains(PDFViewer))
|
|
|
+ {
|
|
|
+ var contentRegion = region.Regions[ViwerRegionName];
|
|
|
+ contentRegion.Remove(PDFViewer);
|
|
|
+ }
|
|
|
+ region.AddToRegion(ViwerRegionName, PDFViewer);
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(CurrentBar) || CurrentBar.Equals("TabItemPageEdit", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ EnterSelectedBar("TabItemAnnotation");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ EnterSelectedBar(CurrentBar);
|
|
|
+ }
|
|
|
+
|
|
|
+ //isInPageEdit = false;
|
|
|
+ //ShowContent(CurrentBar, false);
|
|
|
+ //isInPageEdit = false;
|
|
|
+
|
|
|
+ IsLoading = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+
|
|
|
#endregion 方法
|
|
|
}
|
|
|
}
|