Browse Source

其他-同步代码

liuaoran 2 years ago
parent
commit
1c1eb8b07f

+ 1 - 1
PDF Office/PDF Office.csproj

@@ -387,8 +387,8 @@
       <Generator>MSBuild:Compile</Generator>
     </Page>
     <Page Include="Views\ViewContent.xaml">
-      <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
     </Page>
   </ItemGroup>
   <ItemGroup>

+ 28 - 0
PDF Office/Styles/ToolsBtnStyle.xaml

@@ -0,0 +1,28 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style x:Key="ToolsBtnStyle" TargetType="{x:Type Button}">
+        <Setter Property="Background" Value="Transparent"/>
+        <Setter Property="BorderBrush" Value="Transparent"/>
+        <Setter Property="Width" Value="auto"/>
+        <Setter Property="Height" Value="40"/>
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type Button}">
+                    <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}"   Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
+                        <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="true">
+                            <Setter Property="Background" TargetName="border" Value="#1A000000"/>
+                            <Setter Property="BorderBrush" TargetName="border" Value= "gray"/>
+                        </Trigger>
+                        <Trigger Property="IsPressed" Value="true">
+                            <Setter Property="Background" TargetName="border" Value="#26000000"/>
+                            <Setter Property="BorderBrush" TargetName="border" Value= "gray"/>
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+</ResourceDictionary>

+ 22 - 0
PDF Office/Styles/ToolsMenuStyle.xaml

@@ -0,0 +1,22 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style x:Key="ToolsMenuStyle" TargetType="{x:Type MenuItem}">
+        <Setter Property="Background" Value="White"></Setter>
+        <Setter Property="Margin" Value="0,0,0,0"></Setter>
+        <Setter Property="Padding" Value="0,10,10,20"></Setter>
+            <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type MenuItem}">
+                    <Border Padding="17,0,17,0" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
+                        <ContentPresenter x:Name="ContentPresenter"  Content="{TemplateBinding Header}" Grid.Column="1" ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="True">
+                            <Setter Property="Background" Value="whitesmoke"/>
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+</ResourceDictionary>

+ 34 - 66
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -38,17 +38,8 @@ namespace PDF_Office.ViewModels
 
         public string ToolContentRegionName { get; set; }
 
-<<<<<<< Updated upstream
-=======
         public string ToolsBarContentRegionName { get; set; }
 
-        public DelegateCommand LoadFile { get; set; }
-
-        public DelegateCommand Load { get; set; }
-
-        public DelegateCommand<object> TabControlSelectionChangedCommand { get; set; }
-
->>>>>>> Stashed changes
 
 
         private int gridToolRow = 1;
@@ -91,7 +82,6 @@ namespace PDF_Office.ViewModels
             }
         }
 
-<<<<<<< Updated upstream
         private Visibility isLoading = Visibility.Collapsed;
         /// <summary>
         /// 是否正在加载中
@@ -104,7 +94,7 @@ namespace PDF_Office.ViewModels
                 SetProperty(ref isLoading, value);
             }
         }
-=======
+
         private Visibility toolsbarContentVisible = Visibility.Visible;
         /// <summary>
         /// 控制Content的显示
@@ -119,6 +109,7 @@ namespace PDF_Office.ViewModels
             }
         }
 
+
         private Dictionary<string, string> regionNameByTabItem;
 
         private Dictionary<string, string> barContentByTabItem;
@@ -126,7 +117,7 @@ namespace PDF_Office.ViewModels
         private string previousBar = "";
 
         private string currentBar = "";
->>>>>>> Stashed changes
+
 
 
         /// <summary>
