Sfoglia il codice sorgente

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

OYXH\oyxh 2 anni fa
parent
commit
424d5350c4

+ 1 - 1
PDF Office/App.xaml

@@ -21,7 +21,7 @@
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/WindowsStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/CustomBtnStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ContainerStyles/ComboxStyle/ComboxItemStyle.xaml" />
-
+                <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/RadioButtonStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/PathButtonStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ImageButtonStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/PathRadioButtonDictionary.xaml" />

+ 4 - 7
PDF Office/CustomControl/WritableComboBox.xaml.cs

@@ -109,9 +109,7 @@ namespace PDF_Office.CustomControl
         public List<int> PageIndexList
         {
             get { return (List<int>)GetValue(PageIndexListProperty); }
-            set { 
-                SetValue(PageIndexListProperty, value);
-            }
+            set { SetValue(PageIndexListProperty, value); }
         }
 
         // Using a DependencyProperty as the backing store for PageIndexList.  This enables animation, styling, binding, etc...
@@ -135,11 +133,11 @@ namespace PDF_Office.CustomControl
             int value = Convert.ToInt32(e.NewValue);
             if (value>0)
             {
-                (d as WritableComboBox).t();
+                (d as WritableComboBox).UpDataPagesInRange();
             }
         }
 
-        private void t()
+        private void UpDataPagesInRange()
         {
 
             if ((writableComboBox.SelectedItem as ComboBoxItem).Tag != null)
@@ -210,7 +208,6 @@ namespace PDF_Office.CustomControl
                 }
 
             }
-            SetCurrentValue(PageIndexListProperty, PageIndexList);
         }
         public ItemCollection Items
         {
@@ -382,7 +379,7 @@ namespace PDF_Office.CustomControl
 
         private void UserControl_Loaded(object sender, RoutedEventArgs e)
         {
-            var x = PageIndexList;
+            UpDataPagesInRange();
         }
     }
 }

+ 2 - 2
PDF Office/SDKLisence.xml

@@ -1,6 +1,6 @@
 <Lisences
-	devKey = "sTHSivIW4YnZQavIYDLVw4vaFcN5DQTUtRGrVyv5p9aeaHX3GirG/MBxl6Wy9TJbNOwR4CU6LPjHmGe3Po3OtBCPqIRheam9+LomScw3AvoUTHFlG1134e2J4enF43WJQ6PyOnjwZqsG1kUdlBPNztkoPzDAE2pQKgZWf6V2i34="
-    devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6cfaiHpW8pgW2aur3AxuQIBBLuJD5gcmNxTYW3KA32JLG8alfyXjKFVS3gka9bngvwfZ7GuNXybjKlmz1tnN6iVHpnbSj+xOHhWEperY4HHrSg=="
+	devKey = "BK8BcXWm+YbGRpEONe43pEJXhshAiAwWoBQgwlEUnxFBkCVal4AYW01RnbuwHCdkktvy9sAYs/SUflLR+KOMayg6z2TE2G3OhIXf95sN8k1sk947zrPGeHPtHx7gMaurYrscLDAumvtymhg4rMTg7XFKfBtchlAi0bE+wPTsqa8="
+  devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iYSXB8erGstkUyaynN7k8ocNCYAAzc9CPxiym2TlqeSUWpLOaOv47bs7x+UqfQzn9hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBwyVLBY93oKLBB8UJg4t07605BGbaBKUlDopA0iGq1HSnRAJhqHxGgIZ+m3BxAFwgabp2OdkT7I9klGmA/4KertEmsKlSJ3WFqmDWhwfT73yCYDNQpuarUAQxiS1PJu8kUw=="
 	userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs="
 	userSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4ivEHOmPIqbfhpDnKKj+7Ymj2rXQvfZRmke06HMV+3tt064G64WjPW8+EbGCNZaAh1hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1FKJi6HYB+DuugQyaqI2prfej861QnJrU4s2T/npZK/"
 	ConverterDevKey="ErjZKxcU3SPvUohGZo0CBgy0XdkAsZqUYqCTbfn1AYsCQ6mxCucx61UPqLT7MDQ0n+5/oKnWY9SSk8Xv5pJtYYHD87HRdYNG+QNCaoPGHulyfVxGllmzU71U7WjflfZBFvhg/UQOFiz3OsAVKz4k2YkXPzQgNaS3glym42PVpj4="

+ 35 - 0
PDF Office/Styles/RadioButtonStyle.xaml

@@ -541,4 +541,39 @@
             </Setter.Value>
         </Setter>
     </Style>
