Browse Source

注释 - 手绘属性面板

chenrongqian@kdanmobile.com 2 years ago
parent
commit
5a3634f79a

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

@@ -107,6 +107,7 @@ namespace PDF_Office.CustomControl.CompositeControl
         private void ThicknessSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
         private void ThicknessSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
         {
         {
             combox.SelectedItems = new ComboDataItem(Value);
             combox.SelectedItems = new ComboDataItem(Value);
+            ValueChanged?.Invoke(Value, null);
         }
         }
 
 
 
 
@@ -124,9 +125,7 @@ namespace PDF_Office.CustomControl.CompositeControl
             var value = (double)e.NewValue;
             var value = (double)e.NewValue;
             if (control != null)
             if (control != null)
             {
             {
-
                 control.combox.SelectedItems = new ComboDataItem(value);
                 control.combox.SelectedItems = new ComboDataItem(value);
-                control.ValueChanged?.Invoke(value, null);
 
 
             }
             }
         }
         }

+ 24 - 1
PDF Office/ViewModels/PropertyPanel/AnnotPanel/AnnotBasePropertyVM.cs

@@ -28,6 +28,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             set => SetProperty(ref _annotTypeTitle, value);
             set => SetProperty(ref _annotTypeTitle, value);
         }
         }
 
 
+        #region 线条
+
         //线条粗细大小
         //线条粗细大小
         private double _annotThickness = 1;
         private double _annotThickness = 1;
         public double AnnotThickness
         public double AnnotThickness
@@ -44,6 +46,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             set => SetProperty(ref dash, value);
             set => SetProperty(ref dash, value);
         }
         }
 
 
+        #endregion 线条
+
         #region 填充
         #region 填充
         //填充颜色透明度
         //填充颜色透明度
         private double fillOpacity = 1;
         private double fillOpacity = 1;
@@ -110,7 +114,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             set => SetProperty(ref _currentFontColor, value);
             set => SetProperty(ref _currentFontColor, value);
         }
         }
 
 
-
+        //外部UI引用,判断是否选中实线、虚线、或都不选中
+        public string strDashStyle { get; private set; }
+        //VM赋值
+        public void SetStrDashStyle(string str)
+        {
+            strDashStyle = str;
+        }
         #endregion
         #endregion
 
 
         #region 多选
         #region 多选
@@ -123,6 +133,19 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         }
         }
 
 
         #endregion
         #endregion
+
+        /// <summary>
+        /// VM触发到外部UI事件
+        /// </summary>
+        public event EventHandler<object> SelectedAnnotInvokeToUI;
+        //Todo:由于考虑到有些UI在VM不太方便处理,因此需要触发该函数到外部xaml.cs里更改UI属性。
+        //更改多个属性:value可为键值对集合
+        //适应范围:若VM在Loaded进行绑定,需要UI初始化之后,才能起到作用
+        public void InvokeToUI(object sender,object value)
+        {
+            SelectedAnnotInvokeToUI?.Invoke(sender, value);
+        }
+
     }
     }
 
 
 }
 }

+ 106 - 145
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreehandAnnotPropertyViewModel.cs

@@ -38,71 +38,30 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
 
     public class FreehandAnnotPropertyViewModel : BindableBase, INavigationAware
     public class FreehandAnnotPropertyViewModel : BindableBase, INavigationAware
     {
     {
-        private bool isPen = true;
-        public bool IsPen
-        {
-            get { return isPen; }
-            set
-            {
-                SetProperty(ref isPen, value);
-            }
-        }
+        #region 属性
 
 
-        private Brush selectColor = new SolidColorBrush(Colors.Transparent);
-        public Brush SelectColor
+        private AnnotBasePropertyVM _basicVm = new AnnotBasePropertyVM();
+        public AnnotBasePropertyVM BasicVm
         {
         {
-            get { return selectColor; }
-            set { SetProperty(ref selectColor, value); 
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (SelectColor as SolidColorBrush).Color);
-                AnnotEvent?.UpdateAnnot();
-            }
+            get { return _basicVm; }
+            set => SetProperty(ref _basicVm, value);
         }
         }
 
 
-        private double annotOpacity = 1;
-        public double AnnotOpacity
+        private bool _isPen = true;
+        public bool IsPen
         {
         {
-            get { return annotOpacity; }
-            set
-            {
-                SetProperty(ref annotOpacity, value);
-            }
+            get { return _isPen; }
+            set => SetProperty(ref _isPen, value);
         }
         }
 
 
-        bool isCanSave = false;
-        private double thicknessLine = 1;
-        public double ThicknessLine
-        {
-            get { return thicknessLine; }
-            set
-            {
-                SetProperty(ref thicknessLine, value);
-                if(isCanSave)
-                {
-                    AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, thicknessLine);
-                    AnnotEvent?.UpdateAnnot();
-                }
-
-            }
-        }
-
-        private double erasethicknessLine = 1;
+        private double _erasethicknessLine = 1;
         public double EraseThicknessLine
         public double EraseThicknessLine
         {
         {
-            get { return erasethicknessLine; }
-            set
-            {
-                SetProperty(ref erasethicknessLine, value);
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, erasethicknessLine);
-                AnnotEvent?.UpdateAnnot();
-            }
+            get { return _erasethicknessLine; }
+            set => SetProperty(ref _erasethicknessLine, value);
         }
         }
 
 
-        private bool _isMultiSelected = false;
-        public bool IsMultiSelected
-        {
-            get { return _isMultiSelected; }
-            set => SetProperty(ref _isMultiSelected, value);
-        }
+        #endregion 属性
 
 
         public AnnotAttribEvent AnnotEvent { get; set; }
         public AnnotAttribEvent AnnotEvent { get; set; }
         private AnnotHandlerEventArgs Annot;
         private AnnotHandlerEventArgs Annot;
@@ -116,17 +75,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public DelegateCommand<object> LineModeCheckedCommand { get; set; }
         public DelegateCommand<object> LineModeCheckedCommand { get; set; }
         public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
         public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
 
 
-        public event EventHandler<object> LoadPropertyHandler;
-
-
         public FreehandAnnotPropertyViewModel()
         public FreehandAnnotPropertyViewModel()
         {
         {
             EraseCommand = new DelegateCommand<object>(Erase_Command);
             EraseCommand = new DelegateCommand<object>(Erase_Command);
             PenCommand = new DelegateCommand<object>(Pen_Command);
             PenCommand = new DelegateCommand<object>(Pen_Command);
 
 
-            SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged_Click);
-            SelectPenThickChangedCommand = new DelegateCommand<object>(SelectPenThickChanged_Command);
-            SetEraserThickCommand = new DelegateCommand<object>(SelectEraserThickChanged_Command);
+            SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged);
+            SelectPenThickChangedCommand = new DelegateCommand<object>(SelectPenThickChanged);
+            SetEraserThickCommand = new DelegateCommand<object>(SelectEraserThickChanged);
             LineModeCheckedCommand = new DelegateCommand<object>(LineMode_Checked);
             LineModeCheckedCommand = new DelegateCommand<object>(LineMode_Checked);
             SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
             SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
 
 
@@ -138,22 +94,71 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
 
         }
         }
 
 
-        private void SelectEraserThickChanged_Command(object obj)
+        //设置颜色
+        private void SelectedColorChanged(object obj)
         {
         {
             if (obj != null)
             if (obj != null)
             {
             {
-                var item = (ComboBoxItem)obj;
-                var content = (string)item.Content;
-                if (content != null)
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+                    if (BasicVm.IsMultiSelected)
+                    {
+                        foreach (var item in PropertyPanel.AnnotEvents)
+                        {
+                            item?.UpdateAttrib(AnnotAttrib.Color, colorValue);
+                            item?.UpdateAnnot();
+                        }
+                    }
+                    else
+                    {
+                        BasicVm.FontColor = new SolidColorBrush(colorValue);
+                        BasicVm.FontColor.Opacity = BasicVm.FillOpacity;
+
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, colorValue);
+                        AnnotEvent?.UpdateAnnot();
+
+                        PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, colorValue);
+                    }
+
+                }
+            }
+        }
+
+        //设置线条大小
+        private void SelectPenThickChanged(object obj)
+        {
+            if (obj != null && obj is double)
+            {
+                var thick = (double)obj;
+                if (BasicVm.IsMultiSelected)
+                {
+                    foreach (var itemEvent in PropertyPanel.AnnotEvents)
+                    {
+                        itemEvent?.UpdateAttrib(AnnotAttrib.Thickness, thick);
+                        itemEvent?.UpdateAnnot();
+                    }
+                }
+                else
                 {
                 {
-                    var intData = double.Parse(content);
-                    AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, intData);
+                    AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, thick);
                     AnnotEvent?.UpdateAnnot();
                     AnnotEvent?.UpdateAnnot();
-                    EraseThicknessLine = intData;
                 }
                 }
             }
             }
         }
         }
 
 
