Browse Source

compdfkit demo(windows) - 多页签-添加

liuaoran 1 year ago
parent
commit
9f989d5b4e
20 changed files with 303 additions and 38 deletions
  1. 35 0
      compdfkit_demo_windows/compdfkit/compdfkit-assets/Styles/WindowStyle.xaml
  2. 4 0
      compdfkit_demo_windows/compdfkit/compdfkit-assets/compdfkit-assets.csproj
  3. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/AnnotArgsTypeToVisibilityConverter.cs
  4. 24 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/CaptionHeightConverter.cs
  5. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/IntAndTagToBoolMultiBinding.cs
  6. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/ListViewWidthConvert.cs
  7. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/ReverseBoolConvert.cs
  8. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/TextLengthToBoolConvert.cs
  9. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/TextLengthToVisibilityConvert.cs
  10. 33 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/WindowStateToPathConverter.cs
  11. 34 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/WindowStateToThicknessConverter.cs
  12. 3 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj
  13. BIN
      compdfkit_demo_windows/compdfkit/compdfkit/App.ico
  14. 5 2
      compdfkit_demo_windows/compdfkit/compdfkit/App.xaml
  15. 11 14
      compdfkit_demo_windows/compdfkit/compdfkit/MainPage.xaml.cs
  16. 96 7
      compdfkit_demo_windows/compdfkit/compdfkit/MainWindow.xaml
  17. 43 6
      compdfkit_demo_windows/compdfkit/compdfkit/MainWindow.xaml.cs
  18. 5 3
      compdfkit_demo_windows/compdfkit/compdfkit/compdfkit.csproj
  19. BIN
      compdfkit_demo_windows/compdfkit/pageedit-ctrl-demo/App.ico
  20. 4 0
      compdfkit_demo_windows/compdfkit/pageedit-ctrl-demo/pageedit-ctrl-demo.csproj

+ 35 - 0
compdfkit_demo_windows/compdfkit/compdfkit-assets/Styles/WindowStyle.xaml

@@ -0,0 +1,35 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style x:Key="WindowStyle" TargetType="{x:Type Window}">
+        <Setter Property="WindowChrome.WindowChrome">
+            <Setter.Value>
+                <WindowChrome
+                    CaptionHeight="32"
+                    CornerRadius="0"
+                    GlassFrameThickness="0"
+                    ResizeBorderThickness="5"
+                    UseAeroCaptionButtons="False" /> 
+            </Setter.Value>
+        </Setter>
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type Window}">
+                    <Border
+                        Background="{TemplateBinding Background}"
+                        BorderBrush="{TemplateBinding BorderBrush}"
+                        BorderThickness="{TemplateBinding BorderThickness}">
+                        <AdornerDecorator>
+                            <ContentPresenter x:Name="win_content" />
+                        </AdornerDecorator>
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="WindowState" Value="Maximized"> 
+                            <Setter TargetName="win_content" Property="Margin" Value="5,5,5,5" />
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+
+</ResourceDictionary>

+ 4 - 0
compdfkit_demo_windows/compdfkit/compdfkit-assets/compdfkit-assets.csproj

@@ -95,6 +95,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Styles\WindowStyle.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Themes\Global.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/AnnotArgsTypeToVisibilityConverter.cs

