Ver Fonte

文件-提交部分文件结构

ZhouJieSheng há 2 anos atrás
pai
commit
f2eff87c79

+ 67 - 0
PDF Office/App.xaml.cs

@@ -2,10 +2,14 @@
 using System.Collections.Generic;
 using System.Configuration;
 using System.Data;
+using System.IO;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Windows;
+using ComPDFKit.NativeMethod;
+using ComPDFKit_Conversion.Converter;
 using PDF_Office.Views;
+using PDF_Office.Views.HomePanel;
 using Prism.DryIoc;
 using Prism.Ioc;
 
@@ -27,6 +31,9 @@ namespace PDF_Office
             var countryCode = RegionInfo.CurrentRegion.TwoLetterISORegionName;//上传国家信息
             AppCenter.SetCountryCode(countryCode);
 #endif
+            LicenseVerify();
+
+
         }
 
         /// <summary>
@@ -43,6 +50,66 @@ namespace PDF_Office
             //单例
             containerRegistry.RegisterForNavigation<HomeContent>();
             containerRegistry.RegisterForNavigation<ViewContent>();
+            containerRegistry.RegisterForNavigation<HomeCloudContent>("Cloud");
+            containerRegistry.RegisterForNavigation<HomeToolsContent>("Tools");
+            containerRegistry.RegisterForNavigation<HomeGuidContent>("Guid");
+        }
+
+        private static bool LicenseVerify()
+        {
+            bool result = false;
+            try
+            {
+                result = CPDFSDKVerifier.LoadNativeLibrary();
+                if (!result)
+                    return false;
+            }
+            catch (Exception ex) { }
+            string devKey = "";
+            string devSecret = "";
+#if DEBUG
+            devKey = "tmqcblSkvVZeNj9k4nMA88G6g1kw4yYH+tPiqK+T91CaGM9urgNlT1+kXiTyv0W1bTQNObS51WgQpfJNl1inRVDKBB3wznw2o7vtKjOKKDNbV7R1ply0PhDKVkKYV040vpAdaT8GZEfllftNlts99uGhscqGvmCLBKmgTsq0HFo=";
+            devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iccr16WMBclnQACarlyblNMFa171moVHNuaoPG9eUt/RDYPB4dH12/mo6Nb7CMnoDUShGRobCLus9Vl3Sb80EZvGI/sVnm7Ju0Mhj+L/faMDDsKeheIw8v1IwmcZT3yU2l9MwkobWvR2DRybgSkLGYbFAv+VbVAICHE/17JjUpTkFo+FpaETldwAVsTVNm77oq2xRRteAQmIiZl/ptWMK8";
+#endif
+
+            string userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs=";
+            string userSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4ivEHOmPIqbfhpDnKKj+7Ymj2rXQvfZRmke06HMV+3tt064G64WjPW8+EbGCNZaAh1hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1FKJi6HYB+DuugQyaqI2prfej861QnJrU4s2T/npZK/";
+
+            try
+            {
+                CPDFSDKVerifier.LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(devKey, devSecret, userKey, userSecret);
+                if (verifyResult != CPDFSDKVerifier.LicenseErrorCode.LICENSE_ERR_SUCCESS)
+                    return false;
+            }
+            catch (Exception ex) { }
+
+
+
+            string ConverterDevKey = "mDDCTNY5rV2+FUj2JESUBruJ0643Tv7rNuxACu6g3L/0guIw1r8zZB+o3aw3rs4rrOThmxBXpEDcItvyGx096mF/3Ixg7aD6QZk5HvBEScIPerdM3KnhgwMwCjE0DYOSMCRwAhbA2xjXfXgT5VVo7JZroKOGQB5Qmf2kLl5nQuU=";
+            string ConverterDevSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4g3S5AixMY+3TX1FpQaugG9sTsnCq4QxIEDzyAI3s3dWjNe3wDsMrmFq51HtjPa2tSFAoV6NtcUJC8skonXVk7kMv7C2jvq4o0q6sQtN3jR42k0n/LkN5UfbQ5Lfel4OfZrk7dh2/DUR87Ps4vBX1hrYkwcNWVMyYvggPV2rTFvfawopGIC034QzjthmhwwX90=";
+            string ConverterUserkey = "WLUHzXhndQKyrTJVzvZ+dvPXDQDZeJpcSvklX3GJwRX4+urd8eQskYgbeCf0NXLZ/qJkS/k10x+qGad34i4v5rI/ASFIx901c/Nw5C0YJMH7X87dib141tdAmSmQhnKLO5TBi4FiAidboyvnLFLrYGMmS2kLQOXFPwPj5zQUv5A=";
+            string ConverterUserSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ==";
+
+            try
+            {
+                /*LicenseError licenseerror = CPDFConverter.SDKLicenseVerify(ConverterDevKey, ConverterDevSecret, ConverterUserkey, ConverterUserSecret);
+            string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
+            if (licenseerror != LicenseError.ERR_SUCCESS)
+            {
+                return false;
+            }
+                CPDFConverter.Init(resPath);*/
+                string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
+                LicenseError licenseerror = CPDFConverter.LicenseVerify(ConverterDevKey, ConverterDevSecret, ConverterUserkey, ConverterUserSecret);
+                if (licenseerror != LicenseError.ERR_SUCCESS)
+                {
+                    //MessageBox.Show("ComPDFKit Conversion SDK Load Failed!");
+                    return false;
+                }
+                CPDFConverter.Init(resPath);
+            }
+            catch (Exception ex) { }
+            return result;
         }
     }
 }