+        //设置橡皮擦大小
+        private void SelectEraserThickChanged(object obj)
+        {
+            if (obj != null && obj is double)
+            {
+                var eraser = (double)obj;
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, eraser);
+                AnnotEvent?.UpdateAnnot();
+            }
+        }
+
+        //设置线条样式
         private void LineMode_Checked(object obj)
         private void LineMode_Checked(object obj)
         {
         {
             if (obj != null)
             if (obj != null)
@@ -163,16 +168,15 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 switch (tag)
                 switch (tag)
                 {
                 {
                     case "Dashed":
                     case "Dashed":
-                      
                         newDash.Dashes.Add(2);
                         newDash.Dashes.Add(2);
                         newDash.Dashes.Add(2);
                         newDash.Dashes.Add(2);
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Dash);
+                     //   AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Dash);
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, newDash);
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, newDash);
                         
                         
                         break;
                         break;
 
 
                     case "Solid":
                     case "Solid":
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, newDash);
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Solid);
                         break;
                         break;
 
 
                 }
                 }
@@ -181,76 +185,21 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
             }
         }
         }
 
 
-
-        private void SelectPenThickChanged_Command(object obj)
-        {
-            if (obj != null)
-            {
-                var item = (ComboBoxItem)obj;
-                var content = (string)item.Content;
-                if (content != null)
-                {
-                    var intData = double.Parse(content);
-                    if (IsMultiSelected)
-                    {
-                        foreach (var itemEvent in PropertyPanel.AnnotEvents)
-                        {
-                            itemEvent?.UpdateAttrib(AnnotAttrib.Thickness, intData);
-                            itemEvent?.UpdateAnnot();
-                        }
-                    }
-                    else
-                    {
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, intData);
-                        AnnotEvent?.UpdateAnnot();
-                    }
-                   
-                    ThicknessLine = intData;
-                }
-            }
-        }
-
+        //设置不透明度
         private void SelectedOpacityValue(object obj)
         private void SelectedOpacityValue(object obj)
         {
         {
             if (obj != null)
             if (obj != null)
             {
             {
-                annotOpacity = (double)obj;
-                SelectColor.Opacity = annotOpacity;
+                BasicVm.FillOpacity = (double)obj;
+                BasicVm.FontColor.Opacity = BasicVm.FillOpacity;
 
 
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
                 AnnotEvent?.UpdateAnnot();
                 AnnotEvent?.UpdateAnnot();
-                PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, annotOpacity);
-            }
-        }
-
-
-        
-        private void SelectedColorChanged_Click(object obj)
-        {
-            if (obj != null)
-            {
-                var colorValue = (Color)obj;
-                if (colorValue != null)
-                {
-                    if (IsMultiSelected)
-                    {
-                        foreach (var item in PropertyPanel.AnnotEvents)
-                        {
-                            item?.UpdateAttrib(AnnotAttrib.Color, colorValue);
-                            item?.UpdateAnnot();
-                        }
-                    }
-                    else
-                    {
-                        SelectColor = new SolidColorBrush(colorValue);
-                        SelectColor.Opacity = AnnotOpacity;
-                        PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, obj);
-                    }
-                   
-                }
+                PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, BasicVm.FillOpacity);
             }
             }
         }
         }
 
 
+       //选择橡皮擦
         private void Erase_Command(object obj)
         private void Erase_Command(object obj)
         {
         {
             var btn = obj as ToggleButton;
             var btn = obj as ToggleButton;
@@ -261,6 +210,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
             }
         }
         }
 
 
