Browse Source

偏好设置UI

OYXH\oyxh 2 years ago
parent
commit
d1bc3b2445

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

@@ -312,6 +312,7 @@ namespace PDF_Office
             containerRegistry.RegisterDialog<MarkSettingDialog>(DialogNames.MarkSettingDialog);
             containerRegistry.RegisterDialog<PageMarkDialog>(DialogNames.PageMarkDialog);
             containerRegistry.RegisterDialog<RepeatMarkDialog>(DialogNames.RepeatMarkDialog);
+            containerRegistry.RegisterDialog<InfoDialog>(DialogNames.InfoDialog);
 
             #endregion 注册弹窗
         }

+ 18 - 28
PDF Office/CustomControl/NumericUpDown.xaml

@@ -15,7 +15,11 @@
                 <ColumnDefinition Width="*" />
                 <ColumnDefinition Width="auto" />
             </Grid.ColumnDefinitions>
-            <Border BorderBrush="{StaticResource color.field.border.norm}" BorderThickness="1,1,0,1" CornerRadius="4,0,0,4" Background="{StaticResource color.field.bg.def}"></Border>
+            <Border
+                Background="{StaticResource color.field.bg.def}"
+                BorderBrush="{StaticResource color.field.border.norm}"
+                BorderThickness="1,1,0,1"
+                CornerRadius="4,0,0,4" />
             <TextBox
                 Name="TextBox_Num"
                 MinWidth="80"
@@ -31,24 +35,20 @@
                 PreviewTextInput="CountTextBox_PreviewTextInput"
                 Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:NumericUpDown}, Path=Text}"
                 TextAlignment="Left"
-                TextChanged="TextBox_Num_TextChanged">
-                <!--<TextBox.Template>
-                <ControlTemplate TargetType="{x:Type TextBox}">
-                <Border BorderBrush="{StaticResource color.field.border.norm}" BorderThickness="1,1,0,1" CornerRadius="4,0,0,4" Background="{StaticResource color.field.bg.def}">
-                <ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />
-                </Border>
-                </ControlTemplate>
-                </TextBox.Template>-->
-            </TextBox>
+                TextChanged="TextBox_Num_TextChanged" />
             <Grid Grid.Column="1" Width="16">
                 <Grid.RowDefinitions>
                     <RowDefinition />
                     <RowDefinition />
                 </Grid.RowDefinitions>
-                <Border  Grid.Row="0" BorderBrush="{StaticResource color.field.border.norm}" BorderThickness="1,1,1,0.5" CornerRadius="0,4,0,0" Background="{StaticResource color.field.bg.def}">
+                <Border
+                    Grid.Row="0"
+                    Background="{StaticResource color.field.bg.def}"
+                    BorderBrush="{StaticResource color.field.border.norm}"
+                    BorderThickness="1,1,1,0.5"
+                    CornerRadius="0,4,0,0">
                     <Button
                         Name="Button_Add"
-
                         Background="Transparent"
                         BorderBrush="Transparent"
                         BorderThickness="0"
@@ -59,19 +59,16 @@
                             Fill="{StaticResource color.icon.arrow.gray.def}"
                             Stretch="Uniform"
                             Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:NumericUpDown}, Path=ShowBtn}" />
-                        <!--<Button.Template>
-                        <ControlTemplate TargetType="{x:Type Button}">
-                        <Border BorderBrush="{StaticResource color.field.border.norm}" BorderThickness="1,1,1,0.5" CornerRadius="0,4,0,0" Background="{StaticResource color.field.bg.def}">
-                        <ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />
-                        </Border>
-                        </ControlTemplate>
-                        </Button.Template>-->
                     </Button>
                 </Border>
-                <Border  Grid.Row="1" BorderBrush="{StaticResource color.field.border.norm}" BorderThickness="1,0.5,1,1" CornerRadius="0,0,4,0" Background="{StaticResource color.field.bg.def}">
+                <Border
+                    Grid.Row="1"
+                    Background="{StaticResource color.field.bg.def}"
+                    BorderBrush="{StaticResource color.field.border.norm}"
+                    BorderThickness="1,0.5,1,1"
+                    CornerRadius="0,0,4,0">
                     <Button
                         Name="Button_Sub"
-
                         Background="Transparent"
                         BorderThickness="00"
                         Click="Button_Sub_Click">
@@ -80,13 +77,6 @@
                             Fill="{StaticResource color.icon.arrow.gray.def}"
                             Stretch="Uniform"
                             Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:NumericUpDown}, Path=ShowBtn}" />
