Browse Source

注释 - 优化手绘,文字字体样式,选中注释

chenrongqian@kdanmobile.com 2 years ago
parent
commit
17c8e0659f

+ 20 - 1
PDF Office/CustomControl/CompositeControl/SlidComboControl.xaml.cs

@@ -122,7 +122,6 @@ namespace PDF_Office.CustomControl.CompositeControl
         }
         public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(double), typeof(SlidComboControl), new PropertyMetadata(1.0, SelectedValuePropertyChanged));
-       
         private static void SelectedValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
             var control = d as SlidComboControl;
@@ -134,6 +133,26 @@ namespace PDF_Office.CustomControl.CompositeControl
             }
         }
 
+        public List<ComboDataItem> ItemsSource
+        {
+            get { return (List<ComboDataItem>)GetValue(ItemsSourceProperty); }
+            set { SetValue(ItemsSourceProperty, value); }
+        }
+        public static readonly DependencyProperty ItemsSourceProperty =
+           DependencyProperty.Register("ItemsSource", typeof(List<ComboDataItem>), typeof(SlidComboControl), new PropertyMetadata(null, SelectedItemsSourcePropertyChanged));
+
+
+        private static void SelectedItemsSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            var control = d as SlidComboControl;
+            var value = (List<ComboDataItem>)e.NewValue;
+            if (control != null && value != null)
+            {
+                control.SetItemSource(value);
+
+            }
+        }
+
         private void ThicknessSlider_PreviewMouseMove(object sender, MouseEventArgs e)
         {
             if(e.LeftButton == MouseButtonState.Pressed)

+ 1 - 1
PDF Office/Model/PropertyPanel/AnnotPanel/FontStyleItem.cs

@@ -131,7 +131,7 @@ namespace PDF_Office.Model.PropertyPanel.AnnotPanel
         }
 
         //获取拟定的预设样式
