Browse Source

compdfkit demo(windows) - 文字搜索用到的宽度转换器移动到公共文件夹

liyuxuan 1 year ago
parent
commit
e78f08915f

+ 40 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/ListViewWidthConvert.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows;
+
+namespace compdfkit_tools.Common
+{
+    internal class ListViewWidthConvert : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (value == null)
+            {
+                return 0;
+            }
+            else
+            {
+                if (value is double)
+                {
+                    double width = (double)value;
+                    width = width - SystemParameters.VerticalScrollBarWidth - 8;
+                    return Math.Max(0, width);
+                }
+                else
+                {
+                    return 0;
+                }
+            }
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 3 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFSearch/PDFSearchUI/CPDFSearchResultUI.xaml

@@ -4,11 +4,12 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:compdfkit_tools.PDFControlUI"
+             xmlns:convert="clr-namespace:compdfkit_tools.Common"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <UserControl.Resources>
         <ResourceDictionary>
-            <local:WidthConvert x:Key="WidthConvert"/>
+            <convert:ListViewWidthConvert x:Key="ListViewWidthConvert"/>
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid>
@@ -43,7 +44,7 @@
                     <StackPanel>
                         <RichTextBox Background="Transparent" Foreground="#000000" FontFamily="Segoe UI" FontSize="14" IsReadOnly="True" BorderThickness="0" 
                                      Padding="12,6,10,6" local:SearchResultBindHelper.DocumentBind="{Binding BindProperty}" 
-                                      Width="{Binding ElementName=ResultListControl,Path=ActualWidth,Converter={StaticResource WidthConvert}}"
+                                      Width="{Binding ElementName=ResultListControl,Path=ActualWidth,Converter={StaticResource ListViewWidthConvert}}"
                                      VerticalContentAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="False" >
                         </RichTextBox>
                     </StackPanel>

+ 0 - 29
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFSearch/PDFSearchUI/CPDFSearchResultUI.xaml.cs

@@ -287,33 +287,4 @@ namespace compdfkit_tools.PDFControlUI
         }
 
     }
-
-    internal class WidthConvert : IValueConverter
-    {
-        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            if (value == null)
-            {
-                return 0;
-            }
-            else
-            {
-                if (value is double)
-                {
-                    double width = (double)value;
-                    width = width - SystemParameters.VerticalScrollBarWidth - 8;
-                    return Math.Max(0, width);
-                }
-                else
-                {
-                    return 0;
-                }
-            }
-        }
-
-        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            throw new NotImplementedException();
-        }
-    }
 }

+ 1 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

@@ -68,6 +68,7 @@
     <Compile Include="Common\Bar\TitleBarControl.xaml.cs">
       <DependentUpon>TitleBarControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Common\Convert\ListViewWidthConvert.cs" />
     <Compile Include="Helper\CommonHelper.cs" />
     <Compile Include="PDFView\PDFDisplaySettings\PDFDisplaySettingsControl\CPDFBrowseModeControl.xaml.cs">
       <DependentUpon>CPDFBrowseModeControl.xaml</DependentUpon>