Browse Source

compdfkit(win) - 补充homepage 初版

liuaoran 1 year ago
parent
commit
9f2086d5cf

+ 81 - 0
Demo/Examples/Compdfkit_Tools/Common/HomePage/FeaturesListControl.xaml

@@ -0,0 +1,81 @@
+<UserControl x:Class="Compdfkit_Tools.PDFControl.FeaturesListControl"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:Compdfkit_Tools.PDFControl"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800" Background="White"
+             Loaded="UserControl_Loaded">
+    <UserControl.Resources>
+        <Style TargetType="ListBox" x:Key="WrapListBoxStyle">
+            <Setter Property="BorderThickness" Value="0" />
+            <Setter Property="BorderBrush" Value="Transparent" />
+            <Setter Property="Padding" Value="0" />
+        </Style>
+
+      
+
+        <Style x:Key="ItemBorderStyle" TargetType="Border">
+            <Setter Property="Background" Value="#70DDDDDD" />
+            <Setter Property="CornerRadius" Value="5" />
+            <Style.Triggers>
+                <Trigger Property="IsMouseOver" Value="True">
+                    <Setter Property="BorderThickness" Value="0" />
+                    <Setter Property="Background" Value="#DDDDDD" />
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+    </UserControl.Resources>
+    <Grid Margin="60, 50">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition></RowDefinition>
+            <RowDefinition Height="40"></RowDefinition>
+        </Grid.RowDefinitions>
+        <TextBlock Text="Features List" FontFamily="Segoe ui" Foreground="#001A4E" FontSize="24" LineHeight="32" FontWeight="DemiBold"></TextBlock>
+        <Grid Grid.Row="1">
+            <ListBox  x:Name="FeaturesListBox" Style="{StaticResource WrapListBoxStyle}" ItemsSource="{Binding Items}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"  SelectionMode="Single" d:ItemsSource="{d:SampleData ItemCount=5}">
+                <ListBox.ItemContainerStyle>
+                    <Style TargetType="ListBoxItem">
+                        <Setter Property="Margin" Value="10" />
+                        <Setter Property="Template">
+                            <Setter.Value>
+                                <ControlTemplate TargetType="ListBoxItem">
+                                    <ContentPresenter />
+                                </ControlTemplate>
+                            </Setter.Value>
+                        </Setter>
+                    </Style>
+                </ListBox.ItemContainerStyle>
+                <ListBox.ItemsPanel>
+                    <ItemsPanelTemplate>
+                        <WrapPanel Width="{Binding ElementName=WrapListBox, Path=ActualWidth}"></WrapPanel>
+                    </ItemsPanelTemplate>
+                </ListBox.ItemsPanel>
+                <ListBox.ItemTemplate>
+                    <DataTemplate>
+                        <Border  Width="500" Height="128" Style="{StaticResource ItemBorderStyle}">
+                            <Grid Margin="16,20,16,36">
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition Width="33"></ColumnDefinition>
+                                    <ColumnDefinition></ColumnDefinition>
+                                </Grid.ColumnDefinitions>
+                                <Grid Grid.Column="1">
+                                    <Grid.RowDefinitions>
+                                        <RowDefinition></RowDefinition>
+                                        <RowDefinition></RowDefinition>
+                                    </Grid.RowDefinitions>
+                                    <TextBlock FontSize="14"   Foreground="#1a1a1a" FontWeight="Bold" Text="{Binding TitleText}"/>
+                                    <TextBlock Grid.Row="1"  FontSize="12" Foreground="#666666" Text="{Binding DescriptionText}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis"/>
+                                </Grid>
+
+                            </Grid>
+                        </Border>
+                    </DataTemplate>
+                </ListBox.ItemTemplate>
+            </ListBox>
+        </Grid>
+        <Grid Grid.Row="2"></Grid>
+    </Grid>
+</UserControl>

+ 99 - 0
Demo/Examples/Compdfkit_Tools/Common/HomePage/FeaturesListControl.xaml.cs

