Procházet zdrojové kódy

注释 - 切换选中手绘线条不对的问题

chenrongqian@kdanmobile.com před 2 roky
rodič
revize
ed80500439

+ 24 - 2
PDF Office/CustomControl/CompositeControl/CustomComboControl.xaml.cs

@@ -66,6 +66,7 @@ namespace PDF_Office.CustomControl.CompositeControl
             comBox.SelectionChanged += comBox_SelectionChanged;
         }
 
+
         //更换集合
         public void SetItemSource(List<ComboDataItem> items)
         {
@@ -127,6 +128,23 @@ namespace PDF_Office.CustomControl.CompositeControl
 
         }
 
+        //在外部判断值是否存在于下拉框里
+        public bool IsExistInComBox(object value)
+        {
+            if (value is double)
+            {
+                var item = Items.FirstOrDefault(temp => temp.Value == (double)Value);
+                return (item == null ? false : true);
+            }
+            else if (value is string)
+            {
+                var item = Items.FirstOrDefault(temp => temp.ValueStr == (string)ValueStr);
+                return (item == null ? false : true);
+            }
+
+            return false;
+        }
+
         public double Value
         {
             get { return (double)GetValue(ValueProperty); }
@@ -253,8 +271,12 @@ namespace PDF_Office.CustomControl.CompositeControl
 
                         if (index >= 0)
                         {
-                            control.SelectedIndex = -1;
-                            control.SelectedIndex = index;
+                            if(control.SelectedIndex != index)
+                            {
+                                control.SelectedIndex = index;
+                            }
+                            //control.SelectedIndex = -1;
+                            //control.SelectedIndex = index;
                         }
                         else
                             control.title.Text = selectedItems.Content;

+ 1 - 0
PDF Office/CustomControl/CompositeControl/SlidComboControl.xaml

@@ -589,6 +589,7 @@
                 Maximum="24"
                 Minimum="0"
                 Style="{DynamicResource RoundThumbSlider}"
+                PreviewMouseMove="ThicknessSlider_PreviewMouseMove"
                 TickFrequency="1"
                 Value="{Binding ElementName=usercontrol, Path=Value}">
                 <Slider.Resources>

+ 14 - 3
PDF Office/CustomControl/CompositeControl/SlidComboControl.xaml.cs

@@ -99,15 +99,19 @@ namespace PDF_Office.CustomControl.CompositeControl
         {
             if (sender is double == true)
             {
-                if ((double)sender != Value)
-                    Value = (double)sender;
+                //点击下拉框时触发
+                if (combox.IsExistInComBox(sender))
+                {
+                    ThicknessSlider.Value = (double)sender;
+                    ValueChanged?.Invoke((double)sender, null);
+                }
             }
         }
 
         private void ThicknessSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
         {
             combox.SelectedItems = new ComboDataItem(Value);
-            ValueChanged?.Invoke(Value, null);
+          //  ValueChanged?.Invoke(Value, null);
         }
 
 
@@ -130,5 +134,12 @@ namespace PDF_Office.CustomControl.CompositeControl
             }
         }
 
+        private void ThicknessSlider_PreviewMouseMove(object sender, MouseEventArgs e)
+        {
+            if(e.LeftButton == MouseButtonState.Pressed)
+            {
+                ValueChanged?.Invoke(ThicknessSlider.Value, null);
+            }
+        }
     }
 }

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

@@ -216,6 +216,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
+
             if (PropertyPanel != null)
             {
                 AnnotEvent = PropertyPanel.AnnotEvent;

+ 60 - 19
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -76,18 +76,20 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             ReDefineFontStyleCommand = new DelegateCommand(ReDefineFontStyle);
             //恢复默认
             RestoreDefaultStyleCommand = new DelegateCommand(RestoreDefaultStyle);
-
-            SelectedFillOpacityCommand = new DelegateCommand<object>(SelectedFillOpacity);
-           
+            //颜色
             SelectedColorCommand = new DelegateCommand<object>(SelectedColor_Command);
+            //填充颜色
             SelectedFillColorCommand = new DelegateCommand<object>(SelectedFillColorChange);
-            
+            //填充颜色不透明度
+            SelectedFillOpacityCommand = new DelegateCommand<object>(SelectedFillOpacity);
+            //大小
             FontSizeChangedCommand = new DelegateCommand(FontSizeChanged);
+            //内容对齐
             TextAlignCheckedCommand = new DelegateCommand<object>(TextAlignChecked);
+
+            //MVP不上
             LineModeCheckedCommand = new DelegateCommand<object>(LineMode_Checked);
             SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
-
-            
             InitVariable();
         }
 