-        private static List<PresetFontItem> GetPresetFontStyle()
+        public static List<PresetFontItem> GetPresetFontStyle()
         {
             List<PresetFontItem> fontStyleList = new List<PresetFontItem>();
             PresetFontItem custom = new PresetFontItem();

+ 34 - 0
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreehandAnnotPropertyViewModel.cs

@@ -1,5 +1,6 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
+using PDF_Office.CustomControl.CompositeControl;
 using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.PropertyPanel.AnnotPanel;
@@ -41,6 +42,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
     public class FreehandAnnotPropertyViewModel : BindableBase, INavigationAware
     {
         #region 属性
+        //手绘画笔橡皮擦的大小列表
+        public List<ComboDataItem> PenSizeItems { get; protected set; }
+        public List<ComboDataItem> EraserSizeItems { get; protected set; }
 
         private AnnotBasePropertyVM _basicVm = new AnnotBasePropertyVM();
         public AnnotBasePropertyVM BasicVm
@@ -93,7 +97,37 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         private void InitVariable()
         {
+            InitPenSizeItems();
+            InitEraserSizeItems();
+        }
 
+        private void InitPenSizeItems()
+        {
+            PenSizeItems = new List<ComboDataItem>();
+            ComboDataItem item = new ComboDataItem(1, "pt");
+            PenSizeItems.Add(item);
+            item = new ComboDataItem(2, "pt");
+            PenSizeItems.Add(item);
+            item = new ComboDataItem(4, "pt");
+            PenSizeItems.Add(item);
+            item = new ComboDataItem(6, "pt");
+            PenSizeItems.Add(item);
+            item = new ComboDataItem(8, "pt");
+            PenSizeItems.Add(item);
+        }
+
+        private void InitEraserSizeItems()
+        {
+            EraserSizeItems = new List<ComboDataItem>();
+            ComboDataItem item = new ComboDataItem(5, "pt");
+            EraserSizeItems.Add(item);
+            item = new ComboDataItem(10, "pt");
+            EraserSizeItems.Add(item);
+            item = new ComboDataItem(15, "pt");
+            EraserSizeItems.Add(item);
+            item = new ComboDataItem(20, "pt");
+            EraserSizeItems.Add(item);
+          
         }
 
         //设置颜色

+ 28 - 4
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -346,14 +346,18 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public List<PresetFontItem> FontStyleList = new List<PresetFontItem>();
         private void ReDefineFontStyle()
         {
-            var item = FontStyleList.FirstOrDefault(temp => temp.mTag == FontVm.CurrentPresetFont.ValueStr);
+            
+            var item = FontVm.PresetFontList.FirstOrDefault(temp => temp.mTag == FontVm.CurrentPresetFont.ValueStr);
+            if (item == null) return;
 
-            if (FontVm.CurrentFontFamily.ValueStr == "Bold")
+            item.mFontFamily = new FontFamily(FontVm.CurrentFontFamily.ValueStr);
+
+            if (FontVm.CurrrentFontWeightStyle.ValueStr == "Bold")
             {
                 item.mFontStyle = FontStyles.Normal;
                 item.mFontWeight = FontWeights.Bold;
             }
-            else if (FontVm.CurrentFontFamily.ValueStr == "Regular")
+            else if (FontVm.CurrrentFontWeightStyle.ValueStr == "Regular")
             {
                 item.mFontStyle = FontStyles.Normal;
                 item.mFontWeight = FontWeights.Normal;
@@ -369,7 +373,27 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         private void RestoreDefaultStyle()
         {
-           // var item = FontStyleList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
+            var defaultlists = TextFont.GetPresetFontStyle();
+            if(FontVm.CurrentPresetFont.ValueStr != "custom")
+            {
+                var defaulItem = defaultlists.FirstOrDefault(temp => temp.mTag == FontVm.CurrentPresetFont.ValueStr);
+                if (defaulItem != null)
+                {
+                    var currentItem = FontVm.PresetFontList.FirstOrDefault(temp => temp.mTag == FontVm.CurrentPresetFont.ValueStr);
+                    if (currentItem != null)
+                    {
+                        currentItem.mTagContent = defaulItem.mTagContent;
+                        currentItem.mFontStyle = defaulItem.mFontStyle;
+                        currentItem.mFontWeight = defaulItem.mFontWeight;
+                        currentItem.mFontFamily = defaulItem.mFontFamily;
+                        currentItem.mFontSize = defaulItem.mFontSize;
+                        FontVm.GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
+                        FontVm.GetCurrentFontSize(currentItem.mFontSize);
+                        FontVm.GetFontWeights_Style(currentItem.mFontStyle, currentItem.mFontWeight);
+                    }
+                }
+            }
+           
         }
 
         private void DateFormatChanged()

+ 1 - 1
PDF Office/ViewModels/PropertyPanel/FontBoardVM.cs

@@ -365,7 +365,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
         #region 属性
 
-        private ComboDataItem _currentPresetFont = new ComboDataItem("Custom", "Custom");
+        private ComboDataItem _currentPresetFont = new ComboDataItem("custom", "Custom");
         public ComboDataItem CurrentPresetFont
         {
             get { return _currentPresetFont; }

+ 15 - 2
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -210,7 +210,6 @@ namespace PDF_Office.ViewModels.Tools
                             }
                             //else
                             PDFViewer.SetToolParam(annot);
-
                             #region TO DO
 
                             //设计重新调整,阅读页空白处,右键菜单,添加链接需要显示,其他和pro mac一样的效果,不显示属性栏
@@ -391,7 +390,7 @@ namespace PDF_Office.ViewModels.Tools
         {
             if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
                 return;
-
+            
             switch (e.CommandType)
             {
                 case CommandType.Context:
@@ -631,6 +630,20 @@ namespace PDF_Office.ViewModels.Tools
                                     viewModel.UpdateAddedAnnot(pageindex, annotindex);
                                 }
                             }
+
+                            var annot = e[0].EditAnnotArgs;
+                            if (
+                               annot.EventType == AnnotArgsType.AnnotSquare ||
+                               annot.EventType == AnnotArgsType.AnnotCircle ||
+                               annot.EventType == AnnotArgsType.AnnotLine ||
+                               annot.EventType == AnnotArgsType.AnnotStamp
+                               )
+                            {
+                                PDFViewer.ClearSelectAnnots();
+                                PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
+                            }
+
+
                             break;
 
                         case ActionType.Del:

+ 5 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -233,6 +233,11 @@ namespace PDF_Office.ViewModels.Tools
                     annotArgs = GetLink();
                     break;
             }
+
+            if(annotArgs != null)
+            annotArgs.Author = Settings.Default.AppProperties.Description.Author;
+
+
         }
 
         /// <summary>

+ 6 - 2
PDF Office/Views/PropertyPanel/AnnotPanel/FreehandAnnotProperty.xaml

@@ -165,7 +165,9 @@
                     </CompositeControl:ColorContent>
                 </Grid>
 
-                <CompositeControl:SlidComboControl x:Name="thickness" Margin="12,0,12,0" Value="{Binding  BasicVm.AnnotThickness,Mode=TwoWay}">
+                <CompositeControl:SlidComboControl x:Name="thickness" Margin="12,0,12,0"
+                                                   ItemsSource="{Binding PenSizeItems}"
+                                                   Value="{Binding  BasicVm.AnnotThickness,Mode=TwoWay}">
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="ValueChanged">
                             <i:InvokeCommandAction Command="{Binding SelectPenThickChangedCommand}" CommandParameter="{Binding ElementName=thickness,Path=Value}"/>
@@ -208,7 +210,9 @@
 
             <StackPanel x:Name="PnlEraser"  Visibility="{Binding IsPen,Converter={StaticResource InvertBoolToVisibleConvert}}">
     
-                <CompositeControl:SlidComboControl x:Name="Eraserthickness" Margin="12,0,12,0" Value="{Binding  EraseThicknessLine,Mode=TwoWay}">
+                <CompositeControl:SlidComboControl x:Name="Eraserthickness" Margin="12,0,12,0"
+                                                   ItemsSource="{Binding EraserSizeItems}"
+                                                   Value="{Binding  EraseThicknessLine,Mode=TwoWay}">
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="ValueChanged">
                             <i:InvokeCommandAction Command="{Binding SetEraserThickCommand}" CommandParameter="{Binding ElementName=Eraserthickness,Path=Value}"/>