@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    /// <summary>
+    /// Interaction logic for FeaturesListControl.xaml
+    /// </summary>
+    public partial class FeaturesListControl : UserControl
+    {
+        public event EventHandler<CustomItem> SelectionChanged;
+
+        public static readonly DependencyProperty ItemsProperty =
+           DependencyProperty.Register("Items", typeof(ObservableCollection<CustomItem>), typeof(FeaturesListControl), new PropertyMetadata(null));
+
+        public ObservableCollection<CustomItem> Items
+        {
+            get { return (ObservableCollection<CustomItem>)GetValue(ItemsProperty); }
+            set { SetValue(ItemsProperty, value); }
+        }
+
+        public FeaturesListControl()
+        {
+            this.DataContext = this;
+            InitializeComponent();
+            Items = new ObservableCollection<CustomItem>();
+        }
+
+        private void FeaturesListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var listBox = sender as ListBox;
+            if (listBox != null && listBox.SelectedIndex != -1)
+            {
+                SelectionChanged?.Invoke(sender, Items[listBox.SelectedIndex]);
+                listBox.SelectedIndex = -1;
+            }
+        }
+
+        private void UserControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            FeaturesListBox.SelectionChanged += FeaturesListBox_SelectionChanged;
+        }
+    }
+    public class CustomItem : Control, INotifyPropertyChanged
+    {
+
+        private string _titleText;
+        public string TitleText
+        {
+            get => _titleText;
+            set
+            {
+                UpdateProper(ref _titleText, value);
+            }
+        }
+
+        private string _descriptionText;
+        public string DescriptionText
+        {
+            get => _descriptionText;
+            set
+            {
+                UpdateProper(ref _descriptionText, value);
+            }
+        }
+
+
+        public event PropertyChangedEventHandler PropertyChanged;
+        protected void UpdateProper<T>(ref T properValue,
+                            T newValue,
+                            [CallerMemberName] string properName = "")
+        {
+            if (object.Equals(properValue, newValue))
+                return;
+
+            properValue = newValue;
+            OnPropertyChanged(properName);
+
+        }
+
+        protected void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+    }
+}

+ 23 - 0
Demo/Examples/Compdfkit_Tools/Common/HomePage/HomePageControl.xaml

@@ -0,0 +1,23 @@
+<UserControl x:Class="Compdfkit_Tools.PDFControl.HomePageControl"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:Compdfkit_Tools.PDFControl"
+             mc:Ignorable="d" 
+              d:DesignHeight="1040" d:DesignWidth="1920">
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="260"></ColumnDefinition>
+            <ColumnDefinition></ColumnDefinition>
+        </Grid.ColumnDefinitions>
+        <Grid Grid.Column="1">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="660"></RowDefinition>
+                <RowDefinition></RowDefinition>
+            </Grid.RowDefinitions>
+            <local:FeaturesListControl x:Name="FeaturesListControl"></local:FeaturesListControl>
+            <local:RecentFilesControl Grid.Row="1"></local:RecentFilesControl>
+        </Grid>
+    </Grid>
+</UserControl>

+ 69 - 0
Demo/Examples/Compdfkit_Tools/Common/HomePage/HomePageControl.xaml.cs