+ 16 - 0
PDF Office/EventAggregators/OpenFileEvent.cs

@@ -0,0 +1,16 @@
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.EventAggregators
+{
+    /// <summary>
+    /// 用于通知打开文件的事件类型
+    /// </summary>
+    public class OpenFileEvent: PubSubEvent
+    {
+    }
+}

+ 41 - 0
PDF Office/PDF Office.csproj

@@ -35,6 +35,22 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="ComOCRKit.Desk, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>.\ComOCRKit.Desk.dll</HintPath>
+    </Reference>
+    <Reference Include="ComPDFKit.Desk, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>.\ComPDFKit.Desk.dll</HintPath>
+    </Reference>
+    <Reference Include="ComPDFKit.Viewer, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>.\ComPDFKit.Viewer.dll</HintPath>
+    </Reference>
+    <Reference Include="ComPDFKit_Conversion, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>.\ComPDFKit_Conversion.dll</HintPath>
+    </Reference>
     <Reference Include="DotNetSpeech, Version=5.1.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <EmbedInteropTypes>True</EmbedInteropTypes>
@@ -83,6 +99,19 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="EventAggregators\OpenFileEvent.cs" />
+    <Compile Include="ViewModels\HomePanel\HomeCloudContentViewModel.cs" />
+    <Compile Include="ViewModels\HomePanel\HomeGuidContentViewModel.cs" />
+    <Compile Include="ViewModels\HomePanel\HomeToolsContentViewModel.cs" />
+    <Compile Include="Views\HomePanel\HomeCloudContent.xaml.cs">
+      <DependentUpon>HomeCloudContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\HomePanel\HomeGuidContent.xaml.cs">
+      <DependentUpon>HomeGuidContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\HomePanel\HomeToolsContent.xaml.cs">
+      <DependentUpon>HomeToolsContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\ViewContent.xaml.cs">
       <DependentUpon>ViewContent.xaml</DependentUpon>
     </Compile>
@@ -90,6 +119,18 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="Views\HomePanel\HomeCloudContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\HomePanel\HomeGuidContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\HomePanel\HomeToolsContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

+ 12 - 6
PDF Office/ViewModels/HomeContentViewModel.cs

@@ -1,4 +1,6 @@
-using Prism.Commands;
+using PDF_Office.EventAggregators;
+using Prism.Commands;
+using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
@@ -14,14 +16,18 @@ namespace PDF_Office.ViewModels
 
         public DelegateCommand OpenFileCommand { get; set; }
 
+        public DelegateCommand<string> ShowToolCommand { get; set; }
+
         public IRegionManager toolregion;
 
-        public HomeContentViewModel(IRegionManager regionManager)
+        public IEventAggregator eventer;
+
+        public HomeContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
         {
             toolregion = regionManager;
+            eventer = eventAggregator;
             OpenFileCommand = new DelegateCommand(OpenFile);
-        
-
+            ShowToolCommand = new DelegateCommand<string>(ShowToolContent);
         }
 
         /// <summary>