+
+    <!--  底部工具栏的RadionButton StateBar  Design Token  -->
+    <Style x:Key="StateBarRbt" TargetType="{x:Type RadioButton}">
+        <Setter Property="Foreground" Value="{StaticResource color.icon.base.neutral.norm.lv1}" />
+        <Setter Property="Background" Value="Transparent" />
+        <Setter Property="FontSize" Value="18" />
+        <Setter Property="Cursor" Value="Hand" />
+        <Setter Property="Margin" Value="0,0,10,10" />
+        <Setter Property="Height" Value="32" />
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type RadioButton}">
+                    <Border
+                        x:Name="fore"
+                        Background="{TemplateBinding Background}"
+                        BorderThickness="0"
+                        CornerRadius="{StaticResource border-radius.4}">
+                        <ContentPresenter
+                            x:Name="content"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            Content="{TemplateBinding Content}" />
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsChecked" Value="true">
+                            <Setter TargetName="fore" Property="Background" Value="{StaticResource color.item-state.sel.bg.lv2}" />
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="True">
+                            <Setter TargetName="fore" Property="Background" Value="{StaticResource color.item-state.hov.bg}" />
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
 </ResourceDictionary>

+ 1 - 1
PDF Office/Styles/ToggleButton.xaml

@@ -29,7 +29,7 @@
                     </Border>
                     <ControlTemplate.Triggers>
                         <Trigger Property="IsMouseOver" Value="True">
-                            <Setter TargetName="border" Property="Panel.Background" Value="{StaticResource color.item-state.sel.bg.lv2}" />
+                            <Setter TargetName="border" Property="Panel.Background" Value="{StaticResource color.item-state.hov.bg}" />
                         </Trigger>
                         <Trigger Property="IsPressed" Value="True">
                             <Setter TargetName="border" Property="Panel.Background" Value="{StaticResource color.item-state.sel.bg.lv2}" />

+ 1 - 21
PDF Office/ViewModels/BottomToolContentViewModel.cs

@@ -189,7 +189,6 @@ namespace PDF_Office.ViewModels
             PageTextKeyDownCommand = new DelegateCommand<object>(PageNumText_KeyDown);
             PageTextPreviewKeyDownCommand = new DelegateCommand<object>(PageNumText_PreviewKeyDown);
             SelectionChangedCommand = new DelegateCommand<object>(SelectionChangedEvent);
-            OpenFullCommand = new DelegateCommand(OpenFullWindow);
             ShowViewModularCommand = new DelegateCommand<object>(ShowViewModularEvent);
         }
 
@@ -211,26 +210,7 @@ namespace PDF_Office.ViewModels
             IsShowViewModular = ViewContentViewModel.IsPropertyOpen;
         }
 
-        /// <summary>
-        /// 进入全屏模式
-        /// </summary>
-        private void OpenFullWindow()
-        {
-            DialogParameters parameters = new DialogParameters();
-            //因为全屏模式可能需要设置特定的页面模式,所以只传文件路径,新建一个PDFview对象
-            parameters.Add(ParameterNames.FilePath, PDFViewer.Document.FilePath);
-            parameters.Add(ParameterNames.PassWord, PDFViewer.Tag == null ? "" : PDFViewer.Tag.ToString());
-            dialogs.ShowDialog(DialogNames.FullScreenDialog, parameters, e =>
-            {
-                if (e.Result == ButtonResult.Cancel)
-                {
-                    //TODO:弹窗提示打开全屏模式失败
-                    AlertsMessage alertsMessage = new AlertsMessage();
-                    alertsMessage.ShowDialog("", "Error", "OK");
-                    return;
-                }
-            });
-        }
+
 
         private void SelectionChangedEvent(object e)
         {

+ 25 - 0
PDF Office/ViewModels/PropertyPanel/ViewModular/ViewModularContentViewModel.cs

@@ -1,6 +1,7 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.PdfViewer;
 using Microsoft.Office.Interop.Word;
+using PDF_Office.CustomControl;
 using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.ViewModels.BOTA;
@@ -129,6 +130,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.ViewModular
 
         public DelegateCommand<object> RotateCommand { get; set; }
 
+        public DelegateCommand OpenFullCommand { get; set; }
+
         public ViewModularContentViewModel(IRegionManager regionManager, IDialogService dialogService)
         {
             region = regionManager;
@@ -145,6 +148,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.ViewModular
             ContinueCommand = new DelegateCommand<object>(ContinueEvent);
             PagesBreakCommand = new DelegateCommand<object>(PagesBreakEvent);
             RotateCommand = new DelegateCommand<object>(RotateEvent);
+            OpenFullCommand = new DelegateCommand(OpenFullWindow);
 
             //在构造函数中使用Region需要借助Dispatcher 确保UI已经加载完成,加载BOTA区域
             System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
@@ -157,6 +161,27 @@ namespace PDF_Office.ViewModels.PropertyPanel.ViewModular
             ));
         }
 
+        /// <summary>
+        /// 进入全屏模式
+        /// </summary>
+        private void OpenFullWindow()
+        {
+            DialogParameters parameters = new DialogParameters();
+            //因为全屏模式可能需要设置特定的页面模式,所以只传文件路径,新建一个PDFview对象
+            parameters.Add(ParameterNames.FilePath, PDFViewer.Document.FilePath);
+            parameters.Add(ParameterNames.PassWord, PDFViewer.Tag == null ? "" : PDFViewer.Tag.ToString());
+            dialogs.ShowDialog(DialogNames.FullScreenDialog, parameters, e =>
+            {
+                if (e.Result == ButtonResult.Cancel)
+                {
+                    //TODO:弹窗提示打开全屏模式失败
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("", "Error", "OK");
+                    return;
+                }
+            });
+        }
+
         /// <summary>
         /// 旋转
         /// </summary>