@@ -140,7 +131,7 @@ namespace PDF_Office.ViewModels
         private double[] zoomLevel = { 1.00f, 10, 25, 50, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
         #endregion
 
-<<<<<<< Updated upstream
+
         #region 命令
         public DelegateCommand LoadFile { get; set; }
 
@@ -149,8 +140,6 @@ namespace PDF_Office.ViewModels
         public DelegateCommand<object> TabControlSelectionChangedCommand { get; set; }
         #endregion
 
-=======
->>>>>>> Stashed changes
         public ViewContentViewModel(IRegionManager regionManager, IDialogService dialogService)
         {
             region = regionManager;
@@ -163,11 +152,9 @@ namespace PDF_Office.ViewModels
             ViwerRegionName = Guid.NewGuid().ToString();
             BOTARegionName = Guid.NewGuid().ToString();
             PropertyRegionName = Guid.NewGuid().ToString();
-<<<<<<< Updated upstream
+
             //未显示时无法注册上Region名称
             ToolContentVisible = Visibility.Visible;
-=======
->>>>>>> Stashed changes
             ToolContentRegionName = Guid.NewGuid().ToString();
             ToolsBarContentRegionName = Guid.NewGuid().ToString();
 
@@ -220,29 +207,25 @@ namespace PDF_Office.ViewModels
             if (args != null)
             {
                 var item = args.AddedItems[0] as TabItem;
-<<<<<<< Updated upstream
-                if (item.Name == "TabItemPageEdit")
-                {
-                    EnterToolMode("PageEditContent");
-                }
-                else
-                {
-                    ExitToolMode();
-=======
                 currentBar = item.Name;
                 if (previousBar != currentBar)
                 {
-                    if (previousBar != ""&&(currentBar== "TabItemPageEdit"|| currentBar == "TabItemTool"))
+                    currentBar = item.Name;
+                    if (previousBar != currentBar)
                     {
-                            ExitPreview();
+                        if (previousBar != "" && (currentBar == "TabItemPageEdit" || currentBar == "TabItemTool"))
+                        {
+                            ExitToolMode();
+                        }
+                        if ((currentBar == "TabItemPageEdit" || currentBar == "TabItemTool"))
+                        {
+                            EnterSelectedBar(currentBar);
+                        }
+                        previousBar = currentBar;
+
                     }
-                    if ( (currentBar == "TabItemPageEdit" || currentBar == "TabItemTool"))
-                    {
-                        EnterSelectedBar(currentBar);
-                    }  
-                    previousBar = currentBar;
->>>>>>> Stashed changes
                 }
+
             }
         }
 
@@ -324,11 +307,7 @@ namespace PDF_Office.ViewModels
         private void ShowContent(string currentBar)
         {
             //显示页面编辑
-<<<<<<< Updated upstream
-            if (isPageEdit)
-=======
             if (currentBar == "TabItemPageEdit")
->>>>>>> Stashed changes
             {
                 if (GridToolRow != 1)
                 {
@@ -339,26 +318,22 @@ namespace PDF_Office.ViewModels
                 {
                     GridToolRowSpan = 3;
                 }
-<<<<<<< Updated upstream
-
-=======
                 ToolContentVisible = Visibility.Visible;
->>>>>>> Stashed changes
+                ToolContentVisible = Visibility.Visible;
             }
             else
             {
                 if (GridToolRow != 1)
                 {
                     GridToolRow = 1;
-                } 
+                }
                 ToolsBarContentVisible = Visibility.Visible;
             }
         }
 
         /// <summary>
         /// 进入工具编辑(如页面编辑、水印、密文等)模式
-        /// </summary>
-<<<<<<< Updated upstream
+        /// </summary> 
         /// <param name="targetToolMode">要导航过去的控件名称</param>
         /// <param name="valuePairs">导航需要传送的参数,为空时,默认传送PDFView和ViewContentViewModel</param>
         private async void EnterToolMode(string targetToolMode, NavigationParameters valuePairs = null)
@@ -376,36 +351,26 @@ namespace PDF_Office.ViewModels
                 param = valuePairs;
             }
             region.RequestNavigate(ToolContentRegionName, targetToolMode, param);
+            ShowContent(currentBar);
 
-            if (targetToolMode == "PageEditContent")
-            {
-                ShowToolContent();
-            }
-            else
-            {
-                ShowToolContent(false);
-            }
             IsLoading = Visibility.Collapsed;
-=======
+        }
+
         private void EnterSelectedBar(string currentBar)
-        { 
-                NavigationParameters param = new NavigationParameters();
-                param.Add(ParameterNames.PDFViewer, PDFViewer);
-                param.Add(ParameterNames.ViewContentViewModel, this);
-                region.RequestNavigate(regionNameByTabItem[currentBar], barContentByTabItem[currentBar], param);
-                ShowContent(currentBar);
->>>>>>> Stashed changes
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add(ParameterNames.ViewContentViewModel, this);
+            region.RequestNavigate(regionNameByTabItem[currentBar], barContentByTabItem[currentBar], param);
+            ShowContent(currentBar);
         }
 
         /// <summary>
         /// 退出工具(水印、密文等)编辑模式,隐藏ToolContent
         /// </summary>
-<<<<<<< Updated upstream
+
 
         public void ExitToolMode()
-=======
-        public void ExitPreview()
->>>>>>> Stashed changes
         {
             ToolContentVisible = Visibility.Collapsed;
             ToolsBarContentVisible = Visibility.Collapsed;
@@ -413,3 +378,6 @@ namespace PDF_Office.ViewModels
         #endregion
     }
 }
+
+
+

+ 2 - 3
PDF Office/Views/ViewContent.xaml

@@ -173,14 +173,13 @@
             prism:RegionManager.RegionName="{Binding ToolContentRegionName}"
             Visibility="{Binding ToolContentVisible}" />
 
-<<<<<<< Updated upstream
         <cus:LoadingControl Grid.RowSpan="3" Visibility="{Binding IsLoading}" />
-=======
+
         <ContentControl
             Name="ContentToolsBar"
             Grid.Row="{Binding GridToolRow}"
             prism:RegionManager.RegionName="{Binding ToolsBarContentRegionName}"
             Visibility="{Binding ToolsBarContentVisible}" />
->>>>>>> Stashed changes
+
     </Grid>
 </UserControl>

+ 2 - 20
PDF Office/Views/ViewContent.xaml.cs

@@ -1,26 +1,9 @@
-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;
-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;
+using System.Windows.Controls;
 
 namespace PDF_Office.Views
 {
     /// <summary>
-    /// ViewContent.xaml 的交互逻辑
+    /// Interaction logic for ViewContent
     /// </summary>
     public partial class ViewContent : UserControl
     {
@@ -28,6 +11,5 @@ namespace PDF_Office.Views
         {
             InitializeComponent();
         }
-
     }
 }