@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    /// <summary>
+    /// Interaction logic for HomePageControl.xaml
+    /// </summary>
+    public partial class HomePageControl : UserControl
+    {
+        private List<CustomItem> customItems = new List<CustomItem>()
+        {
+            new CustomItem{TitleText = "Viewer", DescriptionText="View PDFs with tools like display modes, navigation, reading themes, scrolling, zooming, text searching, text reflow, split viewer, etc."},
+            new CustomItem{TitleText="Annotations", DescriptionText="Annotate and markup PDFs with notes, links, texts, line, square, arrow, circle, highlight, underline, squiggly, strikeout, stamps, ink, signature, sound, etc. Allow to create, delete, edit, import, export, and flatten PDF annotations." },
+            new CustomItem{TitleText="Forms", DescriptionText="Create, delete, edit, fill, flatten, import, and export forms. Support a wide array of PDF form fields including text field, check box, radio button, list box, combo button, push button, and signatures."},
+            new CustomItem{TitleText="Signature", DescriptionText="Sign PDFs with digital signatures and electronic signatures. Choose the drawn, image, or typed signatures and sign files conveniently. Or sign with your digital ID securely.\r\n"},
+            new CustomItem{TitleText="Document Editor", DescriptionText="Process PDF pages and files. Add, insert, replace, extract, reverse, move, copy, paste, rotate, delete, crop, scale, etc."},
+            new CustomItem{TitleText="Content Editor", DescriptionText="Edit the text and images with ComPDFKit Content Editor. Give you the freedom to adjust the size, position, style, font, etc.\r\n"},
+            new CustomItem{TitleText="Security", DescriptionText="Secure your documents using AES-128, AES-256, or RC4 encryption and decrypt PDFs. Customize permissions, edit headers & footers, change the background, insert or remove Bates numbers for indexing, etc.\r\n"},
+            new CustomItem{TitleText="Redaction", DescriptionText="Use redaction to remove sensitive images, text, and vector graphics, that can't be recovered after applying the redaction. Support customizing redaction appearance and choosing an area or searching for specific text to redact.\r\n"},
+            new CustomItem{TitleText="Watermark", DescriptionText="Create, insert, and remove text or image watermarks to brand your users' work and discourage its unauthorized use.\r\n"},
+        };
+
+        public HomePageControl()
+        {
+            InitializeComponent();
+            ImportFeatures();
+        }
+
+        private void ImportFeatures()
+        {
+            if (FeaturesListControl != null)
+            {
+                foreach (CustomItem item in customItems)
+                {
+                    FeaturesListControl.Items.Add(item);
+                    
+                }
+            }
+            FeaturesListControl.SelectionChanged -= FeaturesListControl_SelectionChanged;
+            FeaturesListControl.SelectionChanged += FeaturesListControl_SelectionChanged;
+        }
+
+        private void FeaturesListControl_SelectionChanged(object sender, CustomItem e)
+        {
+            switch (e.TitleText) {
+                case "Watermark":
+                    MessageBox.Show(e.TitleText + " is under development.");
+                    break;
+                default:
+                    MessageBox.Show(e.TitleText + " is under development.");
+                    break;
+            }
+
+        }
+    }
+}

+ 12 - 0
Demo/Examples/Compdfkit_Tools/Common/HomePage/RecentFilesControl.xaml

@@ -0,0 +1,12 @@
+<UserControl x:Class="Compdfkit_Tools.PDFControl.RecentFilesControl"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:Compdfkit_Tools.PDFControl"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800" Background="AliceBlue">
+    <Grid>
+            
+    </Grid>
+</UserControl>

+ 28 - 0
Demo/Examples/Compdfkit_Tools/Common/HomePage/RecentFilesControl.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    /// <summary>
+    /// Interaction logic for RecentFilesControl.xaml
+    /// </summary>
+    public partial class RecentFilesControl : UserControl
+    {
+        public RecentFilesControl()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 21 - 0
Demo/Examples/Compdfkit_Tools/Compdfkit_Tools.csproj

@@ -132,6 +132,15 @@
     <Compile Include="Common\DeviceSerial\DeviceSerialControl.xaml.cs">
       <DependentUpon>DeviceSerialControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Common\HomePage\FeaturesListControl.xaml.cs">
+      <DependentUpon>FeaturesListControl.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Common\HomePage\HomePageControl.xaml.cs">
+      <DependentUpon>HomePageControl.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Common\HomePage\RecentFilesControl.xaml.cs">
+      <DependentUpon>RecentFilesControl.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Common\PasswordControl\PasswordDialog.xaml.cs">
       <DependentUpon>PasswordDialog.xaml</DependentUpon>
     </Compile>
@@ -577,6 +586,18 @@
       <SubType>Designer</SubType>
     </Page>
     <Page Include="Common\DeviceSerial\DeviceSerialControl.xaml" />
+    <Page Include="Common\HomePage\FeaturesListControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Common\HomePage\HomePageControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Common\HomePage\RecentFilesControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Common\PasswordControl\PasswordDialog.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

File diff suppressed because it is too large
+ 33 - 5
Demo/Examples/PDFViewer/MainWindow.xaml


+ 29 - 3
Demo/Examples/PDFViewer/MainWindow.xaml.cs

@@ -29,6 +29,7 @@ namespace PDFViewer
         #region Property
         private PDFViewControl passwordViewer;
         private PDFViewControl pdfViewControl = new PDFViewControl();
+        private HomePageControl homePageControl = new HomePageControl();
         private string[] oldAndNewFilePath;
 
         #endregion
@@ -37,7 +38,7 @@ namespace PDFViewer
         {
             InitializeComponent();
             Loaded += MainWindow_Loaded; ;
-
+            CreateHomePage();
         }
 
         private void MainWindow_Loaded(object sender, RoutedEventArgs e)
@@ -62,6 +63,14 @@ namespace PDFViewer
             TabControlLoadDocument(defaultFilePath);
         }
 