@@ -11,7 +11,7 @@ using System.Windows.Data;
 namespace compdfkit_tools.Common
 {
     [ValueConversion(typeof(AnnotArgsType), typeof(Visibility))]
-    internal class AnnotArgsTypeToVisibilityConverter : IValueConverter
+    public class AnnotArgsTypeToVisibilityConverter : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {

+ 24 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/CaptionHeightConverter.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace compdfkit_tools.Common
+{
+    public class CaptionHeightConverter : IMultiValueConverter
+    {
+        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+        {
+            return (double)values[0] + (double)values[1];
+        }
+
+        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+        {
+            return null;
+        }
+    }
+}

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/IntAndTagToBoolMultiBinding.cs

@@ -8,7 +8,7 @@ using System.Windows.Data;
 
 namespace compdfkit_tools.Common
 {
-    class IntAndTagToBoolMultiBinding : IMultiValueConverter
+    public class IntAndTagToBoolMultiBinding : IMultiValueConverter
     {
         public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
         {

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/ListViewWidthConvert.cs

@@ -9,7 +9,7 @@ using System.Windows;
 
 namespace compdfkit_tools.Common
 {
-    internal class ListViewWidthConvert : IValueConverter
+    public class ListViewWidthConvert : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/ReverseBoolConvert.cs

@@ -11,7 +11,7 @@ namespace compdfkit_tools.Common
 {
 
     [ValueConversion(typeof(bool), typeof(bool))]
-    internal class ReverseBoolConvert:IValueConverter
+    public class ReverseBoolConvert:IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/TextLengthToBoolConvert.cs

@@ -9,7 +9,7 @@ using System.Windows.Data;
 
 namespace compdfkit_tools.Common
 {
-    internal class TextLengthToBoolConvert: IValueConverter
+    public class TextLengthToBoolConvert: IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/TextLengthToVisibilityConvert.cs

@@ -9,7 +9,7 @@ using System.Windows.Data;
 
 namespace compdfkit_tools.Common
 {
-    internal class TextLengthToVisibilityConvert: IValueConverter
+    public class TextLengthToVisibilityConvert: IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {

+ 33 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/WindowStateToPathConverter.cs

@@ -0,0 +1,33 @@
+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.Media;
+using System.Windows;
+
+namespace compdfkit_tools.Common
+{
+    public class WindowStateToPathConverter : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            var ws = (WindowState)value;
+            if (ws == WindowState.Normal)
+            {
+                return Geometry.Parse("M 13.5,10.5 H 22.5 V 19.5 H 13.5 Z");
+            }
+            else
+            {
+                return Geometry.Parse("M 13.5,12.5 H 20.5 V 19.5 H 13.5 Z M 15.5,12.5 V 10.5 H 22.5 V 17.5 H 20.5");
+            }
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            return null;
+        }
+    }
+}

+ 34 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/WindowStateToThicknessConverter.cs

@@ -0,0 +1,34 @@
+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
+{
+    [ValueConversion(typeof(WindowState), typeof(Thickness))]
+    public class WindowStateToThicknessConverter : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            var ws = (WindowState)value;
+            if (ws == WindowState.Maximized)
+            {
+                return new Thickness(6);
+            }
+            else
+            {
+                // left, right and bottom borders are still drawn by the system
+                return new Thickness(0, 1, 0, 0);
+            }
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            return null;
+        }
+    }
+}

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

@@ -107,9 +107,12 @@
       <DependentUpon>PageNumberControl.xaml</DependentUpon>
     </Compile>
     <Compile Include="Common\Convert\AnnotArgsTypeToVisibilityConverter.cs" />
+    <Compile Include="Common\Convert\CaptionHeightConverter.cs" />
     <Compile Include="Common\Convert\IntAndTagToBoolMultiBinding.cs" />
     <Compile Include="Common\Convert\ReverseBoolConvert.cs" />
     <Compile Include="Common\Convert\ReverseVisibilityConvert.cs" />
+    <Compile Include="Common\Convert\WindowStateToPathConverter.cs" />
+    <Compile Include="Common\Convert\WindowStateToThicknessConverter.cs" />
     <Compile Include="Common\PasswordControl\PasswordDialog.xaml.cs">
       <DependentUpon>PasswordDialog.xaml</DependentUpon>
     </Compile>

BIN
compdfkit_demo_windows/compdfkit/compdfkit/App.ico


+ 5 - 2
compdfkit_demo_windows/compdfkit/compdfkit/App.xaml

@@ -2,8 +2,11 @@
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:local="clr-namespace:compdfkit"
+             xmlns:common="clr-namespace:compdfkit_tools.Common;assembly=com.compdfkit.tools"
              StartupUri="MainWindow.xaml">
     <Application.Resources>
-         
-    </Application.Resources>
+        <common:WindowStateToThicknessConverter x:Key="WindowStateToThicknessConverter"></common:WindowStateToThicknessConverter>
+        <common:CaptionHeightConverter x:Key="CaptionHeightConverter"></common:CaptionHeightConverter>
+        <common:WindowStateToPathConverter x:Key="WindowStateToPathConverter"></common:WindowStateToPathConverter>
+    </Application.Resources> 
 </Application>

+ 11 - 14
compdfkit_demo_windows/compdfkit/compdfkit/MainPage.xaml.cs

@@ -34,8 +34,7 @@ namespace compdfkit
     /// MainPage.xaml 的交互逻辑
     /// </summary>
     public partial class MainPage : UserControl, INotifyPropertyChanged
-    {
-
+    { 
         private bool isFirstLoad = true;
         private string currentMode = "Viewer";
         private PDFViewControl passwordViewer;
@@ -80,7 +79,6 @@ namespace compdfkit
             }
         }
 
-        public string FilePath = string.Empty;
         /// <summary>
         /// The last edit object
         /// </summary>
@@ -93,22 +91,15 @@ namespace compdfkit
             DataContext = this;
         }
 
-        private void UserControl_Loaded(object sender, RoutedEventArgs e)
-        {
-            BotaSideTool.AddBOTAContent(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search);
-            pdfAnnotationControl = new CPDFAnnotationControl();
-            LoadDefaultDocument();
-        }
 
-        private void LoadDefaultDocument()
+        public void InitWithFilePath(string filePath)
         {
-            string defaultFilePath = "developer_guide_windows.pdf";
-            pdfViewControl.PDFView.InitDocument(defaultFilePath);
-            LoadDocument();
+            pdfViewControl = new PDFViewControl();
+            pdfViewControl.PDFView.InitDocument(filePath);
         }
 
         private void LoadDocument()
-        {
+        { 
             pdfViewControl.PDFView?.Load();
             pdfViewControl.PDFView?.SetShowLink(true);
             PDFGrid.Child = pdfViewControl;
@@ -1187,5 +1178,11 @@ namespace compdfkit
                 pdfViewControl.PDFView.UndoManager?.Redo();
             }
         }
+
+        private void UserControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            pdfAnnotationControl = new CPDFAnnotationControl();
+            LoadDocument();
+        }
     }
 }

+ 96 - 7
compdfkit_demo_windows/compdfkit/compdfkit/MainWindow.xaml

@@ -1,4 +1,5 @@
 <Window x:Class="compdfkit.MainWindow"
+        x:Name="Window"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -9,14 +10,23 @@
         mc:Ignorable="d"   
         SnapsToDevicePixels="True" 
         xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+        BorderThickness="{Binding RelativeSource={RelativeSource Mode=Self},Path=WindowState,Converter={StaticResource WindowStateToThicknessConverter}}"
         Title="MainWindow" Height="960" Width="1280"  WindowStartupLocation="CenterScreen">
     <WindowChrome.WindowChrome>
         <WindowChrome 
+            CornerRadius="8"
             NonClientFrameEdges="Left,Bottom,Right"
             UseAeroCaptionButtons="False"
             ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}">
+            <WindowChrome.CaptionHeight>
+                <MultiBinding Converter="{StaticResource CaptionHeightConverter}">
+                    <Binding ElementName="TitleBarGrid" Path="ActualHeight"/>
+                    <Binding ElementName="Window" Path="BorderThickness.Top"/>
+                </MultiBinding>
+            </WindowChrome.CaptionHeight>
         </WindowChrome>
     </WindowChrome.WindowChrome>
+
     <Window.Resources>
         <ControlTemplate x:Key="CloseFileButton" TargetType="{x:Type ButtonBase}">
             <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
@@ -91,7 +101,7 @@
                                 <ColumnDefinition Width="*" />
                                 <ColumnDefinition Width="auto" />
                             </Grid.ColumnDefinitions>
-                            <Border  x:Name="Title"  Width="184"  Height="28"  Margin="4,0,0,2" BorderBrush="#A0A2AE" BorderThickness="1,1,1,0">
+                            <Border  x:Name="Title"  Width="184"  Height="32"  Margin="0,4,0,0" BorderBrush="#A0A2AE" BorderThickness="1,1,1,0" CornerRadius="3,3,0,0">
                                 <Grid Background="Transparent">
                                     <Grid.ColumnDefinitions>
                                         <ColumnDefinition Width="auto" />
@@ -114,7 +124,6 @@
                                 </Grid>
                             </Border>
                         </Grid>
-                        
                         <ControlTemplate.Triggers>
                             <Trigger Property="IsSelected" Value="True">
                                 <Setter TargetName="Title" Property="Background" Value="#FFFFFF" />
@@ -142,15 +151,78 @@
                 </Setter.Value>
             </Setter>
         </Style>
+        <Style x:Key="TitleBarButtonStyle" TargetType="Button">
+            <Setter Property="Foreground" Value="#FFFFFF" />
+            <Setter Property="Padding" Value="0" />
+            <Setter Property="Margin" Value="0" />
+            <Setter Property="VerticalAlignment" Value="Top" />
+            <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
+            <Setter Property="IsTabStop" Value="False" />
+            <Setter Property="Width" Value="36" />
+            <Setter Property="Height" Value="30" />
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="{x:Type Button}">
+                        <Border x:Name="border"
+                                Background="Transparent"
+                                BorderThickness="0"
+                                SnapsToDevicePixels="True">
+                            <ContentPresenter x:Name="contentPresenter"
+                                Margin="0"
+                                HorizontalAlignment="Center"
+                                VerticalAlignment="Center"
+                                Focusable="False"
+                                RecognizesAccessKey="True" />
+                        </Border>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsMouseOver" Value="true">
+                                <Setter TargetName="border" Property="Background" Value="#1AE9E9E9" /> 
+                            </Trigger>
+                            <Trigger Property="IsPressed" Value="true">
+                                <Setter TargetName="border" Property="Background" Value="#1AEDEDED" /> 
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+
+        <Style x:Key="TitleBarCloseButtonStyle" BasedOn="{StaticResource TitleBarButtonStyle}" TargetType="Button"> 
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="{x:Type Button}">
+                        <Border x:Name="border"
+                                Background="Transparent"
+                                BorderThickness="0"
+                                SnapsToDevicePixels="True">
+                            <ContentPresenter x:Name="contentPresenter"
+                                Margin="0"
+                                HorizontalAlignment="Center"
+                                VerticalAlignment="Center"
+                                Focusable="False"
+                                RecognizesAccessKey="True" />
+                        </Border>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsMouseOver" Value="true">
+                                <Setter TargetName="border" Property="Background" Value="#C42B1C" /> 
+                            </Trigger>
+                            <Trigger Property="IsPressed" Value="true">
+                                <Setter TargetName="border" Property="Background" Value="#C84031" /> 
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
     </Window.Resources>
 
-    <Grid Background="#273C62">
-        <dragablz:TabablzControl Name="TabControl" ItemContainerStyle="{StaticResource DragablzItemStyle}">
+    <Grid Background="#273C62" Margin="0,-1,0,0">
+        <dragablz:TabablzControl Name="TabControl" ItemContainerStyle="{StaticResource DragablzItemStyle}" WindowChrome.IsHitTestVisibleInChrome="True">
             <dragablz:TabablzControl.InterTabController>
                 <dragablz:InterTabController />
             </dragablz:TabablzControl.InterTabController>
             <dragablz:TabablzControl.HeaderSuffixContent>
-                <Grid>
+                <Grid Name="TitleBarGrid" MinHeight="32">
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition Width="auto"></ColumnDefinition>
                         <ColumnDefinition Width="*"></ColumnDefinition>
@@ -159,8 +231,25 @@
                     <Button  x:Name="addBtn" Width="16"  Height="16"  Margin="9,7,0,5"  HorizontalAlignment="Left" Background="Transparent"  BorderThickness="0" 
                              Click="DefaultAddButton_Click"  Template="{StaticResource AddFileButton}"></Button>
                     <Grid Grid.Column="2" HorizontalAlignment="Right">
-                        <StackPanel>
-                            <Button Width="30" Height="32"/>
+                        <StackPanel Orientation="Horizontal" Margin="0,-2,0,0">
+                            <Button x:Name="MinimizeButton" Style="{StaticResource TitleBarButtonStyle}" Width="36" Height="32" Click="MinimizeButton_Click">
+                                <Path Width="36" Height="32"
+                                        Data="M 13,15 H 23"
+                                        Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
+                                        StrokeThickness="1" />
+                            </Button>
+                            <Button x:Name="MaximizeRestoreButton" Style="{StaticResource TitleBarButtonStyle}" Width="36" Height="32" Click="MaximizeRestoreButton_Click">
+                                <Path Width="36" Height="32"
+                      Data="{Binding ElementName=Window, Path=WindowState, Converter={StaticResource WindowStateToPathConverter}}"
+                      Stroke="{Binding Path=Foreground,RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
+                      StrokeThickness="1" />
+                            </Button>
+                            <Button x:Name="CloseButton" Style="{StaticResource TitleBarCloseButtonStyle}" Width="36" Height="32" Click="CloseButton_Click">
+                                <Path Width="36" Height="32"
+                                        Data="M 13,11 22,20 M 13,20 22,11"
+                                        Stroke="{Binding Path=Foreground,RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
+                                        StrokeThickness="1" />
+                            </Button>
                         </StackPanel>
                     </Grid>
                 </Grid>

+ 43 - 6
compdfkit_demo_windows/compdfkit/compdfkit/MainWindow.xaml.cs

@@ -43,30 +43,37 @@ namespace compdfkit
         }
 
         private void MainWindow_Loaded(object sender, RoutedEventArgs e)