+        //选择画笔
         private void Pen_Command(object obj)
         private void Pen_Command(object obj)
         {
         {
             var btn = obj as ToggleButton;
             var btn = obj as ToggleButton;
@@ -279,8 +229,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
 
         public void OnNavigatedFrom(NavigationContext navigationContext)
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
         {
-            IsMultiSelected = false;
-            isCanSave = false;
+            BasicVm.IsMultiSelected = false;
         }
         }
 
 
 
 
@@ -294,14 +243,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 Annot = PropertyPanel.annot;
                 Annot = PropertyPanel.annot;
                 if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
                 if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
                 {
                 {
-                    IsMultiSelected = true;
+                    BasicVm.IsMultiSelected = true;
                 }
                 }
                 else
                 else
                 {
                 {
-                    IsMultiSelected = false;
+                    BasicVm.IsMultiSelected = false;
                 }
                 }
 
 
-                if (IsMultiSelected)
+                if (BasicVm.IsMultiSelected)
                 {
                 {
                     double thickness = 0;
                     double thickness = 0;
                     foreach(var item in PropertyPanel.annotlists)
                     foreach(var item in PropertyPanel.annotlists)
@@ -309,19 +258,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         if ((item as FreehandAnnotArgs).LineWidth >= thickness)
                         if ((item as FreehandAnnotArgs).LineWidth >= thickness)
                             thickness = (item as FreehandAnnotArgs).LineWidth;
                             thickness = (item as FreehandAnnotArgs).LineWidth;
                     }
                     }
-                    
-                    ThicknessLine = thickness;
+
+                    BasicVm.AnnotThickness = thickness;
+                    BasicVm.SetStrDashStyle("None");
                 }
                 }
                 else
                 else
                 {
                 {
                     GetAnnotProperty();
                     GetAnnotProperty();
-                    if (Annot is FreehandAnnotArgs)
-                        LoadPropertyHandler?.Invoke(null, (Annot as FreehandAnnotArgs).InkColor);
                 }
                 }
                    
                    
             }
             }
-
-            isCanSave = true;
         }
         }
 
 
         private void GetAnnotProperty()
         private void GetAnnotProperty()
@@ -331,9 +277,24 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 var annot  = Annot as FreehandAnnotArgs;
                 var annot  = Annot as FreehandAnnotArgs;
                 if (annot != null)
                 if (annot != null)
                 {
                 {
-                    AnnotOpacity = annot.Transparency;
-                    SelectColor = new SolidColorBrush(annot.InkColor);
-                    ThicknessLine = annot.LineWidth;
+                    BasicVm.FillOpacity = annot.Transparency;
+                    BasicVm.FontColor = new SolidColorBrush(annot.InkColor);
+                    BasicVm.AnnotThickness = annot.LineWidth;
+                    BasicVm.Dash = annot.LineDash;
+                    bool isSolid = true;
+                    if(annot.LineDash != null && annot.LineDash.Dashes.Count > 0)
+                    {
+                        foreach(var item in annot.LineDash.Dashes)
+                        {
+                            if(item > 0)
+                            {
+                                isSolid = false;
+                                break;
+                            }
+                        }
+                    }
+
+                    BasicVm.SetStrDashStyle(isSolid ? "Solid" : "Dash");
                     IsPen = true;
                     IsPen = true;
                 }
                 }
             }
             }

+ 1 - 4
PDF Office/ViewModels/PropertyPanel/AnnotPanel/TextAnnotPropertyViewModel.cs

@@ -70,10 +70,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public AnnotBasePropertyVM BasicVm
         public AnnotBasePropertyVM BasicVm
         {
         {
             get { return _basicVm; }
             get { return _basicVm; }
-            set
-            {
-                SetProperty(ref _basicVm, value); 
-            }
+            set => SetProperty(ref _basicVm, value);
         }
         }
 
 
         #endregion 属性
         #endregion 属性

+ 29 - 88
PDF Office/Views/PropertyPanel/AnnotPanel/FreehandAnnotProperty.xaml

@@ -35,7 +35,6 @@
                 </Setter>
                 </Setter>
             </Style>
             </Style>
 
 