+ 130 - 116
PDF Office/ViewModels/Scan/ScanViwerViewModel.cs

@@ -18,6 +18,7 @@ using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
+using System.Windows.Threading;
 
 namespace PDF_Office.ViewModels.Scan
 {
@@ -188,43 +189,50 @@ namespace PDF_Office.ViewModels.Scan
             Directory.CreateDirectory(path);
             Directory.CreateDirectory(EnhancePath);
 
-            CIMEngine imEngine = new CIMEngine(App.modelFolderPath);
-            CErrorCode error = imEngine.SetModel();
-            for (int i = 0; i < CurrentDoc.PageCount; i++)
+            Task.Run(() =>
             {
-                string pageImagePath = Path.Combine(path, i.ToString());
-                string pageEnhancePath = Path.Combine(EnhancePath, i.ToString() + ".png");
-                try
+                CIMEngine imEngine = new CIMEngine(App.modelFolderPath);
+                CErrorCode error = imEngine.SetModel();
+                for (int i = 0; i < CurrentDoc.PageCount; i++)
                 {
-                    CPDFPage pdfPage = CurrentDoc.PageAtIndex(i);
-                    float zoom = (float)(DpiHelpers.Dpi / 72D);
-                    int renderWidth = (int)(pdfPage.PageSize.Width * zoom);
-                    int renderHeight = (int)(pdfPage.PageSize.Height * zoom);
-                    byte[] renderData = new byte[renderWidth * renderHeight * 4];
-                    pdfPage.RenderPageBitmapWithMatrix(zoom, new Rect(0, 0, renderWidth, renderHeight), 0xFFFFFFFF, renderData, 0);
-                    WriteableBitmap bitmap = new WriteableBitmap(renderWidth, renderHeight, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
-                    bitmap.WritePixels(new Int32Rect(0, 0, renderWidth, renderHeight), renderData, bitmap.BackBufferStride, 0);
-                    BitmapEncoder encoder = new PngBitmapEncoder();
-                    encoder.Frames.Add(BitmapFrame.Create(bitmap));
-
-                    using (FileStream imageStream = File.Create(pageImagePath))
+                    string pageImagePath = Path.Combine(path, i.ToString());
+                    string pageEnhancePath = Path.Combine(EnhancePath, i.ToString() + ".png");
+                    try
                     {
-                        encoder.Save(imageStream);
-                        imageStream.Flush();
-                    }
+                        CPDFPage pdfPage = CurrentDoc.PageAtIndex(i);
+                        float zoom = (float)(DpiHelpers.Dpi / 72D);
+                        int renderWidth = (int)(pdfPage.PageSize.Width * zoom);
+                        int renderHeight = (int)(pdfPage.PageSize.Height * zoom);
+                        byte[] renderData = new byte[renderWidth * renderHeight * 4];
+                        pdfPage.RenderPageBitmapWithMatrix(zoom, new Rect(0, 0, renderWidth, renderHeight), 0xFFFFFFFF, renderData, 0);
+                        WriteableBitmap bitmap = new WriteableBitmap(renderWidth, renderHeight, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
+                        bitmap.WritePixels(new Int32Rect(0, 0, renderWidth, renderHeight), renderData, bitmap.BackBufferStride, 0);
+                        BitmapEncoder encoder = new PngBitmapEncoder();
+                        encoder.Frames.Add(BitmapFrame.Create(bitmap));
+
+                        using (FileStream imageStream = File.Create(pageImagePath))
+                        {
+                            encoder.Save(imageStream);
+                            imageStream.Flush();
+                        }
 
-                    //File.Create(pageEnhancePath);
-                    error = imEngine.Process(pageImagePath, pageEnhancePath);
-                    EnhancedFilePathList.Add(pageEnhancePath);
-                }
-                catch
-                {
+                        //File.Create(pageEnhancePath);
+                        error = imEngine.Process(pageImagePath, pageEnhancePath);
+                        EnhancedFilePathList.Add(pageEnhancePath);
+                    }
+                    catch
+                    {
 
+                    }
                 }
-            }
 
-            BitmapImage image = new BitmapImage(new Uri(EnhancedFilePathList[PDFViewer.CurrentIndex]));
-            BgImage = new WriteableBitmap(image);
+                Application.Current.Dispatcher.Invoke(() =>
+                {
+                    BitmapImage image = new BitmapImage(new Uri(EnhancedFilePathList[PDFViewer.CurrentIndex]));
+                    BgImage = new WriteableBitmap(image);
+                });
+                imEngine.Release();
+            });
         }
 
         /// <summary>