+        private void CreateHomePage()
+        {
+            TabItemExt tabItem = new TabItemExt();
+            tabItem.Content = homePageControl;
+            tabItem.IsSelected = true; 
+            tabItem.Tag = string.Empty;
+            TabControl.Items.Add(tabItem);
+        }
 
         private void TabControlLoadDocument(string filePath)
         {
@@ -205,7 +214,6 @@ namespace PDFViewer
 
         private bool ViewPage_CheckExistBeforeOpenFileEvent(string[] arg)
         {
-
             if (App.OpenedFilePathList.Contains(arg[0]))
             {
                 for (int i = 0; i < App.Current.Windows.Count; i++)
@@ -301,7 +309,10 @@ namespace PDFViewer
             var dragablzItem = FindParentDragablzItem(button);
             var tabControl = FindParentTabControl(dragablzItem);
             MainPage mainPage = (dragablzItem.Content as TabItemExt).Content as MainPage;
-
+            if(mainPage == null)
+            {
+                return;
+            }
             if (mainPage.CanSave)
             {
                 string fileName = (dragablzItem.Content as TabItemExt).FileName;
@@ -371,6 +382,10 @@ namespace PDFViewer
                 TabItemExt item = TabControl.Items[0] as TabItemExt;
 
                 MainPage mainPage = item.Content as MainPage;
+                if(mainPage == null)
+                {
+                    return;
+                }
                 if (mainPage.CanSave)
                 {
                     string fileName = item.FileName;
@@ -408,5 +423,16 @@ namespace PDFViewer
                 SystemCommands.CloseWindow(this);
             }
         }
+
+        private void SettingsBtn_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void HomPageBtn_Click(object sender, RoutedEventArgs e)
+        {
+            TabControl.SelectedIndex = -1;
+        }
+
     }
 }

+ 2 - 2
Demo/Examples/Samples/AnnotationImportExportTest/VB/AnnotationImportExportTest.vb

@@ -45,7 +45,7 @@ Module AnnotationImportExportTest
 
     ' Export the annotations in the document to XFDF format
     Private Function ExportAnnotation(document As CPDFDocument) As Boolean
-        Dim filePath As String = Path.Combine(outputPath, "\ExportAnnotationTest.xfdf")
+        Dim filePath As String = Path.Combine(outputPath, "ExportAnnotationTest.xfdf")
         If Not document.ExportAnnotationToXFDFPath(filePath, tempPath) Then
             Return False
         End If
@@ -55,7 +55,7 @@ Module AnnotationImportExportTest
 
     ' Importing XFDF into the document
     Private Function ImportAnnotation(document As CPDFDocument) As Boolean
-        Dim filePath As String = Path.Combine(outputPath, "\ImportAnnotationTest.pdf")
+        Dim filePath As String = Path.Combine(outputPath, "ImportAnnotationTest.pdf")
 
         If Not document.ImportAnnotationFromXFDFPath("Annotations.xfdf", tempPath) Then
             Return False