Procházet zdrojové kódy

注释-链接-UI优化

OYXH\oyxh před 2 roky
rodič
revize
1953747339

+ 1 - 1
PDF Office/CustomControl/TextBoxWithTip.xaml

@@ -43,4 +43,4 @@
             </Setter>
         </Style>
     </UserControl.Style>
-</UserControl>
+</UserControl>

+ 4 - 20
PDF Office/CustomControl/TextBoxWithTip.xaml.cs

@@ -26,8 +26,6 @@ namespace PDF_Office.CustomControl
             InitializeComponent();
         }
 
-
-
         public string TipText
         {
             get { return (string)GetValue(TipTextProperty); }
@@ -38,8 +36,6 @@ namespace PDF_Office.CustomControl
         public static readonly DependencyProperty TipTextProperty =
             DependencyProperty.Register("TipText", typeof(string), typeof(TextBoxWithTip), new PropertyMetadata(""));
 
-
-
         public Visibility ShowTip
         {
             get { return (Visibility)GetValue(ShowTipProperty); }
@@ -50,9 +46,6 @@ namespace PDF_Office.CustomControl
         public static readonly DependencyProperty ShowTipProperty =
             DependencyProperty.Register("ShowTip", typeof(Visibility), typeof(TextBoxWithTip), new PropertyMetadata(Visibility.Hidden));
 
-
-
-
         public string Text
         {
             get { return (string)GetValue(TextProperty); }
@@ -63,19 +56,15 @@ namespace PDF_Office.CustomControl
         public static readonly DependencyProperty TextProperty =
             DependencyProperty.Register("Text", typeof(string), typeof(TextBoxWithTip), new PropertyMetadata(null));
 
-
-
-        public string  PlaceHoldText
+        public string PlaceHoldText
         {
-            get { return (string )GetValue(PlaceHoldTextProperty); }
+            get { return (string)GetValue(PlaceHoldTextProperty); }
             set { SetValue(PlaceHoldTextProperty, value); }
         }
 
         // Using a DependencyProperty as the backing store for PlaceHoldText.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty PlaceHoldTextProperty =
-            DependencyProperty.Register("PlaceHoldText", typeof(string ), typeof(TextBoxWithTip), new PropertyMetadata(""));
-
-
+            DependencyProperty.Register("PlaceHoldText", typeof(string), typeof(TextBoxWithTip), new PropertyMetadata(""));
 
         public bool IsError
         {
@@ -86,10 +75,5 @@ namespace PDF_Office.CustomControl
         // Using a DependencyProperty as the backing store for IsError.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty IsErrorProperty =
             DependencyProperty.Register("IsError", typeof(bool), typeof(TextBoxWithTip), new PropertyMetadata(false));
-
-
-
-
-
     }
-}
+}

+ 28 - 6
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -64,6 +64,20 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        private string pageNumTextContent = "Enter target page";
+
+        public string PageNumTextContent
+        {
+            get
+            {
+                return pageNumTextContent;
+            }
+            set
+            {
+                SetProperty(ref pageNumTextContent, value);
+            }
+        }
+
         private WriteableBitmap previewImage;
 
         public WriteableBitmap PreviewImage
@@ -135,13 +149,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         private void ToggleButtonTabSelected(object obj)
         {
+            if (obj is object[] array)
+            {
+            }
         }
 
         private void PageNumTextChanged(object obj)
         {
             if (obj is TextChangedEventArgs textChangedEventArgs)
             {
-                if (textChangedEventArgs.Source is TextBoxEx textBox)
+                if (textChangedEventArgs.Source is TextBoxWithTip textBox)
                 {
                     int pageNum = -1;
                     if (CheckPageNumVaild(out pageNum, textBox))
@@ -156,7 +173,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        private bool CheckPageNumVaild(out int pageNum, TextBoxEx textBox)
+        private bool CheckPageNumVaild(out int pageNum, TextBoxWithTip textBox)
         {
             pageNum = -1;
             ErrorNumTipsVisibility = Visibility.Collapsed;
@@ -172,8 +189,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 {
                     //ErrorNumTipsVisibility = Visibility.Visible;
                     //ErrorRangeTipsVisibility = Visibility.Collapsed;
-                    textBox.ShowTip = true;
-                    textBox.ShowTipText = Visibility.Visible;
+                    textBox.IsError = true;
+                    textBox.ShowTip = Visibility.Visible;
                     textBox.TipText = " Page number error.";
                     return false;
                 }
@@ -182,11 +199,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 //ErrorNumTipsVisibility = Visibility.Collapsed;
                 //ErrorRangeTipsVisibility = Visibility.Visible;
-                textBox.ShowTip = true;
-                textBox.ShowTipText = Visibility.Visible;
+                textBox.IsError = true;
+                textBox.ShowTip = Visibility.Visible;
                 textBox.TipText = "  Page number out of range.";
                 return false;
             }
+            else
+            {
+                textBox.IsError = false;
+                textBox.ShowTip = Visibility.Collapsed;
+            }
             BtnGOorBackVisibility = Visibility.Visible;
             return true;
         }

+ 64 - 38
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml

@@ -21,9 +21,13 @@
     mc:Ignorable="d">
     <UserControl.Resources>
         <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="pack://application:,,,/Styles/RadioButtonStyle.xaml" />
+            </ResourceDictionary.MergedDictionaries>
             <Convert:ObjectConvert x:Key="ObjectConvert" />
             <Convert:StringToVisibleConvert x:Key="StringToVisibleConvert" />
             <Convert:StringToUnVisibleConvert x:Key="StringToUnVisibleConvert" />
+            <Convert:BoolToVisible x:Key="BoolToVisible" />
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid>
@@ -42,25 +46,27 @@
                 Name="ToggleButtonTab"
                 Margin="12,0,0,0"
                 Orientation="Horizontal">
-                <ToggleButton
+                <RadioButton
                     Name="LinkPageBtn"
                     Width="75"
                     Height="28"
                     VerticalContentAlignment="Center"
-                    Background="Transparent"
-                    BorderThickness="0"
                     Command="{Binding ToggleButtonTabCommand}"
+                    GroupName="LinkTab"
                     IsChecked="True"
+                    Style="{StaticResource PageViewRadioBtn}"
                     Tag="Page">
-                    <ToggleButton.CommandParameter>
-                        <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
-                            <MultiBinding.Bindings>
-                                <Binding ElementName="LinkPageBtn" />
-                                <Binding ElementName="LinkPageBtn" />
-                                <Binding ElementName="LinkPageBtn" />
-                            </MultiBinding.Bindings>
-                        </MultiBinding>
-                    </ToggleButton.CommandParameter>
+                    <!--<ToggleButton.CommandParameter>
+                    <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
+                    <MultiBinding.Bindings>
+                    <Binding ElementName="LinkPageBtn" />
+                    -->
+                    <!--<Binding ElementName="LinkWebBtn" />
+                    <Binding ElementName="LinkMailBtn" />-->
+                    <!--
+                    </MultiBinding.Bindings>
+                    </MultiBinding>
+                    </ToggleButton.CommandParameter>-->
                     <StackPanel>
                         <Path
                             Margin="8,8,8,8"
@@ -84,16 +90,18 @@
                             TextAlignment="Center"
                             TextWrapping="Wrap" />
                     </StackPanel>
-                </ToggleButton>
+                </RadioButton>
 
-                <ToggleButton
+                <RadioButton
                     Name="LinkWebBtn"
                     Width="75"
                     Height="28"
                     VerticalContentAlignment="Center"
                     Background="Transparent"
-                    BorderThickness="0"
                     Command="{Binding ToggleButtonTabCommand}"
+                    GroupName="LinkTab"
+                    IsChecked="False"
+                    Style="{StaticResource PageViewRadioBtn}"
                     Tag="Web">
                     <StackPanel>
                         <Path
@@ -123,16 +131,18 @@
                             </Path.Data>
                         </Path>
                     </StackPanel>
-                </ToggleButton>
+                </RadioButton>
 
-                <ToggleButton
+                <RadioButton
                     Name="LinkMailBtn"
                     Width="75"
                     Height="28"
                     VerticalContentAlignment="Center"
                     Background="Transparent"
-                    BorderThickness="0"
                     Command="{Binding ToggleButtonTabCommand}"
+                    GroupName="LinkTab"
+                    IsChecked="False"
+                    Style="{StaticResource PageViewRadioBtn}"
                     Tag="Mail">
                     <StackPanel>
                         <Path
@@ -147,7 +157,7 @@
                             </Path.Data>
                         </Path>
                     </StackPanel>
-                </ToggleButton>
+                </RadioButton>
             </StackPanel>
             <Line
                 Width="232"
@@ -160,7 +170,7 @@
                 Y1="0"
                 Y2="0" />
             <Grid MinWidth="260">
-                <StackPanel Name="LinkPagePanel" Visibility="Visible">
+                <StackPanel Name="LinkPagePanel" Visibility="{Binding ElementName=LinkPageBtn, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
                     <TextBlock
                         x:Name="TxtPage"
                         Height="20"
@@ -172,19 +182,35 @@
                         Text="Page" />
                     <StackPanel Orientation="Horizontal">
                         <Grid>
-                            <CustomControl:TextBoxEx
+                            <!--<CustomControl:TextBoxEx
+                            x:Name="PageNumText"
+                            Width="228"
+                            Height="32"
+                            Margin="16,0"
+                            VerticalContentAlignment="Center"
+                            IsEnabled="False"
+                            PlaceholderText="Enter target page">
+                            <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="TextChanged">
+                            <i:InvokeCommandAction Command="{Binding PageNumTextChangedCommand}" PassEventArgsToCommand="True" />
+                            </i:EventTrigger>
+                            </i:Interaction.Triggers>
+                            </CustomControl:TextBoxEx>-->
+                            <CustomControl:TextBoxWithTip
                                 x:Name="PageNumText"
                                 Width="228"
-                                Height="32"
                                 Margin="16,0"
                                 VerticalContentAlignment="Center"
-                                PlaceholderText="Enter target page">
+                                IsEnabled="False"
+                                ShowTip="Collapsed"
+                                Text="Enter target page"
+                                TipText=" Page number error.">
                                 <i:Interaction.Triggers>
                                     <i:EventTrigger EventName="TextChanged">
                                         <i:InvokeCommandAction Command="{Binding PageNumTextChangedCommand}" PassEventArgsToCommand="True" />
                                     </i:EventTrigger>
                                 </i:Interaction.Triggers>
-                            </CustomControl:TextBoxEx>
+                            </CustomControl:TextBoxWithTip>
                             <!--<Border
                             Name="BorderPageNumText"
                             Width="228"
@@ -254,20 +280,20 @@
                         LineHeight="20"
                         TextAlignment="Center" />-->
                     </StackPanel>
-                    <TextBlock
-                        Name="ErrorNumTips"
-                        Margin="12,0,0,0"
-                        Foreground="Red"
-                        Visibility="{Binding ErrorNumTipsVisibility}">
-                        Page number error.
+                    <!--<TextBlock
+                    Name="ErrorNumTips"
+                    Margin="12,0,0,0"
+                    Foreground="Red"
+                    Visibility="{Binding ErrorNumTipsVisibility}">
+                    Page number error.
                     </TextBlock>
                     <TextBlock
-                        Name="ErrorRangeTips"
-                        Margin="12,0,0,0"
-                        Foreground="Red"
-                        Visibility="{Binding ErrorRangeTipsVisibility}">
-                        Page number out of range.
-                    </TextBlock>
+                    Name="ErrorRangeTips"
+                    Margin="12,0,0,0"
+                    Foreground="Red"
+                    Visibility="{Binding ErrorRangeTipsVisibility}">
+                    Page number out of range.
+                    </TextBlock>-->
                     <Button
                         Name="BtnLocation"
                         Width="228"
@@ -295,7 +321,7 @@
                         Source="{Binding PreviewImage}"
                         Visibility="{Binding ImagePreviewVisibility}" />
                 </StackPanel>
-                <StackPanel Name="LinkWebPanel" Visibility="Collapsed">
+                <StackPanel Name="LinkWebPanel" Visibility="{Binding ElementName=LinkWebBtn, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
                     <TextBlock
                         Height="20"
                         Margin="16,12,0,4"
@@ -365,7 +391,7 @@
                         Invalid link.
                     </TextBlock>
                 </StackPanel>
-                <StackPanel Name="LinkMailPanel" Visibility="Collapsed">
+                <StackPanel Name="LinkMailPanel" Visibility="{Binding ElementName=LinkMailBtn, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
                     <TextBlock
                         Height="20"
                         Margin="12,12,0,4"

+ 4 - 2
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml.cs

@@ -40,12 +40,14 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             if (PageNumText.IsEnabled == true)
             {
                 //defaultPageNumText.Text = string.Format($"1-{totalPage}页");
-                PageNumText.PlaceholderText = string.Format($"1-{totalPage}页");
+                //PageNumText.PlaceholderText = string.Format($"1-{totalPage}页");
+                PageNumText.PlaceHoldText = string.Format($"1-{totalPage}页");
             }
             else
             {
                 //defaultPageNumText.Text = "Enter target page";
-                PageNumText.PlaceholderText = "Enter target page";
+                //PageNumText.PlaceholderText = "Enter target page";
+                PageNumText.PlaceHoldText = "Enter target page";
             }
             PageNumText.IsError = false;
             //BorderPageNumText.Background = enable ? Brushes.White : Brushes.LightGray;