Browse Source

内嵌文档-更新内嵌文档逻辑(文档待更新)

ZhouJieSheng 2 years ago
parent
commit
6375a68301

+ 3 - 0
PDF Office/App.config

@@ -36,6 +36,9 @@
       <setting name="IsNewUser" serializeAs="String">
         <value>True</value>
       </setting>
+      <setting name="IsGuidPDFUpdated" serializeAs="String">
+        <value>True</value>
+      </setting>
     </PDF_Office.Properties.Settings>
   </userSettings>
 </configuration>

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

@@ -71,6 +71,16 @@ namespace PDF_Office
     {
         public static string CurrentPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "PDF Office");
 
+        /// <summary>
+        /// 内嵌文档路径
+        /// </summary>
+        public static string GuidPDFPath = Path.Combine(Environment.CurrentDirectory, "Resources//GuidPDF//Quick Start Guide.pdf");
+
+        /// <summary>
+        /// 是否需要更新内嵌文档
+        /// </summary>
+        public static bool IsGuidPDFUpdated = false;
+
         /// <summary>
         /// 产品名称
         /// </summary>
@@ -130,8 +140,18 @@ namespace PDF_Office
 
         private void InitSettings()
         {
+
+            //是否是更新后
             if (Settings.Default.UpdateSettings)
             {
+                //内嵌文档更新时 显示文档到最前方
+                //每次版本更新留意检查IsGuidPDFUpdated 值,如果没有内嵌文档更新,要设为false
+                if (Settings.Default.IsGuidPDFUpdated && File.Exists(GuidPDFPath))
+                {
+                    App.IsGuidPDFUpdated = true;
+                    Settings.Default.IsGuidPDFUpdated = false;
+                }
+
                 Settings.Default.Upgrade();
                 Settings.Default.UpdateSettings = false;
                 App.IsShowRegist = true;
@@ -139,7 +159,9 @@ namespace PDF_Office
             }
 
             if (Settings.Default.RecentOpenFiles == null)
+            {
                 Settings.Default.RecentOpenFiles = new RecentOpenFiles();
+            }
 
             if (Settings.Default.RedactionsSettings == null)
                 Settings.Default.RedactionsSettings = new PDFSettings.RedactionSettings();
@@ -152,6 +174,11 @@ namespace PDF_Office
 
             if (Settings.Default.QuickPDFToolsList == null)
                 Settings.Default.QuickPDFToolsList = new PDFSettings.QuickPDFToolsList();
+
+            if(App.IsGuidPDFUpdated)
+            {
+                SettingHelper.SortRecentOpenFiles(GuidPDFPath);
+            }
         }
 
         protected override void OnStartup(StartupEventArgs e)

+ 2 - 1
PDF Office/Helper/SettingHelper.cs

@@ -48,8 +48,9 @@ namespace PDF_Office.Helper
             else
             {
                 OpenFileInfo fileInfo = new OpenFileInfo();
-                fileInfo.FileName = filePath.Substring(filePath.LastIndexOf("\\") + 1);
+                fileInfo.FileName = Path.GetFileName(filePath);
                 fileInfo.FilePath = filePath;
+                fileInfo.IsGuidPDF = string.Equals(filePath, App.GuidPDFPath);
                 fileInfo.ThumbImgPath = "";
                 fileInfo.LastOpenTime = DateTime.Now;
                 PDF_Office.Properties.Settings.Default.RecentOpenFiles.Insert(0, fileInfo);

+ 3 - 0
PDF Office/PDF Office.csproj

@@ -2153,6 +2153,9 @@
     <Content Include="ComDocumentAIKit.dll">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
+    <Content Include="Resources\GuidPDF\Quick Start Guide.pdf">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
     <None Include="source\models\OCR.model" />
     <Resource Include="Resources\ToolBarIcon\Scan\enhance.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>

+ 12 - 0
PDF Office/Properties/Settings.Designer.cs

@@ -248,5 +248,17 @@ namespace PDF_Office.Properties {
                 this["IsNewUser"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]
+        public bool IsGuidPDFUpdated {
+            get {
+                return ((bool)(this["IsGuidPDFUpdated"]));
+            }
+            set {
+                this["IsGuidPDFUpdated"] = value;
+            }
+        }
     }
 }

+ 3 - 0
PDF Office/Properties/Settings.settings

@@ -62,5 +62,8 @@
     <Setting Name="IsNewUser" Type="System.Boolean" Scope="User">
       <Value Profile="(Default)">True</Value>
     </Setting>
+    <Setting Name="IsGuidPDFUpdated" Type="System.Boolean" Scope="User">
+      <Value Profile="(Default)">True</Value>
+    </Setting>
   </Settings>
 </SettingsFile>