@@ -37,8 +43,8 @@ namespace PDF_Office.ViewModels
         /// 打开文件
         /// </summary>
         public void OpenFile()
-        { 
-
+        {
+            eventer.GetEvent<OpenFileEvent>().Publish();
         }
 
         public void CreatBlankPDF()

+ 17 - 0
PDF Office/ViewModels/HomePanel/HomeCloudContentViewModel.cs

@@ -0,0 +1,17 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.HomePanel
+{
+    public class HomeCloudContentViewModel:BindableBase
+    {
+        public HomeCloudContentViewModel()
+        {
+
+        }
+    }
+}

+ 17 - 0
PDF Office/ViewModels/HomePanel/HomeGuidContentViewModel.cs

@@ -0,0 +1,17 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.HomePanel
+{
+    public class HomeGuidContentViewModel:BindableBase
+    {
+        public HomeGuidContentViewModel()
+        {
+
+        }
+    }
+}

+ 17 - 0
PDF Office/ViewModels/HomePanel/HomeToolsContentViewModel.cs

@@ -0,0 +1,17 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.HomePanel
+{
+    public class HomeToolsContentViewModel:BindableBase
+    {
+        public HomeToolsContentViewModel()
+        {
+
+        }
+    }
+}

+ 15 - 3
PDF Office/ViewModels/MainWindowViewModel.cs

@@ -1,4 +1,7 @@
-using Prism.Commands;
+using PDF_Office.EventAggregators;
+using PDF_Office.Views;
+using Prism.Commands;
+using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
@@ -18,13 +21,22 @@ namespace PDF_Office.ViewModels
             set { SetProperty(ref _title, value); }
         }
 
-
         public IRegionManager region;
 
-        public MainWindowViewModel(IRegionManager regionManager)
+        public IEventAggregator eventer;
+
+        public MainWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
         {
             region = regionManager;
+            eventer = eventAggregator;
+            //region.RequestNavigate("ViwerRegion", "HomeContent");
+            eventer.GetEvent<OpenFileEvent>().Subscribe(OpenFile);
+            region.RegisterViewWithRegion("ViwerRegion",typeof(HomeContent));
+        }
 
+        public void OpenFile()
+        {
+            region.RequestNavigate("ViwerRegion", "ViewContent");
         }
     }
 }

+ 39 - 2
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -1,12 +1,49 @@
-using System;
+using Microsoft.Win32;
+using Prism.Commands;
+using Prism.Mvvm;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using ComPDFKitViewer.PdfViewer;
+using Prism.Regions;
 
 namespace PDF_Office.ViewModels
 {
-    class ViewContentViewModel
+
+    public class ViewContentViewModel : BindableBase
     {
+        public DelegateCommand LoadFile { get; set; }
+
+        private CPDFViewer PDFViewer { get; set; }
+
+        public IRegionManager region;
+
+        public ViewContentViewModel(IRegionManager regionManager)
+        {
+            LoadFile = new DelegateCommand(loadFile);
+            region = regionManager;
+            //在构造函数中使用Region需要借助Dispatcher 确保UI已经加载完成
+            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { loadFile(); }));
+
+
+        }
+
+        private void loadFile()
+        {
+            OpenFileDialog openFileDialog = new OpenFileDialog();
+            openFileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
+            if ((bool)openFileDialog.ShowDialog())
+            {
+                string file = openFileDialog.FileName;
+                var PDFViewer = new CPDFViewer();
+                PDFViewer.InitDocument(file);
+                PDFViewer.Load();
+                region.AddToRegion("PDFViewer", PDFViewer);
+            }
+
+        }
+
     }
 }

+ 52 - 17
PDF Office/Views/HomeContent.xaml

@@ -1,24 +1,59 @@
-<UserControl x:Class="PDF_Office.Views.HomeContent"
-             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:prism ="http://prismlibrary.com/"
-             xmlns:viewmodels="clr-namespace:PDF_Office.ViewModels" 
-             prism:ViewModelLocator.AutoWireViewModel="True"
-             mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
+<UserControl
+    x:Class="PDF_Office.Views.HomeContent"
+    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"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:prism="http://prismlibrary.com/"
+    xmlns:viewmodels="clr-namespace:PDF_Office.ViewModels"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    prism:ViewModelLocator.AutoWireViewModel="True"
+    mc:Ignorable="d">
     <Grid>
         <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="270"/>