-     
         </ResourceDictionary>
         </ResourceDictionary>
     </UserControl.Resources>
     </UserControl.Resources>
     <Grid Background="#F3F3F3">
     <Grid Background="#F3F3F3">
@@ -43,7 +42,7 @@
             <TextBlock Name="AnnotTypeTitle" FontFamily="SegoeUI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Left" Margin="10,8,0,0">Freehand</TextBlock>
             <TextBlock Name="AnnotTypeTitle" FontFamily="SegoeUI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Left" Margin="10,8,0,0">Freehand</TextBlock>
 
 
             <Border Width="128" Height="32" Margin="0,12,0,0" BorderThickness="1" BorderBrush="#FFE2E3E6"
             <Border Width="128" Height="32" Margin="0,12,0,0" BorderThickness="1" BorderBrush="#FFE2E3E6"
-                    Visibility="{Binding IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"
+                    Visibility="{Binding  BasicVm.IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"
                     >
                     >
                 <Grid Name="ToolGrid">
                 <Grid Name="ToolGrid">
                     <Grid.ColumnDefinitions>
                     <Grid.ColumnDefinitions>
@@ -51,7 +50,6 @@
                         <ColumnDefinition Width="*"></ColumnDefinition>
                         <ColumnDefinition Width="*"></ColumnDefinition>
                     </Grid.ColumnDefinitions>
                     </Grid.ColumnDefinitions>
 
 
-
                     <ToggleButton Name="PenBtn"  IsEnabled="True" Tag="PenBtn" Background="Transparent"  BorderThickness="0" Click="PenBtn_Click" IsChecked="{Binding IsPen}" Checked="PenBtn_Checked" Command="{Binding PenCommand}" CommandParameter="{Binding ElementName=PenBtn}" >
                     <ToggleButton Name="PenBtn"  IsEnabled="True" Tag="PenBtn" Background="Transparent"  BorderThickness="0" Click="PenBtn_Click" IsChecked="{Binding IsPen}" Checked="PenBtn_Checked" Command="{Binding PenCommand}" CommandParameter="{Binding ElementName=PenBtn}" >
                         <Image Width="16" Height="16">
                         <Image Width="16" Height="16">
                             <Image.Source>
                             <Image.Source>
@@ -84,7 +82,6 @@
                         </Image>
                         </Image>
                     </ToggleButton>
                     </ToggleButton>
 
 
-
                     <Line HorizontalAlignment="Left" Style="{StaticResource lineStyle}" VerticalAlignment="Center" Grid.Column="1" X1="0" Y1="0" X2="0" Y2="16" StrokeThickness="1" Stroke="#33000000"></Line>
                     <Line HorizontalAlignment="Left" Style="{StaticResource lineStyle}" VerticalAlignment="Center" Grid.Column="1" X1="0" Y1="0" X2="0" Y2="16" StrokeThickness="1" Stroke="#33000000"></Line>
 
 
                     <ToggleButton Name="EraseBtn" Tag="EraseBtn" Background="Transparent" Grid.Column="1" BorderThickness="0" Click="EraseBtn_Click" Command="{Binding EraseCommand}" CommandParameter="{Binding ElementName=EraseBtn}">
                     <ToggleButton Name="EraseBtn" Tag="EraseBtn" Background="Transparent" Grid.Column="1" BorderThickness="0" Click="EraseBtn_Click" Command="{Binding EraseCommand}" CommandParameter="{Binding ElementName=EraseBtn}">
@@ -100,12 +97,11 @@
                 </Grid>
                 </Grid>
             </Border>
             </Border>
 
 
-            
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0"
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0"
-                    Visibility="{Binding IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"
+                    Visibility="{Binding  BasicVm.IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"
                     >
                     >
                 <Grid>
                 <Grid>