@@ -233,76 +241,79 @@ namespace PDF_Office.ViewModels.Scan
         /// <param name="args"></param>
         private void OCRProcess(ScanEventArgs args)
         {
-            COCREngine imEngine = new COCREngine(App.modelFolderPath);
-            //CIMEngine imEngine = new CIMEngine(App.modelFolderPath);
+            Task.Run(() =>
+            {
+                COCREngine imEngine = new COCREngine(App.modelFolderPath);
+                //CIMEngine imEngine = new CIMEngine(App.modelFolderPath);
 
-            string path = App.CachePath.MergeFilePath;
-            string name = Guid.NewGuid().ToString();
-            path = Path.Combine(path, name);
+                string path = App.CachePath.MergeFilePath;
+                string name = Guid.NewGuid().ToString();
+                path = Path.Combine(path, name);
 
-            Directory.CreateDirectory(path);
+                Directory.CreateDirectory(path);
 
-            CPDFDocument CurrentDoc = PDFViewer.Document;
+                CPDFDocument CurrentDoc = PDFViewer.Document;
 
-            CErrorCode error = imEngine.SetModel((COCRLanguage)args.ScanLanguage);
+                CErrorCode error = imEngine.SetModel((COCRLanguage)args.ScanLanguage);
 
-            cacahe.Clear();
+                cacahe.Clear();
 
-            for (int i = 0; i < args.PageRange.Count; i++)
-            {
-                string pageImagePath = Path.Combine(path, args.PageRange[i].ToString());
+                for (int i = 0; i < args.PageRange.Count; i++)
+                {
+                    string pageImagePath = Path.Combine(path, args.PageRange[i].ToString());
 
-                CPDFPage pdfPage = CurrentDoc.PageAtIndex(args.PageRange[i]);
-                float zoom = (float)(DpiHelpers.Dpi / 72D);
-                int renderWidth = (int)(pdfPage.PageSize.Width * zoom);
-                int renderHeight = (int)(pdfPage.PageSize.Height * zoom);
-                byte[] renderData = new byte[renderWidth * renderHeight * 4];
-                pdfPage.RenderPageBitmapWithMatrix(zoom, new Rect(0, 0, renderWidth, renderHeight), 0xFFFFFFFF, renderData, 0);
-                WriteableBitmap bitmap = new WriteableBitmap(renderWidth, renderHeight, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
-                bitmap.WritePixels(new Int32Rect(0, 0, renderWidth, renderHeight), renderData, bitmap.BackBufferStride, 0);
-                BitmapEncoder encoder = new PngBitmapEncoder();
-                encoder.Frames.Add(BitmapFrame.Create(bitmap));
+                    CPDFPage pdfPage = CurrentDoc.PageAtIndex(args.PageRange[i]);
+                    float zoom = (float)(DpiHelpers.Dpi / 72D);
+                    int renderWidth = (int)(pdfPage.PageSize.Width * zoom);
+                    int renderHeight = (int)(pdfPage.PageSize.Height * zoom);
+                    byte[] renderData = new byte[renderWidth * renderHeight * 4];
+                    pdfPage.RenderPageBitmapWithMatrix(zoom, new Rect(0, 0, renderWidth, renderHeight), 0xFFFFFFFF, renderData, 0);
+                    WriteableBitmap bitmap = new WriteableBitmap(renderWidth, renderHeight, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
+                    bitmap.WritePixels(new Int32Rect(0, 0, renderWidth, renderHeight), renderData, bitmap.BackBufferStride, 0);
+                    BitmapEncoder encoder = new PngBitmapEncoder();
+                    encoder.Frames.Add(BitmapFrame.Create(bitmap));
 
-                using (FileStream imageStream = File.Create(pageImagePath))
-                {
-                    encoder.Save(imageStream);
-                    imageStream.Flush();
-                }
+                    using (FileStream imageStream = File.Create(pageImagePath))
+                    {
+                        encoder.Save(imageStream);
+                        imageStream.Flush();
+                    }
 
-                error = imEngine.Process(pageImagePath);
+                    error = imEngine.Process(pageImagePath);
 
-                if (imEngine.OCRResultList == null)
-                    return;
+                    if (imEngine.OCRResultList == null)
+                        return;
 
-                List<KeyValuePair<Rect, string>> RectList = new List<KeyValuePair<Rect, string>>();
-                foreach (COCRResult ocrResult in imEngine.OCRResultList)
-                {
-                    List<Point> rectPoints = new List<Point>();
-                    for (int j = 0; j < ocrResult.position.Length; j += 2)
+                    List<KeyValuePair<Rect, string>> RectList = new List<KeyValuePair<Rect, string>>();
+                    foreach (COCRResult ocrResult in imEngine.OCRResultList)
                     {
-                        rectPoints.Add(new Point(ocrResult.position[j], ocrResult.position[j + 1]));
-                    }
-                    int left = (int)rectPoints.AsEnumerable().Min(x => x.X);
-                    int right = (int)rectPoints.AsEnumerable().Max(x => x.X);
-                    int top = (int)rectPoints.AsEnumerable().Min(x => x.Y);
-                    int bottom = (int)rectPoints.AsEnumerable().Max(x => x.Y);
+                        List<Point> rectPoints = new List<Point>();
+                        for (int j = 0; j < ocrResult.position.Length; j += 2)
+                        {
+                            rectPoints.Add(new Point(ocrResult.position[j], ocrResult.position[j + 1]));
+                        }
+                        int left = (int)rectPoints.AsEnumerable().Min(x => x.X);
+                        int right = (int)rectPoints.AsEnumerable().Max(x => x.X);
+                        int top = (int)rectPoints.AsEnumerable().Min(x => x.Y);
+                        int bottom = (int)rectPoints.AsEnumerable().Max(x => x.Y);
 
-                    RectList.Add(new KeyValuePair<Rect, string>(new Rect(left, top, right - left, bottom - top), ocrResult.text));
-                }
-                cacahe.Add(args.PageRange[i], RectList);
-            }
-            if (cacahe.Count > 0)
-            {
-                if (cacahe.ContainsKey(PDFViewer.CurrentIndex))
-                {
-                    TextRectList = cacahe[PDFViewer.CurrentIndex];
+                        RectList.Add(new KeyValuePair<Rect, string>(new Rect(left, top, right - left, bottom - top), ocrResult.text));
+                    }
+                    cacahe.Add(args.PageRange[i], RectList);
                 }
-                else
+                if (cacahe.Count > 0)
                 {
-                    TextRectList = null;
+                    if (cacahe.ContainsKey(PDFViewer.CurrentIndex))
+                    {
+                        TextRectList = cacahe[PDFViewer.CurrentIndex];
+                    }
+                    else
+                    {
+                        TextRectList = null;
+                    }
                 }
-            }
-            imEngine.Release();
+                imEngine.Release();
+            });
         }
 
         /// <summary>
@@ -311,47 +322,50 @@ namespace PDF_Office.ViewModels.Scan
         /// <param name="args"></param>
         private void EnhancedOCRProcess(ScanEventArgs args)
         {
-            COCREngine imEngine = new COCREngine(App.modelFolderPath);
-
-            CErrorCode error = imEngine.SetModel((COCRLanguage)args.ScanLanguage);
-
-            cacahe.Clear();
-            for (int i = 0; i < args.PageRange.Count; i++)
+            Task.Run(() =>
             {
-                error = imEngine.Process(EnhancedFilePathList[i]);
+                COCREngine imEngine = new COCREngine(App.modelFolderPath);
 
-                if (imEngine.OCRResultList == null)
-                    return;
+                CErrorCode error = imEngine.SetModel((COCRLanguage)args.ScanLanguage);
 
-                List<KeyValuePair<Rect, string>> RectList = new List<KeyValuePair<Rect, string>>();
-                foreach (COCRResult ocrResult in imEngine.OCRResultList)
+                cacahe.Clear();
+                for (int i = 0; i < args.PageRange.Count; i++)
                 {
-                    List<Point> rectPoints = new List<Point>();
-                    for (int j = 0; j < ocrResult.position.Length; j += 2)
+                    error = imEngine.Process(EnhancedFilePathList[args.PageRange[i]]);
+
+                    if (imEngine.OCRResultList == null)
+                        return;
+
+                    List<KeyValuePair<Rect, string>> RectList = new List<KeyValuePair<Rect, string>>();
+                    foreach (COCRResult ocrResult in imEngine.OCRResultList)
                     {
-                        rectPoints.Add(new Point(ocrResult.position[j], ocrResult.position[j + 1]));
-                    }
-                    int left = (int)rectPoints.AsEnumerable().Min(x => x.X);
-                    int right = (int)rectPoints.AsEnumerable().Max(x => x.X);
-                    int top = (int)rectPoints.AsEnumerable().Min(x => x.Y);
-                    int bottom = (int)rectPoints.AsEnumerable().Max(x => x.Y);
+                        List<Point> rectPoints = new List<Point>();
+                        for (int j = 0; j < ocrResult.position.Length; j += 2)
+                        {
+                            rectPoints.Add(new Point(ocrResult.position[j], ocrResult.position[j + 1]));
+                        }
+                        int left = (int)rectPoints.AsEnumerable().Min(x => x.X);
+                        int right = (int)rectPoints.AsEnumerable().Max(x => x.X);
+                        int top = (int)rectPoints.AsEnumerable().Min(x => x.Y);
+                        int bottom = (int)rectPoints.AsEnumerable().Max(x => x.Y);
 
-                    RectList.Add(new KeyValuePair<Rect, string>(new Rect(left, top, right - left, bottom - top), ocrResult.text));
-                }
-                cacahe.Add(args.PageRange[i], RectList);
-            }
-            if (cacahe.Count > 0)
-            {
-                if (cacahe.ContainsKey(PDFViewer.CurrentIndex))
-                {
-                    TextRectList = cacahe[PDFViewer.CurrentIndex];
+                        RectList.Add(new KeyValuePair<Rect, string>(new Rect(left, top, right - left, bottom - top), ocrResult.text));
+                    }
+                    cacahe.Add(args.PageRange[i], RectList);
                 }
-                else
+                if (cacahe.Count > 0)
                 {
-                    TextRectList = null;
+                    if (cacahe.ContainsKey(PDFViewer.CurrentIndex))
+                    {
+                        TextRectList = cacahe[PDFViewer.CurrentIndex];
+                    }
+                    else
+                    {
+                        TextRectList = null;
+                    }
                 }
-            }
-            imEngine.Release();
+                imEngine.Release();
+            });
         }
     }
 }