-            <ColumnDefinition Width="*"/>
+            <ColumnDefinition Width="270" />
+            <ColumnDefinition Width="*" />
         </Grid.ColumnDefinitions>
-        <!--左侧菜单栏-->
+        <!--  左侧菜单栏  -->
         <StackPanel>
-            <Button Name="BtnOpenPDF" Content="OPEN PDF" Margin="41 54 41 0" Height="48" Command="{Binding OpenFileCommand}"/>
-            <Button Name="BtnCreatPDF" Content="" Margin="41 8 41 0" Height="48"/>
+            <Button
+                Name="BtnOpenPDF"
+                Height="48"
+                Margin="41,54,41,0"
+                Padding="0,0,0,0"
+                Command="{Binding OpenFileCommand}"
+                Content="OPEN PDF" />
+            <Button
+                Name="BtnCreatPDF"
+                Height="48"
+                Margin="41,8,41,0"
+                Content="" />
+
+            <Button
+                Name="BtnGuid"
+                Width="216"
+                Height="40"
+                Margin="0,24,0,0"
+                Command="{Binding ShowToolCommand}"
+                CommandParameter="Guid"
+                Content="Home" />
+            <Button
+                Name="BtnTool"
+                Width="216"
+                Height="40"
+                Command="{Binding ShowToolCommand}"
+                CommandParameter="Tools"
+                Content="Tool" />
+            <Button
+                Name="BtnCloud"
+                Width="216"
+                Height="40"
+                Command="{Binding ShowToolCommand}"
+                CommandParameter="Cloud"
+                Content="Cloud" />
         </StackPanel>
-        <!--右侧内容区域-->
-        <ContentControl Grid.Column="1" prism:RegionManager.RegionName="ToolContent"/>
+        <!--  右侧内容区域  -->
+        <ContentControl Grid.Column="1" prism:RegionManager.RegionName="ToolContent" />
     </Grid>
 </UserControl>

+ 15 - 0
PDF Office/Views/HomePanel/HomeCloudContent.xaml

@@ -0,0 +1,15 @@
+<UserControl x:Class="PDF_Office.Views.HomePanel.HomeCloudContent"
+             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:PDF_Office.Views.HomePanel"
+             xmlns:prism ="http://prismlibrary.com/"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             Background="Yellow"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+            
+    </Grid>
+</UserControl>