@@ -176,8 +178,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 FontVm.UpdateFontWeight_Style();
 
                 Dictionary<AnnotAttrib, object> AnnotAttribDir = new Dictionary<AnnotAttrib, object>();
-                AnnotAttribDir.Add(AnnotAttrib.FontStyle, FontVm.FontWeightItem);
-                AnnotAttribDir.Add(AnnotAttrib.FontWeight, FontVm.FontStyleItem);
+                AnnotAttribDir.Add(AnnotAttrib.FontStyle, FontVm.FontStyleItem);
+                AnnotAttribDir.Add(AnnotAttrib.FontWeight, FontVm.FontWeightItem);
                 PropertyPanel.UpdateAnnotAllAttribs(AnnotAttribDir);
             }
         }
@@ -339,21 +341,60 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 AnnotEvent = PropertyPanel.AnnotEvent;
                 Annot = PropertyPanel.annot as FreeTextAnnotArgs;
                 LoadPropertyHandler?.Invoke(this, Annot);
-                if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
-                {
-                    BasicVm.IsMultiSelected = true;
-                }
-                else
-                {
-                    BasicVm.IsMultiSelected = false;
-                }
+
+                BasicVm.IsMultiSelected = PropertyPanel.IsMultiSelected;
 
                 if(BasicVm.IsMultiSelected)
                 {
+                    bool isDifferentFontFamily = false;
+                    bool isDifferentFontSize = false;
+                    bool isDifferentFontStyle = false;
+
+                    FreeTextAnnotArgs tempAnnot = null;
+                    foreach (var item in PropertyPanel.annotlists)
+                    {
+                       var itemFreeText = item as FreeTextAnnotArgs;
+                        if(itemFreeText != null)
+                        {
+                            if (tempAnnot == null)
+                            {
+                                tempAnnot = itemFreeText;
+                            }
+                            else
+                            {
+
+                                if (itemFreeText.FontFamily != tempAnnot.FontFamily)
+                                {
+                                    isDifferentFontFamily = true;
+                                }
+
+                                if (itemFreeText.FontSize != tempAnnot.FontSize)
+                                {
+                                    isDifferentFontSize = true;
+                                }
+
+                                if (itemFreeText.FontStyle != tempAnnot.FontStyle || itemFreeText.FontWeight != tempAnnot.FontWeight)
+                                {
+                                    isDifferentFontStyle = true;
+                                }
+                                tempAnnot = itemFreeText;
+                            }
+                           
+                        }
+                        
+                    }
+
+                    if (isDifferentFontFamily || isDifferentFontSize || isDifferentFontStyle)
+                        FontVm.CurrentPresetFont = null;
+
+                    if(isDifferentFontFamily)
                     FontVm.CurrentFontFamily = null;
-                    FontVm.CurrentFontSize = null;
-                    FontVm.CurrrentFontWeightStyle = null;
-                    FontVm.CurrentPresetFont = null;
+
+                    if (isDifferentFontSize)
+                        FontVm.CurrentFontSize = null;
+
+                    if (isDifferentFontStyle)
+                        FontVm.CurrrentFontWeightStyle = null;
 
                     BasicVm.SetStrDashStyle("None");
                 }

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

@@ -81,6 +81,9 @@ namespace PDF_Office.ViewModels.Tools
             }
 
         }
+
+        //是否为多选
+        public bool IsMultiSelected { get { return (annotlists != null && annotlists.Count > 1); } }
         /// <summary>
         /// 更新多个属性,触发到工具栏注释工具,改变工具图标下的颜色值
         /// </summary>

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

@@ -156,7 +156,7 @@
                                 SelectedItems="{Binding FontVm.CurrrentFontWeightStyle, Mode=TwoWay}">
                             <i:Interaction.Triggers>
                                 <i:EventTrigger EventName="ValueChanged">
-                                    <i:InvokeCommandAction Command="{Binding FontFamilyChangedCommand}"/>
+                                    <i:InvokeCommandAction Command="{Binding FontStyleWeightChangedCommand}"/>
                                 </i:EventTrigger>
                             </i:Interaction.Triggers>
                         </CompositeControl:CustomComboControl>