-                    <Path Name="FreehandPath" Fill="{Binding SelectColor}" Stroke="{Binding SelectColor}" StrokeThickness="{Binding ThicknessLine}" Visibility="{Binding IsPen,Converter={StaticResource BoolToVisible}}"
+                    <Path Name="FreehandPath" Fill="{Binding BasicVm.FontColor}" Stroke="{Binding BasicVm.FontColor}" StrokeThickness="{Binding BasicVm.AnnotThickness}" Visibility="{Binding IsPen,Converter={StaticResource BoolToVisible}}"
                   Data="M89.6572823,33.0006836 C92.423623,33.0142613 94.9660238,33.2143167 97.6072943,33.6499257 L98.4450428,33.7953737 C99.2868308,33.9487663 100.141867,
                   Data="M89.6572823,33.0006836 C92.423623,33.0142613 94.9660238,33.2143167 97.6072943,33.6499257 L98.4450428,33.7953737 C99.2868308,33.9487663 100.141867,
                   34.1261641 101.020317,34.3291126 L101.906948,34.5406353 L102.811448,34.7695353 L103.736075,35.016156 C103.891982,35.0587552 104.048822,35.1021072 104.206642,
                   34.1261641 101.020317,34.3291126 L101.906948,34.5406353 L102.811448,34.7695353 L103.736075,35.016156 C103.891982,35.0587552 104.048822,35.1021072 104.206642,
                   35.1462189 L105.165696,35.4200646 L106.150524,35.7124896 L107.163387,36.0238374 L108.206543,36.3544513 L109.833019,36.8872476 L110.961791,37.2675295 L112.128763,
                   35.1462189 L105.165696,35.4200646 L106.150524,35.7124896 L107.163387,36.0238374 L108.206543,36.3544513 L109.833019,36.8872476 L110.961791,37.2675295 L112.128763,
@@ -143,7 +139,7 @@
                         <RowDefinition/>
                         <RowDefinition/>
                     </Grid.RowDefinitions>
                     </Grid.RowDefinitions>
                     <CompositeControl:SlidContent x:Name="layerThick" HorizontalAlignment="Right"
                     <CompositeControl:SlidContent x:Name="layerThick" HorizontalAlignment="Right"
-                                          Visibility="{Binding IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"        
+                                          Visibility="{Binding BasicVm.IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"        
                                                   >
                                                   >
                         <i:Interaction.Triggers>
                         <i:Interaction.Triggers>
                             <i:EventTrigger EventName="SelectedValueChanged">
                             <i:EventTrigger EventName="SelectedValueChanged">
@@ -152,48 +148,24 @@
                         </i:Interaction.Triggers>
                         </i:Interaction.Triggers>
                     </CompositeControl:SlidContent>
                     </CompositeControl:SlidContent>
 
 
-                    <CompositeControl:ColorContent Grid.Row="1" x:Name="cusColor"/>
+                    <CompositeControl:ColorContent Grid.Row="1" x:Name="cusColor"
+                                                   UIColor="{Binding BasicVm.CurrentFontColor,Mode=OneWay}"
+                                                   >
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="SelectedColorInvoke">
+                                <i:InvokeCommandAction Command="{Binding SelectedColorChangedCommand}" CommandParameter="{Binding ElementName=cusColor,Path=SelectedColor}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
+                    </CompositeControl:ColorContent>
                 </Grid>
                 </Grid>
 
 
