Prechádzať zdrojové kódy

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

lvle 1 rok pred
rodič
commit
b7dd6cb1b7

BIN
PDF Office/ComDocumentAIKit.dll


BIN
PDF Office/ComPDFKit.Viewer.dll


BIN
PDF Office/ComPDFKit_Conversion.dll


+ 5 - 5
PDF Office/Helper/ConverterHelper.cs

@@ -230,7 +230,7 @@ namespace PDF_Master.Helper
             return result;
         }
 
-        public static void ImageMagickPDFToImage(string imageType, string filePath, string outputFolder, string outputFileName, ref string FileName)
+        public static void ImageMagickPDFToImage(string imageType, string filePath, string outputFolder, string outputFileName, ref string FileName,double density=150)
         {
             FileName = CommonHelper.CreateFolder(outputFolder + "\\" + outputFileName);
             ZipFile.ExtractToDirectory(filePath, FileName);
@@ -254,6 +254,8 @@ namespace PDF_Master.Helper
                     {
                         //Save frame as jpg
                         //image.Format = MagickFormat.Jp2;
+                        //水平垂直DPI
+                        image.Density = new Density(density);
                         image.Write(file.Remove(file.LastIndexOf(".png"), 4) + imageType);
                     }
                     // 删除该文件
@@ -266,7 +268,6 @@ namespace PDF_Master.Helper
                 var settings = new QuantizeSettings();
                 settings.Colors = 256;
                 images.Quantize(settings);
-
                 // Optionally optimize the images (images should have the same size).
                 images.Optimize();
 
@@ -351,7 +352,7 @@ namespace PDF_Master.Helper
                     string saveName = Guid.NewGuid().ToString();
                     string savePath = Path.Combine(folderPath, saveName);
                     result = await Task.Run(() => imgConverter.Convert(folderPath, ref saveName, imgOptions, pageArray, ref error, getProgress));
-                    ImageMagickPDFToImage(imageType, saveName, outputFolder, outputFileName, ref FileName);
+                    ImageMagickPDFToImage(imageType, saveName, outputFolder, outputFileName, ref FileName, imgOptions.ImageDpi);
                     DirectoryInfo di = new DirectoryInfo(folderPath);
                     di.Delete(true);
                 }
@@ -538,11 +539,10 @@ namespace PDF_Master.Helper
                     {
                         word = new Microsoft.Office.Interop.Word.Application();
                     }
-                    Microsoft.Office.Interop.Word.Document document = null;
 
                     word.Visible = false;
                     word.ShowWindowsInTaskbar = true;
-                    document = word.Documents.Open(sourcepath, OpenAndRepair: true);
+                    Microsoft.Office.Interop.Word.Document document = word.Documents.Open(sourcepath);
                     var page = document.PageSetup;
                     page.PaperSize = paperSize;
                     if (margin > 0)

+ 24 - 2
PDF Office/Model/Dialog/ConverterDialogs/ConverterDialogsModel.cs

@@ -10,6 +10,8 @@ using Microsoft.Office.Interop.Word;
 using PDF_Master.Helper;
 using PDF_Master.CustomControl;
 using System.Net.Mime;
+using System.Threading;
+using System.Windows.Threading;
 
 namespace PDF_Master.Model.Dialog.ConverterDialogs
 {
@@ -26,7 +28,7 @@ namespace PDF_Master.Model.Dialog.ConverterDialogs
         public ImgType ImageType = ImgType.PNG;
         public uint ImageDpi = 150;
         public bool IsMergeCsv = false;
-        public LayoutOptions LayoutOpts= LayoutOptions.RetainPageLayout;
+        public LayoutOptions LayoutOpts = LayoutOptions.RetainPageLayout;
     }
 
     public class ConverterDialogsModel
@@ -79,12 +81,32 @@ namespace PDF_Master.Model.Dialog.ConverterDialogs
         /// </summary>
         public ConvertOptions Options = new ConvertOptions();
 