-                        <!--<Button.Template>
-                        <ControlTemplate TargetType="{x:Type Button}">
-                        <Border BorderBrush="{StaticResource color.field.border.norm}" BorderThickness="1,0.5,1,1" CornerRadius="0,0,4,0" Background="{StaticResource color.field.bg.def}">
-                        <ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />
-                        </Border>
-                        </ControlTemplate>
-                        </Button.Template>-->
                     </Button>
                 </Border>
             </Grid>

+ 1 - 1
PDF Office/DataConvert/BoolToBrushConvert.cs

@@ -17,7 +17,7 @@ namespace PDF_Office.DataConvert
             {
                 if (flag)
                 {
-                    Color color = (Color)App.Current.FindResource("color.sys.text.accent.norm");
+                    //Color color = (Color)App.Current.FindResource("color.sys.text.accent.norm");
                     return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#1770F4"));
                     //return new SolidColorBrush(color);
                 }

+ 5 - 0
PDF Office/Model/DialogNames.cs

@@ -11,6 +11,11 @@ namespace PDF_Office.Model
     /// </summary>
     public static class DialogNames
     {
+        /// <summary>
+        /// 偏好设置
+        /// </summary>
+        public static string InfoDialog = "InfoDialog";
+
         /// <summary>
         /// 文档解密弹窗 需要传参PDFDocument对象
         /// </summary>

+ 1 - 0
PDF Office/PDF Office.csproj

@@ -401,6 +401,7 @@
       <AutoGen>True</AutoGen>
     </Compile>
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\CreateFromHtmlDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\InfoDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\Redaction\MarkSettingDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\Redaction\PageMarkDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\Redaction\RepeatMarkDialogViewModel.cs" />

+ 30 - 0
PDF Office/ViewModels/Dialog/InfoDialogViewModel.cs

@@ -0,0 +1,30 @@
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.Dialog
+{
+    internal class InfoDialogViewModel : BindableBase, IDialogAware
+    {
+        public string Title => "";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+        }
+    }
+}

+ 19 - 7
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -441,6 +441,8 @@ namespace PDF_Office.ViewModels
 
         public DelegateCommand PrintCommand { get; set; }
 
+        public DelegateCommand SettingsCommand { get; set; }
+
         #endregion 命令
 
         public ViewContentViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator)
@@ -468,6 +470,7 @@ namespace PDF_Office.ViewModels
 
             PrintCommand = new DelegateCommand(ShowPrintDialog);
 
+            SettingsCommand = new DelegateCommand(SettingsEvent);
             //未显示时无法注册上Region名称
             ToolContentVisible = Visibility.Visible;
             ToolsBarContentVisible = Visibility.Visible;
@@ -493,6 +496,15 @@ namespace PDF_Office.ViewModels
             EnterSelectedBar("TabItemAnnotation");
         }
 
+        private void SettingsEvent()
+        {
+            DialogParameters value = new DialogParameters();
+            value.Add(ParameterNames.PDFViewer, PDFViewer);
+            value.Add(ParameterNames.ViewContentViewModel, this);
+            dialogs.ShowDialog(DialogNames.InfoDialog, value, e =>
+            {
+            });
+        }
 
         private bool CanSaveExcute()
         {
@@ -1010,7 +1022,7 @@ namespace PDF_Office.ViewModels
         /// <summary>
         /// 另存为或新文档保存逻辑
         /// </summary>
-        public bool saveAsFile(bool isApplyRedaction = false,bool isEraseRedaction = false)
+        public bool saveAsFile(bool isApplyRedaction = false, bool isEraseRedaction = false)
         {
             var dlg = new SaveFileDialog();
             dlg.Filter = Properties.Resources.OpenDialogFilter;
@@ -1030,7 +1042,7 @@ namespace PDF_Office.ViewModels
                     }
                     catch { }
                 }
-                else if(isEraseRedaction)
+                else if (isEraseRedaction)
                 {
                     EraseReadction();
                 }