+ 17 - 60
PDF Office/Views/BottomToolContent.xaml

@@ -16,43 +16,7 @@
     BorderBrush="{StaticResource color.sys.layout.divider}"
     BorderThickness="0,1,0,0"
     mc:Ignorable="d">
-    <UserControl.Resources>
-        <Style x:Key="Radion_ButtonStyle" TargetType="{x:Type RadioButton}">
-            <Setter Property="Foreground" Value="Black" />
-            <Setter Property="Background" Value="White" />
-            <Setter Property="FontSize" Value="18" />
-            <Setter Property="Cursor" Value="Hand" />
-            <Setter Property="Margin" Value="0,0,10,10" />
-            <Setter Property="Height" Value="32" />
-            <Setter Property="Template">
-                <Setter.Value>
-                    <ControlTemplate TargetType="{x:Type RadioButton}">
-                        <Border
-                            x:Name="fore"
-                            Background="White"
-                            BorderThickness="0"
-                            CornerRadius="0">
-                            <ContentPresenter
-                                x:Name="content"
-                                HorizontalAlignment="Center"
-                                VerticalAlignment="Center"
-                                Content="{TemplateBinding Content}" />
-                        </Border>
-                        <ControlTemplate.Triggers>
-                            <Trigger Property="IsChecked" Value="true">
-                                <Setter TargetName="fore" Property="Background" Value="#575757" />
-                                <Setter Property="Foreground" Value="White" />
-                            </Trigger>
-                            <Trigger Property="IsMouseOver" Value="True">
-                                <Setter TargetName="fore" Property="Background" Value="#575757" />
-                                <Setter Property="Foreground" Value="White" />
-                            </Trigger>
-                        </ControlTemplate.Triggers>
-                    </ControlTemplate>
-                </Setter.Value>
-            </Setter>
-        </Style>
-    </UserControl.Resources>
+    <UserControl.Resources />
     <Grid Height="32" Background="{StaticResource color.sys.layout.mg}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="*" />