-                <TextBlock x:Name="borderText" LineHeight="20" Margin="12,14,0,0" >Border</TextBlock>
-                <Grid>
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="*"></ColumnDefinition>
-                        <ColumnDefinition Width="auto"></ColumnDefinition>
-                    </Grid.ColumnDefinitions>
-                    <Slider Name="BorderSlider" VerticalAlignment="Center" Margin="12,0,4,0"  Minimum="1" Maximum="12" IsSelectionRangeEnabled="True" IsMoveToPointEnabled="True"
-                    Style="{StaticResource RoundThumbSlider}"  TickFrequency="1" IsSnapToTickEnabled="True" Value="{Binding ThicknessLine}">
-                        <Slider.Resources>
-                            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#477EDE" />
-                            <SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkDarkBrushKey}" Color="#E2E3E6" />
-                        </Slider.Resources>
-                    </Slider>
-
-                    <Border Grid.Column="1" BorderBrush="#E2E3E6"  Width="80" Height="32" Margin="0,0,12,0"  BorderThickness="0">
-                        <Grid>
-                            <ComboBox Name="CmbPen" BorderThickness="1" Padding="10 10 0 0" Background="Transparent" BorderBrush="#FFE2E3E6" >
-                                <ComboBox.ItemContainerStyle>
-                                    <Style TargetType="{x:Type ComboBoxItem}">
-                                        <Setter Property="Padding" Value="10 0 0 0"/>
-                                    </Style>
-                                </ComboBox.ItemContainerStyle>
-                                <ComboBoxItem Content="1" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
-                                <ComboBoxItem Content="3" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
-                                <ComboBoxItem Content="6" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
-                                <ComboBoxItem Content="9" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
-                                <ComboBoxItem Content="12" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
-                                <i:Interaction.Triggers>
-                                    <i:EventTrigger EventName="SelectionChanged">
-                                        <i:InvokeCommandAction Command="{Binding SelectPenThickChangedCommand}"  CommandParameter="{Binding ElementName=CmbPen,Path=SelectedItem}"/>
-                                    </i:EventTrigger>
-                                </i:Interaction.Triggers>
-                            </ComboBox>
-                            <TextBox FontFamily="Segoe UI" FontSize="14" Background="White" Height="20" Margin="10,0,35,0" IsReadOnly="True"
-                             BorderThickness="0" VerticalAlignment="Center" TextAlignment="Left" Text="{Binding ElementName=BorderSlider,Path=Value}">
-                            </TextBox>
-                        </Grid>
-                    </Border>
-                </Grid>
+                <CompositeControl:SlidComboControl x:Name="thickness" Margin="12,0,12,0" Value="{Binding  BasicVm.AnnotThickness,Mode=TwoWay}">
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="ValueChanged">
+                            <i:InvokeCommandAction Command="{Binding SelectPenThickChangedCommand}" CommandParameter="{Binding ElementName=thickness,Path=Value}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </CompositeControl:SlidComboControl>
 
 
                 <StackPanel Orientation="Horizontal" Margin="0,20,0,0">
                 <StackPanel Orientation="Horizontal" Margin="0,20,0,0">
 
 
@@ -211,7 +183,7 @@
                         </i:Interaction.Triggers>
                         </i:Interaction.Triggers>
                     </RadioButton>
                     </RadioButton>
 
 
-                    <RadioButton x:Name="BtnDashed" Tag="Dashed" GroupName="LineMode"
+                    <RadioButton x:Name="BtnDashed" Tag="Dashed" GroupName="LineMode" 
                                  Width="105" Height="32" Margin="0,0" Foreground="#616469"
                                  Width="105" Height="32" Margin="0,0" Foreground="#616469"
                                  VerticalContentAlignment="Center" Background="Transparent"
                                  VerticalContentAlignment="Center" Background="Transparent"
                                  Style="{DynamicResource GreyBgRadioBtnStyle}">
                                  Style="{DynamicResource GreyBgRadioBtnStyle}">
@@ -229,45 +201,14 @@
             </StackPanel>
             </StackPanel>
 
 
             <StackPanel x:Name="PnlEraser"  Visibility="{Binding IsPen,Converter={StaticResource InvertBoolToVisibleConvert}}">
             <StackPanel x:Name="PnlEraser"  Visibility="{Binding IsPen,Converter={StaticResource InvertBoolToVisibleConvert}}">