+ 28 - 0
PDF Office/Views/HomePanel/HomeCloudContent.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 PDF_Office.Views.HomePanel
+{
+    /// <summary>
+    /// HomeCloudContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class HomeCloudContent : UserControl
+    {
+        public HomeCloudContent()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 15 - 0
PDF Office/Views/HomePanel/HomeGuidContent.xaml

@@ -0,0 +1,15 @@
+<UserControl x:Class="PDF_Office.Views.HomePanel.HomeGuidContent"
+             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:PDF_Office.Views.HomePanel"
+             xmlns:prism="http://prismlibrary.com/"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             Background="Blue"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+            
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/HomePanel/HomeGuidContent.xaml.cs

@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace PDF_Office.Views.HomePanel
+{
+    /// <summary>
+    /// HomeGuidContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class HomeGuidContent : UserControl
+    {
+        public HomeGuidContent()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 15 - 0
PDF Office/Views/HomePanel/HomeToolsContent.xaml

@@ -0,0 +1,15 @@
+<UserControl x:Class="PDF_Office.Views.HomePanel.HomeToolsContent"
+             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:PDF_Office.Views.HomePanel"
+             xmlns:prism ="http://prismlibrary.com/"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             Background="Red"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+            
+    </Grid>
+</UserControl>

+ 28 - 0
PDF Office/Views/HomePanel/HomeToolsContent.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 PDF_Office.Views.HomePanel
+{
+    /// <summary>
+    /// HomeToolContetn.xaml 的交互逻辑
+    /// </summary>
+    public partial class HomeToolsContent : UserControl
+    {
+        public HomeToolsContent()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 127 - 73
PDF Office/Views/MainWindow.xaml

@@ -1,24 +1,29 @@
-<Window x:Class="PDF_Office.Views.MainWindow"
-        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" 
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:PDF_Office"
-        xmlns:dragablz ="http://dragablz.net/winfx/xaml/dragablz"
-        xmlns:prism ="http://prismlibrary.com/"
-        xmlns:viewmodels="clr-namespace:PDF_Office.ViewModels" 
-        prism:ViewModelLocator.AutoWireViewModel="True"
-        WindowStartupLocation="CenterScreen"
-        mc:Ignorable="d"
-        Title="{Binding Title}" Height="450" Width="800">
-
+<Window
+    x:Class="PDF_Office.Views.MainWindow"
+    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"
+    xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
+    xmlns:local="clr-namespace:PDF_Office"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:prism="http://prismlibrary.com/"
+    xmlns:viewmodels="clr-namespace:PDF_Office.ViewModels"
+    Title="{Binding Title}"
+    Width="1280"
+    Height="800"
+    MinWidth="1280"
+    MinHeight="800"
+    prism:ViewModelLocator.AutoWireViewModel="True"
+    WindowStartupLocation="CenterScreen"
+    mc:Ignorable="d">
     <WindowChrome.WindowChrome>
-        <WindowChrome   CornerRadius="0"
-                      CaptionHeight="30"
-                  GlassFrameThickness="-1"
-                  UseAeroCaptionButtons="False"
-                  
-                  NonClientFrameEdges="None"/>
+        <WindowChrome
+            CaptionHeight="30"
+            CornerRadius="0"
+            GlassFrameThickness="-1"
+            NonClientFrameEdges="None"
+            ResizeBorderThickness="3"
+            UseAeroCaptionButtons="False" />
     </WindowChrome.WindowChrome>
     <Window.Resources>
         <ResourceDictionary>
@@ -26,53 +31,82 @@
                 <Setter Property="Template">
                     <Setter.Value>
                         <ControlTemplate TargetType="dragablz:DragablzItem">
-                            <Grid  x:Name="templateRoot">
+                            <Grid x:Name="templateRoot">
                                 <Grid.ColumnDefinitions>
-                                    <ColumnDefinition Width="*"></ColumnDefinition>
-                                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                                    <ColumnDefinition Width="*" />
+                                    <ColumnDefinition Width="auto" />
                                 </Grid.ColumnDefinitions>
-                                <Border x:Name="Title"  BorderBrush="#A0A2AE" BorderThickness="1 1 1 0" CornerRadius="5,5,0,0" Width="184" Height="28" Margin="4,0,0,2">
+                                <Border
+                                    x:Name="Title"
+                                    Width="184"
+                                    Height="28"
+                                    Margin="4,0,0,2"
+                                    BorderBrush="#A0A2AE"
+                                    BorderThickness="1,1,1,0"
+                                    CornerRadius="5,5,0,0">
                                     <Grid Background="Transparent">
                                         <Grid.ColumnDefinitions>
-                                            <ColumnDefinition Width="auto"></ColumnDefinition>
-                                            <ColumnDefinition Width="*" MinWidth="10"></ColumnDefinition>
-                                            <ColumnDefinition Width="auto"></ColumnDefinition>
+                                            <ColumnDefinition Width="auto" />
+                                            <ColumnDefinition Width="*" MinWidth="10" />
+                                            <ColumnDefinition Width="auto" />
                                         </Grid.ColumnDefinitions>
-                                        <TextBlock x:Name="TextTitle" MaxWidth="145"  Margin="8,4,0,4" FontFamily="Segoe UI,Microsoft YaHei" TextTrimming="WordEllipsis" Text="{Binding FileName}"/>
-                                        <Thumb Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="PART_Thumb" Background="Transparent" FontFamily="Segoe UI,Microsoft YaHei" ToolTip="{Binding FileName}">
+                                        <TextBlock
+                                            x:Name="TextTitle"
+                                            MaxWidth="145"
+                                            Margin="8,4,0,4"
+                                            FontFamily="Segoe UI,Microsoft YaHei"
+                                            Text="{Binding FileName}"
+                                            TextTrimming="WordEllipsis" />
+                                        <Thumb
+                                            x:Name="PART_Thumb"
+                                            Grid.ColumnSpan="2"
+                                            HorizontalAlignment="Stretch"
+                                            VerticalContentAlignment="Stretch"
+                                            Background="Transparent"
+                                            FontFamily="Segoe UI,Microsoft YaHei"
+                                            ToolTip="{Binding FileName}">
                                             <Thumb.Template>
                                                 <ControlTemplate>
-                                                    <Grid Background="Transparent"/>
+                                                    <Grid Background="Transparent" />
                                                 </ControlTemplate>
                                             </Thumb.Template>
                                         </Thumb>
-                                        <TextBlock Grid.Column="1" Width="5" x:Name="ChangeIcon" Margin="3,4,2,0" HorizontalAlignment="Left" VerticalAlignment="Top" Visibility="{Binding FileChanged}" Text="*" IsHitTestVisible="False"/>
+                                        <TextBlock
+                                            x:Name="ChangeIcon"
+                                            Grid.Column="1"
+                                            Width="5"
+                                            Margin="3,4,2,0"
+                                            HorizontalAlignment="Left"
+                                            VerticalAlignment="Top"
+                                            IsHitTestVisible="False"
+                                            Text="*"
+                                            Visibility="{Binding FileChanged}" />
 
                                     </Grid>
                                 </Border>
                             </Grid>
                             <ControlTemplate.Triggers>
                                 <Trigger Property="IsSelected" Value="True">
-                                    <Setter TargetName="Title" Property="Background" Value="#FFFFFF"/>
-                                    <Setter TargetName="Title" Property="BorderThickness" Value="1,1,1,0"/>
-                                    <Setter TargetName="TextTitle" Property="Foreground" Value="#477EDE"/>
-                                    <Setter TargetName="ChangeIcon" Property="Foreground" Value="#477EDE"/>
+                                    <Setter TargetName="Title" Property="Background" Value="#FFFFFF" />
+                                    <Setter TargetName="Title" Property="BorderThickness" Value="1,1,1,0" />
+                                    <Setter TargetName="TextTitle" Property="Foreground" Value="#477EDE" />
+                                    <Setter TargetName="ChangeIcon" Property="Foreground" Value="#477EDE" />
                                 </Trigger>
                                 <Trigger Property="IsSelected" Value="False">
-                                    <Setter TargetName="Title" Property="Background" Value="TransParent"/>
-                                    <Setter TargetName="Title" Property="BorderThickness" Value="1 1 1 0"/>
-                                    <Setter TargetName="TextTitle" Property="Foreground" Value="#666666"/>
-                                    <Setter TargetName="ChangeIcon" Property="Foreground" Value="#666666"/>
+                                    <Setter TargetName="Title" Property="Background" Value="TransParent" />
+                                    <Setter TargetName="Title" Property="BorderThickness" Value="1,1,1,0" />
+                                    <Setter TargetName="TextTitle" Property="Foreground" Value="#666666" />
+                                    <Setter TargetName="ChangeIcon" Property="Foreground" Value="#666666" />
                                     <!--<Setter TargetName="btnPath" Property="Path.Fill" Value="#FF666666"/>-->
                                 </Trigger>
                                 <MultiDataTrigger>
                                     <MultiDataTrigger.Conditions>
-                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
-                                        <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
+                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false" />
+                                        <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true" />
                                     </MultiDataTrigger.Conditions>
-                                    <Setter TargetName="Title" Property="Background" Value="#0D000000"/>
-                                    <Setter TargetName="TextTitle" Property="Foreground" Value="black"/>
-                                    <Setter TargetName="ChangeIcon" Property="Foreground" Value="black"/>
+                                    <Setter TargetName="Title" Property="Background" Value="#0D000000" />
+                                    <Setter TargetName="TextTitle" Property="Foreground" Value="black" />
+                                    <Setter TargetName="ChangeIcon" Property="Foreground" Value="black" />
                                     <!--<Setter TargetName="btnPath" Property="Path.Fill" Value="Black"/>-->
                                 </MultiDataTrigger>
                             </ControlTemplate.Triggers>
@@ -84,51 +118,71 @@
     </Window.Resources>
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="40"/>
-            <RowDefinition Height="*"/>
+            <RowDefinition Height="40" />
+            <RowDefinition Height="*" />
         </Grid.RowDefinitions>
-        <dragablz:TabablzControl WindowChrome.IsHitTestVisibleInChrome="True"
-                                 Name="PDFViewerTab"
-                                 BorderThickness="0" Grid.RowSpan="2">
+        <dragablz:TabablzControl
+            Name="PDFViewerTab"
+            Grid.RowSpan="2"
+            BorderThickness="0"
+            ItemContainerStyle="{StaticResource DragablzItemStyle}"
+            WindowChrome.IsHitTestVisibleInChrome="True">
             <dragablz:TabablzControl.InterTabController>
-                <dragablz:InterTabController/>
+                <dragablz:InterTabController />
             </dragablz:TabablzControl.InterTabController>
             <dragablz:TabablzControl.HeaderSuffixContent>
-                <Button x:Name="addBtn" Margin="9,7,50,5" BorderThickness="0" Background="Transparent" 
-                                    Content="+" Width="16" Height="16" HorizontalAlignment="Left">
-                </Button>
+                <Button
+                    x:Name="BtnAdd"
+                    Width="16"
+                    Height="16"
+                    Margin="9,7,200,5"
+                    HorizontalAlignment="Left"
+                    Background="Transparent"
+                    BorderThickness="0"
+                    Click="BtnAdd_Click"
+                    Content="+" />
             </dragablz:TabablzControl.HeaderSuffixContent>
             <dragablz:TabablzControl.HeaderPrefixContent>
-                <Grid Background="Transparent" Width="16" Height="38" Margin="0 2 0 0"/>
+                <Grid
+                    Width="16"
+                    Height="38"
+                    Margin="0,2,0,0"
+                    Background="Transparent" />
             </dragablz:TabablzControl.HeaderPrefixContent>
             <TabItem Name="HomeTabControlItem">
                 <TabItem.Header>
-                    <DockPanel VerticalAlignment="Center" Height="40">
-                        <TextBlock Text="Home"/>
-                    </DockPanel>
-                </TabItem.Header>
-                <TabItem.Content>
-                    <ContentControl Name="ViwerContent"/>
-                </TabItem.Content>
-            </TabItem>
-            <TabItem Name="Home1TabControlItem">
-                <TabItem.Header>
-                    <DockPanel VerticalAlignment="Center" Height="40">
-                        <TextBlock Text="Home"/>
+                    <DockPanel Height="40" VerticalAlignment="Center">
+                        <TextBlock Text="Home" />
                     </DockPanel>
                 </TabItem.Header>
                 <TabItem.Content>
-                    <ContentControl Name="ViwerContent1"/>
+                    <ContentControl prism:RegionManager.RegionName="ViwerRegion" />
                 </TabItem.Content>
             </TabItem>
         </dragablz:TabablzControl>
 
-        <!--标题栏右侧栏,关闭按钮,会员,试用等-->
-        <StackPanel Orientation="Horizontal" WindowChrome.IsHitTestVisibleInChrome="True" HorizontalAlignment="Right">
-            <Button Width="40" Height="40"  Content="--" Command="{x:Static SystemCommands.MinimizeWindowCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}" />
-            <Button Width="40" Height="40">
-            </Button>
-            <Button Width="40" Height="40" Content="X" Command="{x:Static SystemCommands.CloseWindowCommand}"/>
+        <!--  标题栏右侧栏,关闭按钮,会员,试用等  -->
+        <StackPanel
+            HorizontalAlignment="Right"
+            Orientation="Horizontal"
+            WindowChrome.IsHitTestVisibleInChrome="True">
+            <Button
+                Name="BtnMiniSize"
+                Width="40"
+                Height="40"
+                Click="BtnMiniSize_Click"
+                Content="--" />
+            <Button
+                Name="BtnReStore"
+                Width="40"
+                Height="40"
+                Click="BtnReStore_Click" />
+            <Button
+                Name="BtnClose"
+                Width="40"
+                Height="40"
+                Click="BtnClose_Click"
+                Content="X" />
         </StackPanel>
     </Grid>
 </Window>

+ 26 - 3
PDF Office/Views/MainWindow.xaml.cs

@@ -1,4 +1,5 @@
-using Prism.Regions;
+using PDF_Office.ViewModels;
+using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -21,13 +22,35 @@ namespace PDF_Office.Views
     /// </summary>
     public partial class MainWindow : Window
     {
+        public HomeContentViewModel HomeViewModel;
         public MainWindow(IRegionManager regionManager)
         {
             InitializeComponent();
+        }
+
+        private void BtnAdd_Click(object sender, RoutedEventArgs e)
+        {
+            TabItem tabItem = new TabItem();
+            tabItem.Header = "Test";
+            PDFViewerTab.Items.Add(tabItem);
+        }
+
+        private void BtnMiniSize_Click(object sender, RoutedEventArgs e)
+        {
+            System.Windows.SystemCommands.MinimizeWindow(this);
+        }
 
-            RegionManager.SetRegionName(ViwerContent,"ViwerContent");
+        private void BtnClose_Click(object sender, RoutedEventArgs e)
+        {
+            System.Windows.SystemCommands.CloseWindow(this);
+        }
 
-            regionManager.RegisterViewWithRegion("ViwerContent",typeof(HomeContent));
+        private void BtnReStore_Click(object sender, RoutedEventArgs e)
+        {
+            if (this.WindowState == WindowState.Maximized)
+                System.Windows.SystemCommands.RestoreWindow(this);
+            else
+                System.Windows.SystemCommands.MaximizeWindow(this);
         }
     }
 }

+ 38 - 19
PDF Office/Views/ViewContent.xaml

@@ -1,24 +1,43 @@
-<UserControl x:Class="PDF_Office.Views.ViewContent"
-             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:PDF_Office.Views"
-             mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
+<UserControl
+    x:Class="PDF_Office.Views.ViewContent"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:Viewer="clr-namespace:ComPDFKitViewer.PdfViewer;assembly=ComPDFKit.Viewer"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+    xmlns:local="clr-namespace:PDF_Office.Views"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:prism="http://prismlibrary.com/"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    prism:ViewModelLocator.AutoWireViewModel="True"
+    mc:Ignorable="d">
     <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition/>
-            <ColumnDefinition/>
-            <ColumnDefinition/>
-            <ColumnDefinition/>
-            <ColumnDefinition/>
-        </Grid.ColumnDefinitions> 
         <Grid.RowDefinitions>
-            <RowDefinition/>
-            <RowDefinition/>
-            <RowDefinition/>
-            <RowDefinition/>
+            <RowDefinition Name="HeadRow" Height="40" />
+            <RowDefinition Name="ToolRow" Height="40" />
+            <RowDefinition Height="*" />
         </Grid.RowDefinitions>
+        <Grid Name="DocumentView" Grid.Row="2">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition x:Name="BOTACloumn" Width="40" />
+                <ColumnDefinition Width="12" />
+                <ColumnDefinition
+                    Name="ViewerColumn"
+                    Width="*"
+                    MinWidth="200" />
+                <ColumnDefinition Width="12" />
+                <ColumnDefinition Name="PropertyColumn" Width="0" />
+            </Grid.ColumnDefinitions>
+            <Grid.RowDefinitions>
+                <RowDefinition Height="*" />
+                <RowDefinition Height="32" />
+            </Grid.RowDefinitions>
+            <ContentControl
+                x:Name="PDFViewerContent"
+                Grid.Column="2"
+                HorizontalAlignment="Stretch"
+                prism:RegionManager.RegionName="PDFViewer" />
+        </Grid>
     </Grid>
 </UserControl>

+ 11 - 1
PDF Office/Views/ViewContent.xaml.cs

@@ -1,4 +1,8 @@
-using System;
+using ComPDFKitViewer.PdfViewer;
+using Microsoft.Win32;
+using PDF_Office.ViewModels;
+using Prism.Regions;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -20,9 +24,15 @@ namespace PDF_Office.Views
     /// </summary>
     public partial class ViewContent : UserControl
     {
+        /// <summary>
+        /// 因为XAML自动匹配VM的形式,会出现VM已经初始化,但是容器尚未加载完成的情况,
+        /// 因此此处采用特殊的形式,通过后台代码绑定VM
+        /// </summary>
+        private ViewContentViewModel contentViewModel;
         public ViewContent()
         {
             InitializeComponent();
         }
+
     }
 }