@@ -158,10 +122,11 @@
                 Height="24"
                 Margin="4"
                 Command="{Binding SetViewModeCommand}"
-                IsChecked="{Binding IsContinue}">
+                IsChecked="{Binding IsContinue}"
+                Style="{StaticResource SubToolbarTgb}">
                 <Grid>
-                    <Polygon Fill="Black" Points="2 0 2 6 14 6 14 0 15 0 15 7 1 7 1 0" />
-                    <Path Data="M10.807106,9 L15,13.3928931 L15,16 L14,16 L14,14 L9.999999,14 L9.999,10 L2,10 L2,16 L1,16 L1,9 L10.807106,9 Z M13.237,13 L10.999,10.64 L10.999,13 L13.237,13 Z" Fill="Black" />
+                    <Polygon Fill="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ToggleButton}, Path=Foreground}" Points="2 0 2 6 14 6 14 0 15 0 15 7 1 7 1 0" />
+                    <Path Data="M10.807106,9 L15,13.3928931 L15,16 L14,16 L14,14 L9.999999,14 L9.999,10 L2,10 L2,16 L1,16 L1,9 L10.807106,9 Z M13.237,13 L10.999,10.64 L10.999,13 L13.237,13 Z" Fill="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ToggleButton}, Path=Foreground}" />
                 </Grid>
             </ToggleButton>
             <Separator
@@ -174,8 +139,8 @@
                 Margin="4"
                 Command="{Binding SetViewModeCommand}"
                 IsChecked="{Binding IsSingleView}"
-                Style="{StaticResource Radion_ButtonStyle}">
-                <Path Data="M9.80710597,0 L14,4.39289312 L14,16 L2,16 L2,0 L9.80710597,0 Z M8.999,1 L3,1 L3,15 L13,15 L13,4.999 L8.999999,5 L8.999,1 Z M12.236,3.999 L9.999,1.64 L9.999,4 L12.236,3.999 Z" Fill="Black" />
+                Style="{StaticResource StateBarRbt}">
+                <Path Data="M9.80710597,0 L14,4.39289312 L14,16 L2,16 L2,0 L9.80710597,0 Z M8.999,1 L3,1 L3,15 L13,15 L13,4.999 L8.999999,5 L8.999,1 Z M12.236,3.999 L9.999,1.64 L9.999,4 L12.236,3.999 Z" Fill="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=RadioButton}, Path=Foreground}" />
             </RadioButton>
 
             <RadioButton