+ 5 - 1
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -815,7 +815,11 @@ namespace PDF_Office.ViewModels
             switch (args)
             {
                 case "Guid":
-                    //TODO 打开内嵌文档
+                    //打开内嵌文档
+                    if (File.Exists(App.GuidPDFPath))
+                    {
+                        App.mainWindowViewModel.AddTabItem(App.GuidPDFPath);
+                    }
                     break;
 
                 case "Online":

+ 34 - 19
PDF Office/Views/HomePanel/RecentFiles/DocItemControl.xaml

@@ -20,20 +20,20 @@
         </Grid.RowDefinitions>
         <Grid Height="165" Margin="51,16">
             <Border
-            BorderBrush="{StaticResource color.sys.layout.divider}"
-            BorderThickness="1"
-                VerticalAlignment="Center"
                 HorizontalAlignment="Center"
-            CornerRadius="{StaticResource border-radius.8}">
+                VerticalAlignment="Center"
+                BorderBrush="{StaticResource color.sys.layout.divider}"
+                BorderThickness="1"
+                CornerRadius="{StaticResource border-radius.8}">
                 <Grid>
                     <Border
-                    Name="BorderImage"
-                    Background="White"
-                    CornerRadius="{StaticResource border-radius.8}" />
+                        Name="BorderImage"
+                        Background="White"
+                        CornerRadius="{StaticResource border-radius.8}" />
                     <Image
-                    Name="CoverImage"
-                    RenderOptions.BitmapScalingMode="HighQuality"
-                    UseLayoutRounding="True">
+                        Name="CoverImage"
+                        RenderOptions.BitmapScalingMode="HighQuality"
+                        UseLayoutRounding="True">
                         <Image.OpacityMask>
                             <VisualBrush Visual="{Binding ElementName=BorderImage}" />
                         </Image.OpacityMask>
@@ -41,18 +41,33 @@
                 </Grid>
             </Border>
         </Grid>
-        <TextBlock
+        <StackPanel
             Grid.Row="1"
-            MaxWidth="226"
-            MaxHeight="44"
             Margin="0,0,0,8"
             HorizontalAlignment="Center"
-            VerticalAlignment="Top"
-            FontSize="14"
-            Text="{Binding FileName}"
-            TextTrimming="CharacterEllipsis"
-            TextWrapping="Wrap"
-            ToolTip="{Binding FileName}" />
+            VerticalAlignment="Center"
+            Orientation="Horizontal">
+            <Rectangle
+                Name="RecNewMark"
+                Width="4"
+                Height="4"
+                Margin="4,0"
+                Fill="{StaticResource color.btn.cta.bg.norm}"
+                RadiusX="4"
+                RadiusY="4"
+                Visibility="Collapsed" />
+            <TextBlock
+                Grid.Row="1"
+                MaxWidth="226"
+                MaxHeight="44"
+                HorizontalAlignment="Center"
+                VerticalAlignment="Top"
+                FontSize="14"
+                Text="{Binding FileName}"
+                TextTrimming="CharacterEllipsis"
+                TextWrapping="Wrap"
+                ToolTip="{Binding FileName}" />
+        </StackPanel>
     </Grid>
 
 </UserControl>

+ 6 - 0
PDF Office/Views/HomePanel/RecentFiles/DocItemControl.xaml.cs

@@ -36,6 +36,12 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
             {
                 var data = grid.DataContext as OpenFileInfo;
                 if (data == null) return;
+
+                if (data.IsGuidPDF && App.IsGuidPDFUpdated)
+                {
+                    RecNewMark.Visibility = Visibility.Visible;
+                }
+
                 if (!string.IsNullOrEmpty(data.ThumbImgPath))
                     CoverImage.Source = ToolMethod.GetFileThumbImg(data.ThumbImgPath);
                 else

+ 19 - 9
PDF Office/Views/HomePanel/RecentFiles/DocItemListViewControl.xaml

@@ -62,15 +62,25 @@
                         UseLayoutRounding="True" />
                 </Border>
                 <StackPanel Grid.Column="1" Margin="8,8,0,8">
-                    <TextBlock
-                        x:Name="FileName"
-                        Grid.Column="1"
-                        HorizontalAlignment="Stretch"
-                        VerticalAlignment="Center"
-                        FontSize="14"
-                        Foreground="{StaticResource color.sys.text.neutral.lv1}"
-                        Text="{Binding FileName}"
-                        TextTrimming="WordEllipsis" />
+                    <StackPanel Grid.Column="1" Orientation="Horizontal">
+                        <Rectangle
+                            Name="RecNewMark"
+                            Width="4"
+                            Height="4"
+                            Margin="4,0"
+                            Fill="{StaticResource color.btn.cta.bg.norm}"
+                            RadiusX="4"
+                            RadiusY="4"
+                            Visibility="Collapsed" />
+                        <TextBlock
+                            x:Name="FileName"
+                            HorizontalAlignment="Stretch"
+                            VerticalAlignment="Center"
+                            FontSize="14"
+                            Foreground="{StaticResource color.sys.text.neutral.lv1}"
+                            Text="{Binding FileName}"
+                            TextTrimming="WordEllipsis" />
+                    </StackPanel>
                     <TextBlock
                         Margin="0,4,0,0"
                         FontSize="14"

+ 5 - 0
PDF Office/Views/HomePanel/RecentFiles/DocItemListViewControl.xaml.cs

@@ -104,6 +104,11 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
                 var data = grid.DataContext as OpenFileInfo;
                 if (data == null) return;
 
+                //显示新文档符号
+                if (data.IsGuidPDF&& App.IsGuidPDFUpdated)
+                {
+                    RecNewMark.Visibility = Visibility.Visible;
+                }
 
                 if (File.Exists(data.ThumbImgPath))
                 {

+ 3 - 1
PDFSettings/RecentOpenFiles.cs

@@ -7,7 +7,7 @@ namespace PDFSettings.Settings
 {
     public class RecentOpenFiles : List<OpenFileInfo>
     {
-
+        
     }
 
     public class OpenFileInfo
@@ -32,5 +32,7 @@ namespace PDFSettings.Settings
 
         //用于记录显示的Color
         public Color LastFillBrushColor = Brushes.White.Color;
+
+        public bool IsGuidPDF { get; set; } = false;
     }
 }