|
@@ -30,7 +30,7 @@ namespace PDF_Master.ViewModels
|
|
|
public class MainWindowViewModel : BindableBase
|
|
|
{
|
|
|
private MainContent selectedItem;
|
|
|
- private LoginDialogViewModel LoginDialogViewModel ;
|
|
|
+ private LoginDialogViewModel LoginDialogViewModel;
|
|
|
|
|
|
#region 文案
|
|
|
|
|
@@ -60,7 +60,7 @@ namespace PDF_Master.ViewModels
|
|
|
{
|
|
|
|
|
|
Msgtologin = App.ServiceLoader.GetString("Msgtologin");
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -298,7 +298,9 @@ namespace PDF_Master.ViewModels
|
|
|
OpenRegisterCommand = new DelegateCommand(OpenRegister);
|
|
|
OpenLoginCommand = new DelegateCommand(OpenLogin);
|
|
|
OpenUserCommand = new DelegateCommand(OpenUser);
|
|
|
- CloseAllTabCommand = new DelegateCommand(() => { if (closeAllTabItem())
|
|
|
+ CloseAllTabCommand = new DelegateCommand(() =>
|
|
|
+ {
|
|
|
+ if (closeAllTabItem())
|
|
|
{
|
|
|
App.Current.MainWindow.Close();
|
|
|
}
|
|
@@ -328,7 +330,7 @@ namespace PDF_Master.ViewModels
|
|
|
else
|
|
|
{
|
|
|
//如果有拖拽文件到图标或者设为默认阅读器的情况,双击文件打开软件时,不加载首页
|
|
|
- if ((App.Current.MainWindow as MainWindow)!=null&&(App.Current.MainWindow as MainWindow).TabablzControl.Items.Count <= 0)
|
|
|
+ if ((App.Current.MainWindow as MainWindow) != null && (App.Current.MainWindow as MainWindow).TabablzControl.Items.Count <= 0)
|
|
|
{
|
|
|
region.RequestNavigate(RegionNames.MainRegion, "MainContent");
|
|
|
}
|
|
@@ -369,14 +371,14 @@ namespace PDF_Master.ViewModels
|
|
|
|
|
|
if (ServiceHelper.GetUser() == "401")
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
LoginVis = Visibility.Visible;
|
|
|
OphVis = Visibility.Visible;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
App.IsLogin = true;
|
|
|
- Useremailchar= Settings.Default.UserDate.Email.Substring(0, 1);
|
|
|
+ Useremailchar = Settings.Default.UserDate.Email.Substring(0, 1);
|
|
|
UserVis = Visibility.Visible;
|
|
|
}
|
|
|
}
|
|
@@ -395,7 +397,7 @@ namespace PDF_Master.ViewModels
|
|
|
bool result = true;
|
|
|
dialogs.ShowDialog(DialogNames.GuidDialog, null, r =>
|
|
|
{
|
|
|
- if(r.Result == ButtonResult.Ignore)
|
|
|
+ if (r.Result == ButtonResult.Ignore)
|
|
|
{
|
|
|
result = false;
|
|
|
}
|
|
@@ -428,7 +430,7 @@ namespace PDF_Master.ViewModels
|
|
|
if (ServiceHelper.GetUser() == "401")
|
|
|
{
|
|
|
|
|
|
- UserVis = Visibility.Collapsed;
|
|
|
+ UserVis = Visibility.Collapsed;
|
|
|
LoginVis = Visibility.Visible;
|
|
|
OphVis = Visibility.Visible;
|
|
|
OpenLogin();
|
|
@@ -450,7 +452,7 @@ namespace PDF_Master.ViewModels
|
|
|
OphVis = Visibility.Visible;
|
|
|
OpenLogin();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -458,7 +460,7 @@ namespace PDF_Master.ViewModels
|
|
|
/// </summary>
|
|
|
private void closeocr()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
if (ProcessCloseAction != null)
|
|
|
{
|
|
|
ProcessCloseAction.Invoke();
|
|
@@ -538,10 +540,10 @@ namespace PDF_Master.ViewModels
|
|
|
/// 设置value值小于MaxValue值时 自动显示
|
|
|
/// Value值 大于等于MaxValue值时,自动隐藏
|
|
|
/// </summary>
|
|
|
- public async void SetProcessValue(string title,double value,double maxvalue,bool showClose = true)
|
|
|
+ public async void SetProcessValue(string title, double value, double maxvalue, bool showClose = true)
|
|
|
{
|
|
|
ProgressTitle = title;
|
|
|
- if(value<0)
|
|
|
+ if (value < 0)
|
|
|
{
|
|
|
//异常处理
|
|
|
this.Value = 0;
|
|
@@ -553,11 +555,11 @@ namespace PDF_Master.ViewModels
|
|
|
this.MaxValue = 0;
|
|
|
}
|
|
|
|
|
|
- if(value<maxvalue)
|
|
|
+ if (value < maxvalue)
|
|
|
{
|
|
|
this.Value = value;
|
|
|
this.MaxValue = maxvalue;
|
|
|
- if(IsProcessVisible!=Visibility.Visible)
|
|
|
+ if (IsProcessVisible != Visibility.Visible)
|
|
|
{
|
|
|
IsProcessVisible = Visibility.Visible;
|
|
|
}
|
|
@@ -580,49 +582,51 @@ namespace PDF_Master.ViewModels
|
|
|
//获取x号所在的maincontentviewmodel对象
|
|
|
var maincontentViewModel = (item as MainContent).DataContext as MainContentViewModel;
|
|
|
//如果已经有打开文档,先切换到目标页签
|
|
|
- if (maincontentViewModel.PDFViewer != null)
|
|
|
+ if (maincontentViewModel.PDFViewer != null && maincontentViewModel.PDFViewer.Document != null)
|
|
|
{
|
|
|
SelectItem(maincontentViewModel.PDFViewer.Document.FilePath);
|
|
|
}
|
|
|
+
|
|
|
+ //可以保存时,弹窗询问提示弹窗
|
|
|
if (maincontentViewModel.PDFViewer != null && maincontentViewModel.PDFViewer.UndoManager.CanSave)
|
|
|
{
|
|
|
ContentResult result = ShowSaveDialog(maincontentViewModel.viewContentViewModel);
|
|
|
//此处要加上第二个判断,如果去除第二个判断,则新建文件后,点击关闭按钮,不选择保存路径时,无法关闭页签
|
|
|
- if (result == ContentResult.Cancel&& !Settings.Default.AppProperties.Description.NotShowSaveWhenClose)
|
|
|
+ if (result == ContentResult.Cancel && !Settings.Default.AppProperties.Description.NotShowSaveWhenClose)
|
|
|
{
|
|
|
//非自动保存且取消了另存为时
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //不要保存 可以直接关闭页签时
|
|
|
+ //这里不能加Else 需要分开写If 否则会出现无法关闭页签的情况
|
|
|
+ //不要保存 可以直接关闭页签时(有多个页签时)
|
|
|
if (region.Regions[RegionNames.MainRegion].Views.Count() > 1)
|
|
|
{
|
|
|
region.Regions[RegionNames.MainRegion].Remove(item);
|
|
|
CheckViewsCount();
|
|
|
|
|
|
//关闭子窗体的最后一个页签时,子窗体关闭(不显示首页),参考福昕逻辑
|
|
|
- if ((App.Current.MainWindow as MainWindow).TabablzControl.Items.Count==0)
|
|
|
+ if ((App.Current.MainWindow as MainWindow).TabablzControl.Items.Count == 0)
|
|
|
{
|
|
|
App.Current.MainWindow.Close();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ //只剩一个页签的情况
|
|
|
if (maincontentViewModel.PDFViewer != null)
|
|
|
{
|
|
|
- //如果是关闭文档的页签 则回到首页
|
|
|
+ // 如果是关闭文档的页签 则回到首页
|
|
|
region.Regions[RegionNames.MainRegion].Remove(item);
|
|
|
region.RequestNavigate(RegionNames.MainRegion, "MainContent");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //如果是关闭首页则关闭软件
|
|
|
+ // 如果是关闭首页则关闭软件
|
|
|
region.Regions[RegionNames.MainRegion].Remove(item);
|
|
|
App.Current.MainWindow.Close();
|
|
|
}
|
|
|
}
|
|
|
- return;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -666,7 +670,7 @@ namespace PDF_Master.ViewModels
|
|
|
{
|
|
|
//偏好设置里未设置直接保存时,需要弹窗提示
|
|
|
AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
- alertsMessage.ShowDialog("",string.Format(App.MainPageLoader.GetString("Main_ModifiedFileWarning"),System.IO.Path.GetFileName(CurrentPDFViewer.Document.FilePath)), App.ServiceLoader.GetString("Text_cancel"), App.ServiceLoader.GetString("Text_no"), App.ServiceLoader.GetString("Text_ok"));
|
|
|
+ alertsMessage.ShowDialog("", string.Format(App.MainPageLoader.GetString("Main_ModifiedFileWarning"), System.IO.Path.GetFileName(CurrentPDFViewer.Document.FilePath)), App.ServiceLoader.GetString("Text_cancel"), App.ServiceLoader.GetString("Text_no"), App.ServiceLoader.GetString("Text_ok"));
|
|
|
result = alertsMessage.result;
|
|
|
}
|
|
|
|