@@ -185,8 +150,8 @@
                 Command="{Binding SetViewModeCommand}"
                 Cursor="Hand"
                 IsChecked="{Binding IsDoubleView}"
-                Style="{StaticResource Radion_ButtonStyle}">
-                <Path Data="M0,15 L0,1 L11.807106,1 L16,5.39289312 L16,15 L0,15 Z M7.5,2 L1,2 L1,14 L7.5,14 L7.5,2 Z M10.999,2 L8.5,2 L8.5,14 L15,14 L15,5.999 L10.999999,6 L10.999,2 Z M11.999,2.64 L11.999,5 L14.236,4.999 L11.999,2.64 Z" Fill="Black" />
+                Style="{StaticResource StateBarRbt}">
+                <Path Data="M0,15 L0,1 L11.807106,1 L16,5.39289312 L16,15 L0,15 Z M7.5,2 L1,2 L1,14 L7.5,14 L7.5,2 Z M10.999,2 L8.5,2 L8.5,14 L15,14 L15,5.999 L10.999999,6 L10.999,2 Z M11.999,2.64 L11.999,5 L14.236,4.999 L11.999,2.64 Z" Fill="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=RadioButton}, Path=Foreground}" />
             </RadioButton>
             <RadioButton
                 Width="24"
@@ -194,17 +159,13 @@
                 Margin="4"
                 Command="{Binding SetViewModeCommand}"
                 IsChecked="{Binding IsBookMode}"
-                Style="{StaticResource Radion_ButtonStyle}">
-                <Path Data="M7,11 L7,16 L6,16 L6,12 L1,12 L1,16 L0,16 L0,11 L7,11 Z M16,11 L16,16 L15,16 L15,12 L10,12 L10,16 L9,16 L9,11 L16,11 Z M3.80710597,0 L7,3.39289312 L7,9 L0,9 L0,0 L3.80710597,0 Z M2.999,1 L1,1 L1,8 L6,8 L6,3.999 L2.999999,4 L2.999,1 Z M3.999,1.652 L3.999,3 L5.251,2.999 L3.999,1.652 Z" Fill="Black" />
+                Style="{StaticResource StateBarRbt}">
+                <Path Data="M7,11 L7,16 L6,16 L6,12 L1,12 L1,16 L0,16 L0,11 L7,11 Z M16,11 L16,16 L15,16 L15,12 L10,12 L10,16 L9,16 L9,11 L16,11 Z M3.80710597,0 L7,3.39289312 L7,9 L0,9 L0,0 L3.80710597,0 Z M2.999,1 L1,1 L1,8 L6,8 L6,3.999 L2.999999,4 L2.999,1 Z M3.999,1.652 L3.999,3 L5.251,2.999 L3.999,1.652 Z" Fill="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=RadioButton}, Path=Foreground}" />
             </RadioButton>
             <Separator
                 Width="1"
                 Height="10"
                 Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
-            <Button
-                Width="24"
-                Height="24"
-                Margin="4" />
 
             <ToggleButton
                 Name="TbtnIsViewPanelOpen"
@@ -212,14 +173,17 @@
                 Height="24"
                 Margin="4"
                 Command="{Binding ShowViewModularCommand}"
-                IsChecked="{Binding IsShowViewModular}" />
+                IsChecked="{Binding IsShowViewModular}"
+                Style="{StaticResource SubToolbarTgb}">
+                <Path Data="M1.5 13V3H7.25V13H1.5ZM8.75 13H14.5V3H8.75V13ZM0 2.5C0 1.94772 0.447715 1.5 1 1.5H15C15.5523 1.5 16 1.94772 16 2.5V13.5C16 14.0523 15.5523 14.5 15 14.5H1C0.447715 14.5 0 14.0523 0 13.5V2.5ZM3 6.25H6V7.75H3V6.25ZM6 9.25H3V10.75H6V9.25Z" Fill="{StaticResource color.icon.base.neutral.norm.lv1}" />
+            </ToggleButton>
             <StackPanel
                 Height="16"
                 FocusVisualStyle="{x:Null}"
                 Orientation="Horizontal">
                 <Grid>
                     <ComboBox
-                        Width="52"
+                        Width="72"
                         Background="White"
                         FocusVisualStyle="{x:Null}"
                         MaxDropDownHeight="510"
@@ -313,7 +277,7 @@
                             Tag="1000" />
                     </ComboBox>
                     <TextBlock
-                        Width="31"
+                        Width="45"
                         Height="14"
                         Margin="4,0,0,0"
                         HorizontalAlignment="Left"
@@ -335,13 +299,6 @@
                         Content="-" />
                 </StackPanel>
             </StackPanel>
