Преглед изворни кода

修复bug - 注释工具切换后为空状态,自动打开属性面板

chenrongqian@kdanmobile.com пре 1 година
родитељ
комит
fb81b772ee

+ 19 - 23
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -1,6 +1,7 @@
 using ComPDFKit.PDFAnnotation;
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
+using PDF_Office.CustomControl.CompositeControl;
 using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.AnnotPanel;
@@ -52,6 +53,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
     public class SharpsAnnotPropertyViewModel : BindableBase, INavigationAware
     {
         #region 属性
+        public List<ComboDataItem> ThicknessItems { get; protected set; }
+
         private AnnotCommon _basicVm = new AnnotCommon();
         public AnnotCommon BasicVm
         {
@@ -89,29 +92,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        private void UpdateDash(AnnotAttribEvent attribEvent)
-        {
-            if (Dash.Dashes != null && Dash.Dashes.Count > 0)
-            {
-
-                if (Dash.Dashes[0] == 0)
-                {
-                    attribEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Solid);
-                }
-                else
-                {
-                    attribEvent?.UpdateAttrib(AnnotAttrib.LineStyle, dash);
-                }
-
-            }
-            else
-            {
-                attribEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Solid);
-            }
-
-            attribEvent?.UpdateAnnot();
-        }
-
         #endregion
 
         public DelegateCommand<object> SelectedThickCommand { get; set; }
@@ -132,6 +112,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         {
             InitColorItems();
             InitFillColorItems();
+            InitThicknessItems();
 
             SharpsTypeCommand = new DelegateCommand<object>(SharpsType_Command);
             SelectedFillOpacityCommand = new DelegateCommand<object>(SelectedFillOpacity_Command);
@@ -145,6 +126,21 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             LineStyleCommand = new DelegateCommand<object>(LineStyle_Command);
         }
 
+        private void InitThicknessItems()
+        {
+            ThicknessItems = new List<ComboDataItem>();
+            ComboDataItem item = new ComboDataItem(1, "pt");
+            ThicknessItems.Add(item);
+            item = new ComboDataItem(2, "pt");
+            ThicknessItems.Add(item);
+            item = new ComboDataItem(4, "pt");
+            ThicknessItems.Add(item);
+            item = new ComboDataItem(6, "pt");
+            ThicknessItems.Add(item);
+            item = new ComboDataItem(8, "pt");
+            ThicknessItems.Add(item);
+        }
+
         private void InitColorItems()
         {
             BasicVm.ColorItems = AnnotColorList.GetColorList(ColorSelectorType.Border);

+ 3 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -363,6 +363,9 @@ namespace PDF_Office.ViewModels.Tools
                             GetSelectedAnnots(e);
                             SelectedSignature(e.AnnotItemsList);
                             CurrentSelectedAnnot = annot;
+
+                            if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty)
+                                ShowPropertyPanel(true);
                         }
                         else
                         {

+ 2 - 2
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Layout.cs

@@ -626,7 +626,7 @@ namespace PDF_Office.ViewModels.Tools
             pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
 
             menuItem = new MenuItem();
-            menuItem.Name = "FreeTextColor";
+            menuItem.Name = "FreeTextFillColor";
             menuItem.Header = "填充颜色";
             menuItem.Tag = "FillColor";
             pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
@@ -913,7 +913,7 @@ namespace PDF_Office.ViewModels.Tools
             pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
 
             menuItem = new MenuItem();
-            menuItem.Name = "StampExportPNG";
+            menuItem.Name = "StampExportPDF";
             menuItem.Header = "PDF";
             menuItem.Tag = "PDF";
             pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);

+ 2 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -172,6 +172,7 @@ namespace PDF_Office.ViewModels.Tools
                     BtnHandIsChecked = false;
                 }
 
+                PDFViewer.ClearSelectAnnots();
                 var tag = annotBtn.Tag.ToString();
                 FindAnnotTypeKey(tag, ref annotArgs);
 
@@ -656,6 +657,7 @@ namespace PDF_Office.ViewModels.Tools
                 PDFViewer.SetMouseMode(MouseModes.Scroll);
                 PDFViewer.ClearSelectAnnots();
                 StrAnnotToolChecked = "";
+                ShowPropertyPanel(false);
             }
             else if (KeyEventsHelper.IsModifierKey(ModifierKeys.Shift, Key.None))
             {

+ 1 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/SharpsAnnotProperty.xaml

@@ -259,7 +259,7 @@
 
             </Grid>
 
-            <CompositeControl:SlidComboControl x:Name="thickness" Margin="0,0,0,0" Value="{Binding  BasicVm.AnnotThickness,Mode=TwoWay}">
+            <CompositeControl:SlidComboControl x:Name="thickness" Margin="0,0,0,0"  ItemsSource="{Binding ThicknessItems}" Value="{Binding  BasicVm.AnnotThickness,Mode=TwoWay}">
                 <i:Interaction.Triggers>
                     <i:EventTrigger EventName="ValueChanged">
                         <i:InvokeCommandAction Command="{Binding SelectedThickCommand}" CommandParameter="{Binding ElementName=thickness,Path=Value}"/>

+ 1 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNotePopup.xaml

@@ -56,7 +56,7 @@
             </Style.Triggers>
         </Style>
     </annotview:StickyPopupExt.Resources>
-    <Grid MouseLeftButtonDown="Grid_MouseLeftButtonDown">
+    <Grid MouseLeftButtonDown="Grid_MouseLeftButtonDown" DataContext="{x:Null}">
         <Border
             x:Name="border"
             Width="240"

+ 1 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNotePopup.xaml.cs

@@ -88,7 +88,7 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             if (ui != null)
             {
                 var colorItem = ui.DataContext as ColorItem;
-                if (colorItem != null)
+                if (colorItem != null || ui.DataContext == null)
                 {
                     e.Handled = false;
                     return;