|
@@ -21,6 +21,8 @@ using Prism.Ioc;
|
|
|
using PDF_Office.CustomControl;
|
|
|
using Prism.Services.Dialogs;
|
|
|
using PDF_Office.Properties;
|
|
|
+using PDF_Office.Helper;
|
|
|
+using PDFSettings.Settings;
|
|
|
|
|
|
namespace PDF_Office.ViewModels
|
|
|
{
|
|
@@ -31,12 +33,13 @@ namespace PDF_Office.ViewModels
|
|
|
public MainContent SelectedItem
|
|
|
{
|
|
|
get { return selectedItem; }
|
|
|
- set {
|
|
|
+ set
|
|
|
+ {
|
|
|
SetProperty(ref selectedItem, value);
|
|
|
- if (SelectedItem!=null)
|
|
|
+ if (SelectedItem != null)
|
|
|
{
|
|
|
var pdfviewer = (SelectedItem.DataContext as MainContentViewModel).PDFViewer;
|
|
|
- if(pdfviewer!=null)
|
|
|
+ if (pdfviewer != null)
|
|
|
{
|
|
|
CurrentPDFViewer = pdfviewer;
|
|
|
}
|
|
@@ -48,8 +51,8 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private string progresstitle;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 进度控件标题
|
|
|
/// </summary>
|
|
@@ -62,9 +65,8 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
private double processvalue = 0;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 进度条当前值
|
|
|
/// </summary>
|
|
@@ -78,6 +80,7 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
|
|
|
private double maxValue = 100;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 进度条最大值
|
|
|
/// </summary>
|
|
@@ -90,9 +93,9 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private Visibility _RegisterVis = Visibility.Collapsed;
|
|
|
- public Visibility RegisterVis
|
|
|
+
|
|
|
+ public Visibility RegisterVis
|
|
|
{
|
|
|
get { return _RegisterVis; }
|
|
|
set
|
|
@@ -102,6 +105,7 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
|
|
|
private Visibility _LoginVis = Visibility.Collapsed;
|
|
|
+
|
|
|
public Visibility LoginVis
|
|
|
{
|
|
|
get { return _LoginVis; }
|
|
@@ -111,9 +115,8 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
private Visibility _UserVis = Visibility.Collapsed;
|
|
|
+
|
|
|
public Visibility UserVis
|
|
|
{
|
|
|
get { return _UserVis; }
|
|
@@ -123,10 +126,8 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
private Visibility isProcessVisible = Visibility.Collapsed;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// OCR进度条是否显示
|
|
|
/// </summary>
|
|
@@ -157,10 +158,6 @@ namespace PDF_Office.ViewModels
|
|
|
|
|
|
public DelegateCommand CloseAllTabCommand { get; set; }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
private CPDFViewer pdfViewer;
|
|
|
|
|
|
/// <summary>
|
|
@@ -178,12 +175,12 @@ namespace PDF_Office.ViewModels
|
|
|
/// 关闭OCR进度条
|
|
|
/// </summary>
|
|
|
public DelegateCommand CloseOCRCommand { get; set; }
|
|
|
+
|
|
|
public DelegateCommand OpenRegisterCommand { get; set; }
|
|
|
public DelegateCommand OpenLoginCommand { get; set; }
|
|
|
public DelegateCommand OpenUserCommand { get; set; }
|
|
|
public DelegateCommand LoadCommand { get; set; }
|
|
|
|
|
|
-
|
|
|
public IRegionManager region;
|
|
|
|
|
|
public IEventAggregator eventer;
|
|
@@ -191,11 +188,9 @@ namespace PDF_Office.ViewModels
|
|
|
public IDialogService dialogs;
|
|
|
|
|
|
private IContainerProvider containerProvider;
|
|
|
-
|
|
|
|
|
|
public IInterTabClient InterTabClient { get; }
|
|
|
|
|
|
-
|
|
|
public MainWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IContainerProvider container, IDialogService dialogService)
|
|
|
{
|
|
|
if (App.mainWindowViewModel == null)
|
|
@@ -218,11 +213,7 @@ namespace PDF_Office.ViewModels
|
|
|
OpenRegisterCommand = new DelegateCommand(OpenRegister);
|
|
|
OpenLoginCommand = new DelegateCommand(OpenLogin);
|
|
|
OpenUserCommand = new DelegateCommand(OpenUser);
|
|
|
- CloseAllTabCommand = new DelegateCommand(()=> { closeAllTabItem(); });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ CloseAllTabCommand = new DelegateCommand(() => { closeAllTabItem(); });
|
|
|
|
|
|
//第一次打开时需要自动加载Home页
|
|
|
if (App.IsFirstOpen)
|
|
@@ -242,33 +233,22 @@ namespace PDF_Office.ViewModels
|
|
|
{
|
|
|
RegisterVis = Visibility.Visible;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//打开注册弹窗
|
|
|
private void OpenRegister()
|
|
|
{
|
|
|
-
|
|
|
dialogs.ShowDialog(DialogNames.RegisterDialog, new DialogParameters(), r =>
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//打开登录弹窗
|
|
|
private void OpenLogin()
|
|
|
{
|
|
|
dialogs.ShowDialog(DialogNames.LoginDialog, new DialogParameters(""), r =>
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -277,15 +257,15 @@ namespace PDF_Office.ViewModels
|
|
|
{
|
|
|
dialogs.ShowDialog(DialogNames.UserDialog, new DialogParameters(""), r =>
|
|
|
{
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 关闭OCR
|
|
|
/// </summary>
|
|
|
private void closeocr()
|
|
|
{
|
|
|
- if(ProcessCloseAction!=null)
|
|
|
+ if (ProcessCloseAction != null)
|
|
|
{
|
|
|
ProcessCloseAction.Invoke();
|
|
|
}
|
|
@@ -314,7 +294,6 @@ namespace PDF_Office.ViewModels
|
|
|
CheckViewsCount();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 关闭所有页签
|
|
|
/// </summary>
|
|
@@ -322,7 +301,7 @@ namespace PDF_Office.ViewModels
|
|
|
{
|
|
|
while (region.Regions[RegionNames.MainRegion].Views.Count() > 0)
|
|
|
{
|
|
|
- if (CurrentPDFViewer!=null&&CurrentPDFViewer.UndoManager.CanSave)
|
|
|
+ if (CurrentPDFViewer != null && CurrentPDFViewer.UndoManager.CanSave)
|
|
|
{
|
|
|
ContentResult result = ShowSaveDialog((SelectedItem.DataContext as MainContentViewModel).viewContentViewModel);
|
|
|
if (result == ContentResult.Cancel)
|
|
@@ -336,7 +315,7 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
|
|
|
//多窗体情况下,单个窗体的所有页签均已关闭时,返回true,允许关闭窗体
|
|
|
- if(selectedItem==null)
|
|
|
+ if (selectedItem == null)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
@@ -353,7 +332,7 @@ namespace PDF_Office.ViewModels
|
|
|
{
|
|
|
SelectItem(maincontentViewModel.PDFViewer.Document.FilePath);
|
|
|
}
|
|
|
- if (maincontentViewModel.PDFViewer != null &&maincontentViewModel.PDFViewer.UndoManager.CanSave)
|
|
|
+ if (maincontentViewModel.PDFViewer != null && maincontentViewModel.PDFViewer.UndoManager.CanSave)
|
|
|
{
|
|
|
ContentResult result = ShowSaveDialog(maincontentViewModel.viewContentViewModel);
|
|
|
if (result == ContentResult.Cancel)
|
|
@@ -365,7 +344,6 @@ namespace PDF_Office.ViewModels
|
|
|
{
|
|
|
maincontentViewModel.PDFViewer.CloseDocument();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
if (region.Regions[RegionNames.MainRegion].Views.Count() > 1)
|
|
|
{
|
|
@@ -374,7 +352,6 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
if (maincontentViewModel.PDFViewer != null)
|
|
|
{
|
|
|
//如果是打开文档的页签 则回到首页
|
|
@@ -389,7 +366,6 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
}
|
|
|
return;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -397,7 +373,7 @@ namespace PDF_Office.ViewModels
|
|
|
/// </summary>
|
|
|
private void CheckViewsCount()
|
|
|
{
|
|
|
- if(region.Regions[RegionNames.MainRegion].Views.Count()>1)
|
|
|
+ if (region.Regions[RegionNames.MainRegion].Views.Count() > 1)
|
|
|
{
|
|
|
IsCloseAllEnable = true;
|
|
|
}
|
|
@@ -415,7 +391,7 @@ namespace PDF_Office.ViewModels
|
|
|
|
|
|
region.Regions[RegionNames.MainRegion].Activate(item);
|
|
|
var behavior = region.Regions[RegionNames.MainRegion].Behaviors[DragablzWindowBehavior.BehaviorKey] as DragablzWindowBehavior;
|
|
|
- if(behavior!=null)
|
|
|
+ if (behavior != null)
|
|
|
{
|
|
|
behavior.ActivateView(item);
|
|
|
}
|
|
@@ -429,7 +405,7 @@ namespace PDF_Office.ViewModels
|
|
|
private ContentResult ShowSaveDialog(ViewContentViewModel viewContentViewModel)
|
|
|
{
|
|
|
AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
- alertsMessage.ShowDialog("关闭提示","当前文档有为保存的操作,是否需要保存?","Cancel","No","Ok");
|
|
|
+ alertsMessage.ShowDialog("关闭提示", "当前文档有为保存的操作,是否需要保存?", "Cancel", "No", "Ok");
|
|
|
var result = alertsMessage.result;
|
|
|
|
|
|
if (result == ContentResult.Ok)
|
|
@@ -441,4 +417,4 @@ namespace PDF_Office.ViewModels
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|