-            <Button
-                Width="24"
-                Height="24"
-                Margin="4"
-                Command="{Binding OpenFullCommand}">
-                <Path Data="M15,1 L15,6 L14,6 L14,2.706 L2.706,14 L6,14 L6,15 L1,15 L1,10 L2,10 L2,13.292 L13.292,2 L10,2 L10,1 L15,1 Z" Fill="Black" />
-            </Button>
         </StackPanel>
     </Grid>
 </UserControl>

+ 6 - 2
PDF Office/Views/MainWindow.xaml

@@ -15,9 +15,11 @@
     Height="800"
     MinWidth="540"
     MinHeight="460"
+    d:DataContext="{d:DesignInstance Type=viewmodels:MainWindowViewModel}"
     prism:ViewModelLocator.AutoWireViewModel="True"
     Activated="Window_Activated"
     Closed="Window_Closed"
+    SizeChanged="Window_SizeChanged"
     Style="{StaticResource WindowStyle}"
     UseLayoutRounding="True"
     WindowStartupLocation="CenterScreen"
@@ -152,7 +154,8 @@
                 Grid.RowSpan="3"
                 BorderThickness="0"
                 ItemContainerStyle="{StaticResource DragablzItemStyle}"
-                SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
+                SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
+                WindowChrome.IsHitTestVisibleInChrome="True">
                 <dragablz:TabablzControl.InterTabController>
                     <dragablz:InterTabController InterTabClient="{Binding InterTabClient}" />
                 </dragablz:TabablzControl.InterTabController>
@@ -161,7 +164,7 @@
                         x:Name="BtnAdd"
                         Width="20"
                         Height="20"
-                        Margin="9,13,0,7"
+                        Margin="8,13,200,7"
                         Padding="0"
                         HorizontalAlignment="Left"
                         Background="Transparent"
@@ -185,6 +188,7 @@
             </dragablz:TabablzControl>
             <!--  标题栏右侧栏,关闭按钮,会员,试用等  -->
             <StackPanel
+                Name="StkPnlRight"
                 HorizontalAlignment="Right"
                 Orientation="Horizontal"
                 WindowChrome.IsHitTestVisibleInChrome="True">

+ 14 - 2
PDF Office/Views/MainWindow.xaml.cs

@@ -66,12 +66,10 @@ namespace PDF_Office.Views
             if (this.WindowState == WindowState.Maximized)
             {
                 System.Windows.SystemCommands.RestoreWindow(this);
-                ico_max.Visibility = Visibility.Visible;
             }
             else
             {
                 System.Windows.SystemCommands.MaximizeWindow(this);
-                ico_max.Visibility = Visibility.Collapsed;
             }
         }
 
@@ -123,5 +121,19 @@ namespace PDF_Office.Views
             Settings.Default.Save();
         }
 
+        private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
+        {
+            var width = StkPnlRight.ActualWidth;
+            BtnAdd.Margin = new Thickness(8,13,width,7);
+
+            if (this.WindowState == WindowState.Maximized)
+            {
+                ico_max.Visibility = Visibility.Visible;
+            }
+            else
+            {
+                ico_max.Visibility = Visibility.Collapsed;
+            }
+        }
     }
 }

+ 1 - 1
PDF Office/Views/PropertyPanel/Scan/ScanPropertyPanel.xaml

@@ -28,7 +28,7 @@
                 <TextBlock Text="Chinese Traditional"/>
                 <TextBlock Text="French"/>
             </ComboBox>
-            <customcontrol:WritableComboBox x:Name="tt" SelectedIndex="0" MaxPageRange="{Binding PageCount}" PageIndexList="{Binding SetPageRange,Mode=TwoWay}" Loaded="WritableComboBox_Loaded"/>
+            <customcontrol:WritableComboBox SelectedIndex="0" MaxPageRange="{Binding PageCount}" PageIndexList="{Binding SetPageRange,Mode=TwoWay}"/>
             <Button Content="OCR" Command="{Binding OCRCommand}"/>
         </StackPanel>
     </Grid>

+ 1 - 8
PDF Office/Views/PropertyPanel/Scan/ScanPropertyPanel.xaml.cs

@@ -1,5 +1,4 @@
-using PDF_Office.CustomControl;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -25,11 +24,5 @@ namespace PDF_Office.Views.PropertyPanel.Scan
         {
             InitializeComponent();
         }
-
-        private void WritableComboBox_Loaded(object sender, RoutedEventArgs e)
-        {
-            var x=tt.PageIndexList;
-            tt.GetBindingExpression(WritableComboBox.PageIndexListProperty).UpdateSource();
-        }
     }
 }

+ 1 - 0
PDF Office/Views/PropertyPanel/ViewModular/ViewModularContent.xaml

@@ -140,6 +140,7 @@
                 <RadioButton
                     Name="RBtnFullScreen"
                     Margin="4,0,4,0"
+                    Command="{Binding OpenFullCommand}"
                     GroupName="DisplayMode"
                     Style="{StaticResource ViewModeViewRadioBtn}">
                     <StackPanel Margin="0,0,3,0">