+        {
+            LoadDefaultDocument();
+        }
+
+        private void LoadDefaultDocument()
         {
             MainPage viewPage = new MainPage();
             TabItemExt tabItem = new TabItemExt();
+            string defaultFilePath = "developer_guide_windows.pdf";
+            viewPage.InitWithFilePath(defaultFilePath);
             tabItem.Content = viewPage;
             tabItem.IsSelected = true;
-            tabItem.FileName = Path.GetFileName(viewPage.FilePath);
+            tabItem.FileName = Path.GetFileName(defaultFilePath);
             TabControl.Items.Add(tabItem);
         }
 
         private void DefaultAddButton_Click(object sender, RoutedEventArgs e)
         {
-            OpenFileDialog openFileDialog = new OpenFileDialog();
-            openFileDialog.Filter = "PDF Files(*.pdf;*.PDF;)|*.pdf;*.PDF;";
-            if (openFileDialog.ShowDialog() == true)
+            string filePath = CommonHelper.GetFilePathOrEmpty();
+            if (filePath != string.Empty)
             {
                 TabItemExt tabItem = new TabItemExt();
                 MainPage viewPage = new MainPage();
-                viewPage.FilePath = openFileDialog.FileName;
+                viewPage.InitWithFilePath(filePath);
                 tabItem.Content = viewPage;
                 tabItem.IsSelected = true;
-                tabItem.FileName = Path.GetFileName(viewPage.FilePath);
+                tabItem.FileName = Path.GetFileName(filePath);
                 TabControl.Items.Add(tabItem);
             }
         }