+        /// <summary>
+        /// 取消进度条
+        /// </summary>
+        private async void  TaskMethod()
+        {
+            await System.Threading.Tasks.Task.Run(() =>
+            {
+                for (int i = 1; App.mainWindowViewModel.IsProcessVisible != System.Windows.Visibility.Collapsed; i++)
+                {
+                    try
+                    {
+                        Thread.Sleep(500 + i * 500);
+                        if (i < App.mainWindowViewModel.MaxValue)
+                            App.mainWindowViewModel.Value = i;
+                    }
+                    catch { }
+                }
+            });
+        }
+
         private void ConverterClear()
         {
             ConverterHelper.Clear(ConvertType);
             App.mainWindowViewModel.ProcessCloseBtnVisible = System.Windows.Visibility.Collapsed;
             App.mainWindowViewModel.ProgressTitle = "Canceling";
-            App.mainWindowViewModel.Value = App.mainWindowViewModel.MaxValue / 3;
+            TaskMethod();
             //App.mainWindowViewModel.ProgressTitle = "";
             //App.mainWindowViewModel.IsProcessVisible = System.Windows.Visibility.Collapsed;
         }

+ 4 - 2
PDF Office/ViewModels/Dialog/ToolsDialogs/MergeDialogViewModel.cs

@@ -271,7 +271,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
                         {
                             MessageBoxEx.Show("图片格式有问题");
                         }
-                        result = SaveDoc.InsertPage(0, img.Width, img.Height, tempFileName);
+                        // 之前插入位置为零点导致插入为第一页,改为尾插 2023/5/24
+                        result = SaveDoc.InsertPage(SaveDoc.PageCount, img.Width, img.Height, tempFileName);
                         try { if (File.Exists(tempFileName)) File.Delete(tempFileName); }
                         catch
                         { }
@@ -296,7 +297,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
                             frame.CopyPixels(imageData, frame.PixelWidth * 4, 0);
                         }
                         frame.CopyPixels(imageData, frame.PixelWidth * 4, 0);
-                        result = SaveDoc.InsertPage(0, frame.PixelWidth, frame.PixelHeight, imageData, CPDFDocumentImageMode.CPDFDocumentImageModeScaleToFill);
+                        // 之前插入位置为零点导致插入为第一页,改为尾插 2023/5/24
+                        result = SaveDoc.InsertPage(SaveDoc.PageCount, frame.PixelWidth, frame.PixelHeight, imageData, CPDFDocumentImageMode.CPDFDocumentImageModeScaleToFill);
                         if (!result)
                         {
                             SaveDoc.Release();

+ 1 - 1
PDF Office/ViewModels/MainContentViewModel.cs

@@ -551,7 +551,7 @@ namespace PDF_Master.ViewModels
                 }
                 else
                 {
-                    alertsMessage.ShowDialog("", App.MainPageLoader.GetString("Create PDF failed"), App.ServiceLoader.GetString("Text_ok"));
+                    alertsMessage.ShowDialog("", App.MainPageLoader.GetString("CreateFileFailedWarning"), App.ServiceLoader.GetString("Text_ok"));
                 }
                 return false;
             }

+ 1 - 1
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -1257,7 +1257,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                 if (!int.TryParse(text.Trim(), out pageNum))
                 {
                     ShowPageNumTip = Visibility.Visible;
-                    PageNumTipText = " 错误格式,仅支持数字";
+                    PageNumTipText = " This field only accepts numbers";
                     return false;
                 }
             }

+ 3 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Properties.cs

@@ -230,6 +230,9 @@ namespace PDF_Master.ViewModels.Tools
         //判断注释是否在拖拉创建中
         public bool IsCreateAnnot = false;
 
+        //判断是否选中图片
+        public bool IsSelectImage=false;
+
         public string PropertyRegionName { get; set; }
         private IEventAggregator events;
         public IDialogService dialogs;