-                <TextBlock x:Name="eText" LineHeight="20" Margin="12,14,0,0" >Border</TextBlock>
-                <Grid>
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="*"></ColumnDefinition>
-                        <ColumnDefinition Width="auto"></ColumnDefinition>
-                    </Grid.ColumnDefinitions>
-                    <Slider Name="SlEraser" VerticalAlignment="Center" Margin="12,0,4,0"  Minimum="1" Maximum="20" IsSelectionRangeEnabled="True" IsMoveToPointEnabled="True"
-                            Value="{Binding EraseThicknessLine}"
-                    Style="{StaticResource RoundThumbSlider}"  TickFrequency="1" IsSnapToTickEnabled="True" >
-                        <Slider.Resources>
-                            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#477EDE" />
-                            <SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkDarkBrushKey}" Color="#E2E3E6" />
-                        </Slider.Resources>
-                    </Slider>
-
-                    <Border Grid.Column="1" BorderBrush="#E2E3E6"  Width="80" Height="32" Margin="0,0,12,0"  BorderThickness="0">
-                        <Grid>
-                            <ComboBox Name="CmbEraser" BorderThickness="1" Padding="10 10 0 0" Background="Transparent" BorderBrush="#FFE2E3E6" >
-                                <ComboBox.ItemContainerStyle>
-                                    <Style TargetType="{x:Type ComboBoxItem}">
-                                        <Setter Property="Padding" Value="10 0 0 0"/>
-                                    </Style>
-                                </ComboBox.ItemContainerStyle>
-                                <ComboBoxItem Content="5" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
-                                <ComboBoxItem Content="10" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
-                                <ComboBoxItem Content="15" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
-                                <ComboBoxItem Content="20" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
-                                <i:Interaction.Triggers>
-                                    <i:EventTrigger EventName="SelectionChanged">
-                                        <i:InvokeCommandAction Command="{Binding SetEraserThickCommand}"  CommandParameter="{Binding ElementName=CmbEraser,Path=SelectedItem}"/>
-                                    </i:EventTrigger>
-                                </i:Interaction.Triggers>
-                            </ComboBox>
-                            <TextBox FontFamily="Segoe UI" FontSize="14" Background="White" Height="20" Margin="10,0,35,0" IsReadOnly="True"
-                             BorderThickness="0" VerticalAlignment="Center" TextAlignment="Left" Text="{Binding ElementName=SlEraser,Path=Value}">
-                            </TextBox>
-                        </Grid>
-                    </Border>
-                </Grid>
+    
+                <CompositeControl:SlidComboControl x:Name="Eraserthickness" Margin="12,0,12,0" Value="{Binding  EraseThicknessLine,Mode=TwoWay}">
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="ValueChanged">
+                            <i:InvokeCommandAction Command="{Binding SetEraserThickCommand}" CommandParameter="{Binding ElementName=Eraserthickness,Path=Value}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </CompositeControl:SlidComboControl>
 
 
             </StackPanel>
             </StackPanel>
           
           

+ 15 - 36
PDF Office/Views/PropertyPanel/AnnotPanel/FreehandAnnotProperty.xaml.cs

@@ -31,48 +31,27 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
 
 
         private void usercontrol_Unloaded(object sender, RoutedEventArgs e)
         private void usercontrol_Unloaded(object sender, RoutedEventArgs e)
         {
         {
-            if (ViewModel != null)
-            {
-                ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
-            }
-            cusColor.SelectedColorHandler -= cusColor_SelectedColor;
+
         }
         }
 
 
         private void usercontrol_Loaded(object sender, RoutedEventArgs e)
         private void usercontrol_Loaded(object sender, RoutedEventArgs e)
         {
         {
             if (ViewModel != null)
             if (ViewModel != null)
             {
             {
-                ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
-                ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
-            }
-            cusColor.SelectedColorHandler += cusColor_SelectedColor;
-        }
-
-        private void ViewModel_LoadPropertyHandler(object sender, object e)
-        {
-            if(e != null && e is Color == true)
-            {
-                var color = (Color)e;
-                cusColor.SelectedColor = color;
-            }
-            
-
-        }
-        private void layerThick_SelectedValue(object sender, double e)
-        {
-            var data = this.DataContext as FreehandAnnotPropertyViewModel;
-            if (data != null)
-            {
-              //  data.SelectedValueChangedCommand?.Execute(e);
-            }
-        }
-
-        private void cusColor_SelectedColor(object sender, Color e)
-        {
-            var data = this.DataContext as FreehandAnnotPropertyViewModel;
-            if (data != null)
-            {
-                data.SelectedColorChangedCommand?.Execute(e);
+                var str = ViewModel.BasicVm.strDashStyle;
+                if (str == "Solid")
+                {
+                    BtnSolid.IsChecked = true;
+                }
+                else if (str == "Dash")
+                {
+                    BtnDashed.IsChecked = true;
+                }
+                else
+                {
+                    BtnSolid.IsChecked = false;
+                    BtnDashed.IsChecked = false;
+                }
             }
             }
         }
         }