+
         public class TabItemExt : TabItem, INotifyPropertyChanged
         {
             public event PropertyChangedEventHandler PropertyChanged;
@@ -110,5 +117,35 @@ namespace compdfkit
                 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
             }
         }
+
+        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            DragMove();
+        }
+
+        #region window action
+        private void MinimizeButton_Click(object sender, RoutedEventArgs e)
+        {
+            SystemCommands.MinimizeWindow(this);
+        }
+
+        private void MaximizeRestoreButton_Click(object sender, RoutedEventArgs e)
+        {
+            if (this.WindowState == WindowState.Maximized)
+            {
+                SystemCommands.RestoreWindow(this);
+            }
+            else
+            {
+                SystemCommands.MaximizeWindow(this);
+            }
+        }
+
+        private void CloseButton_Click(object sender, RoutedEventArgs e)
+        {
+            SystemCommands.CloseWindow(this);
+        }
+        #endregion 
+
     }
 }

+ 5 - 3
compdfkit_demo_windows/compdfkit/compdfkit/compdfkit.csproj

@@ -34,6 +34,9 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup>
+    <ApplicationIcon>App.ico</ApplicationIcon>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="ComPDFKit.Desk, Version=1.8.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
@@ -124,11 +127,10 @@
       <Link>SDKLicense.xml</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <Resource Include="App.ico" />
     <Content Include="ComPDFKit.Desk.dll" />
     <Content Include="ComPDFKit.Viewer.dll" />
-    <Content Include="Dragablz.dll">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
+    <Content Include="Dragablz.dll" />
     <Content Include="x64\ComPDFKit.dll">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>

BIN
compdfkit_demo_windows/compdfkit/pageedit-ctrl-demo/App.ico


+ 4 - 0
compdfkit_demo_windows/compdfkit/pageedit-ctrl-demo/pageedit-ctrl-demo.csproj

@@ -34,6 +34,9 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup>
+    <ApplicationIcon>App.ico</ApplicationIcon>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="ComPDFKit.Desk, Version=1.8.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
@@ -108,6 +111,7 @@
     <None Include="App.config" />
   </ItemGroup>
   <ItemGroup>
+    <Resource Include="App.ico" />
     <Content Include="ComPDFKit.Desk.dll" />
     <Content Include="ComPDFKit.Viewer.dll" />
     <None Include="SDKLicense.xml">