+ 8 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -1995,9 +1995,16 @@ namespace PDF_Master.ViewModels.Tools
             if (e.Key == Key.Escape)
             {
                 if (PropertyPanel != null)
-                    PropertyPanel.IsAddLink = false;
+                {
+                    PropertyPanel.IsAddLink = false;
+                }
                 if (PDFViewer != null)
                 {
+                    if (PDFViewer.GetSelectImageCount() > 0)
+                    {
+                        IsSelectImage=true;
+                        PDFViewer.ClearImage();
+                    }
                     if (PDFViewer.MouseMode == MouseModes.AnnotCreate)
                     {
                         if (PDFViewer.ToolManager != null && PDFViewer.ToolManager.CurrentAnnotArgs != null)

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

@@ -825,6 +825,8 @@ namespace PDF_Master.ViewModels
         public DelegateCommand ZoomInCommand { get; set; }
 
         public DelegateCommand ZoomOutCommand { get; set; }
+        
+        //是否显示视图面板
         public bool IsReadModeShow { get; internal set; } = false;
 
         #endregion 命令
@@ -2365,6 +2367,7 @@ namespace PDF_Master.ViewModels
                         }
                         else
                         {
+                            //如果注释是在拖拉创建中 或者 选中 了图片 不退出阅读模式
                             if (toolContentViewModel != null)
                             {
                                 if (toolContentViewModel.IsCreateAnnot)
@@ -2372,6 +2375,11 @@ namespace PDF_Master.ViewModels
                                     isunannotTool = false;
                                     toolContentViewModel.IsCreateAnnot = false;
                                 }
+                                if(toolContentViewModel.IsSelectImage)
+                                {
+                                    isunannotTool = false;
+                                    toolContentViewModel.IsSelectImage = false;
+                                }
                             }
                         }
                     }

+ 12 - 11
PDF Office/Views/ViewContent.xaml

@@ -277,8 +277,8 @@
                                     Header="Image" />
                             </MenuItem>
                             <MenuItem Command="{Binding MergeFileCommand}" Header="Merge PDF Files" />
-                            
-                              <!--暂时隐藏,V1.2.0上线前确认后删除  
+
+                            <!--暂时隐藏,V1.2.0上线前确认后删除
                             <Separator Margin="8,0" Style="{StaticResource HorizontalSeparatorStyle}" />
                             <MenuItem
                                 Command="{Binding CloseWindowCommand}"
@@ -290,7 +290,7 @@
                                 InputGestureText="Ctrl+W" />-->
                             <Separator Margin="8,0" Style="{StaticResource HorizontalSeparatorStyle}" />
                             <!--<MenuItem Command="{Binding ShowInFolderCommand}" Header="Show in Folder" />-->
-                            
+
                             <MenuItem Command="{Binding PropertyCommand}" Header="Properties" />
                             <Separator Margin="8,0" Style="{StaticResource HorizontalSeparatorStyle}" />
                             <MenuItem Command="{Binding ShareCommand}" Header="Share" />
@@ -343,6 +343,7 @@
                 </Button>
                 <Button
                     Name="BtnMore"
+                    Margin="2,0"
                     Click="BtnMore_Click"
                     Initialized="BtnMore_Initialized"
                     Style="{StaticResource subToolBar}">
@@ -503,6 +504,14 @@
                         Style="{StaticResource ToolbarTabs}">
                         <Grid Grid.Row="1" Height="40" />
                     </cus:IconAndTextTabItem>
+                    <cus:IconAndTextTabItem
+                        x:Name="TabItemEdit"
+                        Height="40"
+                        Header="编辑"
+                        Style="{StaticResource ToolbarTabs}"
+                        Visibility="Visible">
+                        <Grid Grid.Row="1" Height="40" />
+                    </cus:IconAndTextTabItem>
                     <cus:IconAndTextTabItem
                         x:Name="TabItemPageEdit"
                         Header="{Binding T_PageEdit}"
@@ -518,14 +527,6 @@
                         Visibility="Collapsed">
                         <Grid Grid.Row="1" Height="40" />
                     </cus:IconAndTextTabItem>
-                    <cus:IconAndTextTabItem
-                        x:Name="TabItemEdit"
-                        Height="40"
-                        Header="编辑"
-                        Style="{StaticResource ToolbarTabs}"
-                        Visibility="Visible">
-                        <Grid Grid.Row="1" Height="40" />
-                    </cus:IconAndTextTabItem>
                     <cus:IconAndTextTabItem
                         x:Name="TabItemForm"
                         Height="40"

BIN
PDF Office/x64/CPDFConverterNative.dll


BIN
PDF Office/x64/ComDocumentAINative.dll


BIN
PDF Office/x64/DocumentAI.dll


BIN
PDF Office/x64/onnxruntime.dll


BIN
PDF Office/x64/opencv_world420.dll


BIN
PDF Office/x64/paddle2onnx.dll


BIN
PDF Office/x86/CPDFConverterNative.dll