Browse Source

综合-完善一次打开多个文件问题

ZhouJieSheng 2 years ago
parent
commit
ff1ecc5785

+ 10 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/CreateFromHtmlDialogViewModel.cs

@@ -78,7 +78,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
         public CreateFromHtmlDialogViewModel()
         {
             OpenFileCommnad = new DelegateCommand(openFile);
-            CreateCommand = new DelegateCommand(createFile);
+            CreateCommand = new DelegateCommand(createFile,CanExcuteCreateFile).ObservesProperty(()=> FilePath);
             CancelCommand = new DelegateCommand(cancel);
             InitPageSize();
         }
@@ -133,6 +133,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             RequestClose.Invoke(new DialogResult(ButtonResult.OK,valuePairs));
         }
 
+        /// <summary>
+        /// 是否可以创建
+        /// </summary>
+        /// <returns></returns>
+        private bool CanExcuteCreateFile()
+        {
+            return !string.IsNullOrEmpty(FilePath);
+        }
+
         private void cancel()
         {
             RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));

+ 7 - 3
PDF Office/ViewModels/HomeContentViewModel.cs

@@ -120,7 +120,10 @@ namespace PDF_Office.ViewModels
             {
                 var fileList = dialog.FileNames.ToList().Where(x => !App.OpenedFileList.Exists(y => y == x)).ToList();
                 if (fileList.Count <= 0)
+                {
+                    IsLoading = Visibility.Collapsed;
                     return;
+                }
 
                 IsLoading = Visibility.Visible;
                 //在当前页签打开第一个文件
@@ -138,7 +141,6 @@ namespace PDF_Office.ViewModels
                 {
                     if (!App.OpenedFileList.Contains(fileList[i]))
                     {
-                        //需要加一定延时 不然连续添加多个文件时会出现regionname重名的情况 因为多处导航是异步导航,可能绑定还没更新
                         App.mainWindowViewModel.AddTabItem(fileList[i]);
                     }
                     ToolMethod.SetFileThumbImg(fileList[i]);
@@ -199,15 +201,17 @@ namespace PDF_Office.ViewModels
                 {
                     var fileList = openFileDialog.FileNames.ToList().Where(x => !App.OpenedFileList.Exists(y => y == x)).ToList();
                     if (fileList.Count <= 0)
+                    {
+                        App.mainWindowViewModel.SelectItem(openFileDialog.FileName);
+                        IsLoading = Visibility.Collapsed;
                         return;
+                    }
 
                     mainContentViewModel.OpenFile(fileList[0]);
                     for (int i = 1; i < fileList.Count(); i++)
                     {
                         if (!App.OpenedFileList.Contains(fileList[i]))
                         {
-                            //需要加一定延时 不然连续添加多个文件时会出现regionname重名的情况 因为多处导航是异步导航,可能绑定还没更新
-                            await Task.Delay(20);
                             App.mainWindowViewModel.AddTabItem(fileList[i]);
                         }
                         ToolMethod.SetFileThumbImg(fileList[i]);

+ 4 - 2
PDF Office/ViewModels/PropertyPanel/ViewModular/SplitScreenContentViewModel.cs

@@ -98,8 +98,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.ViewModular
         {
             region = regionManager;
             dialogs = dialogService;
-            SplitViewRegionName = RegionNames.SplitViewRegionName;
-            SplitScreenPageRegionName = RegionNames.SplitScreenPageRegionName;
+            //该区域名称 其他地方不需要调用,为减少一次打开多个文件的处理内容
+            //改为随机字符串,不计入RegionNames字典里
+            SplitViewRegionName = Guid.NewGuid().ToString();
+            SplitScreenPageRegionName = Guid.NewGuid().ToString();
             SelectedFiles = new ObservableCollection<string>();
             //dicSelectedFiles = new Dictionary<string, string>();
 

+ 0 - 1
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -1002,7 +1002,6 @@ namespace PDF_Office.ViewModels
             region.RequestNavigate(BottomToolRegionName, "BottomToolContent", parameters);
             region.RequestNavigate(ReadModeRegionName, "ReadModeContent", parameters);
             region.RequestNavigate(SplitViewerRegionName, "SplitScreenContent", parameters);
-            //region.RequestNavigate(TipContentRegionName, "LinkAnnotTip", parameters);
             //TODO 根据上一次关闭记录的菜单,选中TabItem
             EnterSelectedBar("TabItemAnnotation");
                   //}

+ 1 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/CreateFromHtmlDialog.xaml

@@ -43,7 +43,7 @@
             </Grid>
             <TextBlock
                 Height="20"
-                Margin="0,18,0,0"
+                Margin="0,10,0,0"
                 Text="Page Configuration" />
             <StackPanel Margin="0,8" Orientation="Horizontal">
                 <TextBlock

+ 2 - 2
PDF Office/Views/PropertyPanel/ViewModular/ViewModularContent.xaml

@@ -338,12 +338,12 @@
                         </StackPanel>
                     </RadioButton>
                 </StackPanel>
-                <ContentControl
+                <!--<ContentControl
                     x:Name="SplitScreenViewContent"
                     Grid.Row="1"
                     VerticalAlignment="Stretch"
                     prism:RegionManager.RegionName="{Binding SplitScreenViewRegionName}"
-                    Visibility="{Binding SplitScreenViewVisible}" />
+                    Visibility="{Binding SplitScreenViewVisible}" />-->
             </Grid>
             <TextBlock
                 Name="txtRotate"