@@ -1061,17 +1073,17 @@ namespace PDF_Office.ViewModels
 
         private void EraseReadction()
         {
-            for(int i=0;i<PDFViewer.Document.PageCount;i++)
+            for (int i = 0; i < PDFViewer.Document.PageCount; i++)
             {
                 //获取页面Page对象
                 var page = PDFViewer.Document.PageAtIndex(i);
-                var annots = PDFViewer.GetAnnotCommentList(i,PDFViewer.Document);
+                var annots = PDFViewer.GetAnnotCommentList(i, PDFViewer.Document);
                 //循环擦除当前页的标记密文
                 for (int j = 0; j < annots.Count; j++)
-                { 
-                    if(annots[j].EventType == AnnotArgsType.AnnotRedaction)
+                {
+                    if (annots[j].EventType == AnnotArgsType.AnnotRedaction)
                     {
-                        foreach(var rect in (annots[j] as RedactionAnnotArgs).QuardRects)
+                        foreach (var rect in (annots[j] as RedactionAnnotArgs).QuardRects)
                         {
                             page.ErasureRedaction(rect);
                         }

+ 36 - 5
PDF Office/Views/Dialog/InfoDialog.xaml

@@ -5,10 +5,14 @@
     xmlns:cus="clr-namespace:PDF_Office.CustomControl"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:dataconvert="clr-namespace:PDF_Office.DataConvert"
+    xmlns:dialog="clr-namespace:PDF_Office.ViewModels.Dialog"
     xmlns:local="clr-namespace:PDF_Office.Views.Dialog"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:prism="http://prismlibrary.com/"
+    d:DataContext="{d:DesignInstance Type=dialog:InfoDialogViewModel}"
     d:DesignHeight="600"
     d:DesignWidth="700"
+    prism:ViewModelLocator.AutoWireViewModel="True"
     mc:Ignorable="d">
     <UserControl.Resources>
         <dataconvert:BoolToBrushConvert x:Key="BoolToBrushConvert" />
@@ -20,8 +24,12 @@
             <Setter Property="Foreground" Value="{StaticResource color.sys.text.neutral.lv1}" />
             <Setter Property="VerticalAlignment" Value="Center" />
         </Style>
+        <Style x:Key="RadioButton" TargetType="RadioButton">
+            <Setter Property="Foreground" Value="{StaticResource color.sys.text.neutral.lv1}" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+        </Style>
     </UserControl.Resources>
-    <Grid>
+    <Grid Width="700" Height="600">
         <Grid.RowDefinitions>
             <RowDefinition Height="40" />
             <RowDefinition />
@@ -72,6 +80,7 @@
                                     Width="120"
                                     HorizontalAlignment="Left"
                                     BorderThickness="0"
+                                    FontSize="14"
                                     Foreground="{StaticResource color.sys.text.neutral.lv1}"
                                     Text="20" />
                                 <TextBlock
@@ -86,6 +95,7 @@
                                     Width="120"
                                     HorizontalAlignment="Left"
                                     BorderThickness="0"
+                                    FontSize="14"
                                     Foreground="{StaticResource color.sys.text.neutral.lv1}"
                                     Text="10" />
                                 <Label
@@ -98,10 +108,31 @@
                                     Foreground="{StaticResource color.sys.text.neutral.lv3}"
                                     Text="5 to 99" />
                             </StackPanel>
-                            <StackPanel Margin="8" Orientation="Horizontal">
-                                <Label Content="关闭文档:" Style="{StaticResource Label}" />
-                                <RadioButton Content="弹出“保存/不保存”提示" />
-                            </StackPanel>
+                            <Grid Margin="8">
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition Width="64" />
+                                    <ColumnDefinition />
+                                </Grid.ColumnDefinitions>
+                                <Grid.RowDefinitions>
+                                    <RowDefinition />
+                                    <RowDefinition />
+                                </Grid.RowDefinitions>
+                                <Label
+                                    Grid.Row="0"
+                                    Grid.Column="0"
+                                    Content="关闭文档:"
+                                    Style="{StaticResource Label}" />
+                                <RadioButton
+                                    Grid.Row="0"
+                                    Grid.Column="1"
+                                    Content="弹出“保存/不保存”提示"
+                                    Style="{StaticResource RadioButton}" />
+                                <RadioButton
+                                    Grid.Row="1"
+                                    Grid.Column="1"
+                                    Content="无提示,直接保存"
+                                    Style="{StaticResource RadioButton}" />
+                            </Grid>
                         </StackPanel>
                     </StackPanel>
                 </ScrollViewer>

+ 4 - 1
PDF Office/Views/ViewContent.xaml

@@ -93,7 +93,10 @@
                             <MenuItem Header="Share" />
                             <MenuItem Header="Print" />
                             <Separator Margin="8,0" Style="{StaticResource HorizontalSeparatorStyle}" />
-                            <MenuItem Header="Settings" InputGestureText="Ctrl+P" />
+                            <MenuItem
+                                Command="{Binding SettingsCommand}"
+                                Header="Settings"
+                                InputGestureText="Ctrl+P" />
                             <MenuItem Header="Help" />
                         </ContextMenu>
                     </Button.ContextMenu>