Browse Source

注释 - 优化颜色板绑定属性

chenrongqian@kdanmobile.com 2 years ago
parent
commit
d298a95485

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

@@ -48,6 +48,7 @@
                 <Setter Property="HorizontalContentAlignment" Value="Center" />
                 <Setter Property="Height" Value="32" />
                 <Setter Property="Margin" Value="2,0,2,0" />
+                <EventSetter Event="PreviewMouseLeftButtonUp" Handler="listboxItem_PreviewMouseLeftButtonUp"/>
                 <EventSetter Event="PreviewMouseRightButtonDown" Handler="listboxItem_PreviewMouseRightButtonDown" />
             </Style>
         </ResourceDictionary>

+ 50 - 17
PDF Office/CustomControl/CompositeControl/ColorContent.xaml.cs

@@ -76,7 +76,7 @@ namespace PDF_Office.CustomControl.CompositeControl
         private ColorItem ChangedColorItem;
 
         /// <summary>
-        /// 选中项的颜色
+        /// 选中项的颜色,当前颜色
         /// </summary>
         public Color SelectedColor
         {
@@ -85,7 +85,17 @@ namespace PDF_Office.CustomControl.CompositeControl
         }
 
         public static readonly DependencyProperty SelectedColorProperty =
-            DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorContent), new PropertyMetadata((Color)ColorConverter.ConvertFromString("#6C33F8CC"), SelectedColorPropertyChanged));
+            DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorContent), new PropertyMetadata((Color)ColorConverter.ConvertFromString("#6C33F8CC")));
+
+        //外部传过来的颜色值,颜色列表里是否有被选中的颜色,或显示非列表里的当前颜色值
+        public Brush UIColor
+        {
+            get { return (Brush)GetValue(ceshiColorProperty); }
+            set { SetValue(ceshiColorProperty, value); }
+        }
+
+        public static readonly DependencyProperty ceshiColorProperty =
+            DependencyProperty.Register("UIColor", typeof(Brush), typeof(ColorContent), new PropertyMetadata(new SolidColorBrush(Color.FromArgb(0x6C,0x33,0xF8,0xCC)), SelectedColorPropertyChanged));
 
 
         public Visibility ShowColorList
@@ -101,21 +111,32 @@ namespace PDF_Office.CustomControl.CompositeControl
         private static void SelectedColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
             var control = d as ColorContent;
-            var co = (Color)e.NewValue;
+            var co = (SolidColorBrush)e.NewValue;
+            bool isFoundListItem = false;
             if(control != null)
             {
+                if(control.ShowColorList == Visibility.Collapsed)
+                {
+                    control.ElcustomColor.Fill = co;
+                    return;
+                }
+
                 foreach(var item in control.colors)
                 {
                     var colorItem = (item.Color as SolidColorBrush).Color;
-                    if(colorItem.A == co.A && colorItem.G == co.G && colorItem.B == co.B && colorItem.R == co.R)
+                    if(colorItem.A == co.Color.A && colorItem.G == co.Color.G && colorItem.B == co.Color.B && colorItem.R == co.Color.R)
                     {
                         control.ListColor.SelectedItem = item;
+                        control.ElcustomColor.Fill = new SolidColorBrush(Colors.Transparent);
+                        isFoundListItem = true;
                         break;
                     }
-                    else
-                    {
-                        control.ListColor.SelectedItem = null;
-                    }
+                }
+
+                if(isFoundListItem == false)
+                {
+                    control.ElcustomColor.Fill = co;
+                    control.ListColor.SelectedItem = null;
                 }
             }
         }
@@ -134,27 +155,35 @@ namespace PDF_Office.CustomControl.CompositeControl
         {
             IsExistForContainer((ElcustomColor.Fill as SolidColorBrush).Color);
             SelectedColorHandler?.Invoke(this, e.Value);
-            //ElcustomColor.Fill = new SolidColorBrush(e.Value);
+            ElcustomColor.Fill = new SolidColorBrush(e.Value);
             SelectedColor = e.Value;
             SelectedColorInvoke?.Invoke(e.Value, null);
         }
 
         private void ListColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            if(ListColor.SelectedItem != null)
+       
+        }
+
+        private void listboxItem_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            if (ListColor.SelectedItem != null)
             {
                 var item = ListColor.SelectedItem as ColorItem;
-                SelectedColorHandler?.Invoke(this, (item.Color as SolidColorBrush).Color);
-                SelectedColorInvoke?.Invoke((item.Color as SolidColorBrush).Color, null);
+                var selectCo = (item.Color as SolidColorBrush).Color;
+                SelectedColor = selectCo;
+                SelectedColorHandler?.Invoke(this, selectCo);
+                SelectedColorInvoke?.Invoke(selectCo, null);
             }
-            
         }
 
         private void ElcustomColor_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
-            IsExistForContainer((ElcustomColor.Fill as SolidColorBrush).Color);
-            SelectedColorHandler?.Invoke(this, (ElcustomColor.Fill as SolidColorBrush).Color);
-            SelectedColorInvoke?.Invoke((ElcustomColor.Fill as SolidColorBrush).Color, null);
+            var selectCo = (ElcustomColor.Fill as SolidColorBrush).Color;
+            SelectedColor = selectCo;
+            IsExistForContainer(selectCo);
+            SelectedColorHandler?.Invoke(this, selectCo);
+            SelectedColorInvoke?.Invoke(selectCo, null);
         }
 
         private void PnlColor_SelectedColorChanged(object sender, Color? e)
@@ -198,11 +227,13 @@ namespace PDF_Office.CustomControl.CompositeControl
                
         }
 
+        
         private void listboxItem_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
         {           
             e.Handled = true;
         }
-
+        
+        //外部把颜色值传回来作为当前值
         public void SetSelectedColor(Color newColor)
         {
             if (newColor != null)
@@ -215,6 +246,7 @@ namespace PDF_Office.CustomControl.CompositeControl
 
         }
 
+        //颜色列表里是否存在这个颜色值
         private bool IsExistForContainer(Color newColor)
         {
             bool isSelectList = false;
@@ -234,5 +266,6 @@ namespace PDF_Office.CustomControl.CompositeControl
             return isSelectList;
         }
 
+      
     }
 }

+ 46 - 121
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -38,6 +38,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        private Brush _currentFillColor = new SolidColorBrush(Colors.Transparent);
+        public Brush CurrentFillColor
+        {
+            get { return _currentFillColor; }
+            set
+            {
+                SetProperty(ref _currentFillColor, value);
+            }
+        }
+
         private Brush fillColor = new SolidColorBrush(Colors.Transparent);
         public Brush FillColor
         {
@@ -45,82 +55,25 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             set
             {
                 SetProperty(ref fillColor, value);
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, (fillColor as SolidColorBrush).Color);
-                AnnotEvent?.UpdateAnnot();
+                if (IsCanSave)
+                {
+                    AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, (fillColor as SolidColorBrush).Color);
+                    AnnotEvent?.UpdateAnnot();
+                }
+                else
+                {
+                    CurrentFillColor = fillColor;
+                }
+               
             }
         }
 
-        //private FontFamily fontFamily = new FontFamily("Courier");
-        //public FontFamily TextFontFamily
-        //{
-        //    get { return fontFamily; }
-        //    set
-        //    {
-        //        SetProperty(ref fontFamily, value);
-        //    }
-        //}
-
-        //private FontWeight fontWeights = FontWeights.Normal;
-        //public FontWeight TextFontWeights
-        //{
-        //    get { return fontWeights; }
-        //    set
-        //    {
-        //        SetProperty(ref fontWeights, value);
-        //    }
-        //}
-
-        //private FontStyle fontStyle = FontStyles.Normal;
-        //public FontStyle TextFontStyle
-        //{
-        //    get { return fontStyle; }
-        //    set
-        //    {
-        //        SetProperty(ref fontStyle, value);
-        //    }
-        //}
-
-        //private ComboDataItem _fontWeightStyleItem;
-        //public ComboDataItem FontWeightStyleItem
-        //{
-        //    get { return _fontWeightStyleItem; }
-        //    set
-        //    {
-        //        SetProperty(ref _fontWeightStyleItem, value);
-        //        if (_fontWeightStyleItem.ValueStr != null && string.IsNullOrEmpty((string)_fontWeightStyleItem.ValueStr) == false)
-        //        {
-        //            switch ((string)_fontWeightStyleItem.ValueStr)
-        //            {
-        //                case "Regular":
-        //                    FontStyleItem = FontStyles.Normal;
-        //                    FontWeightItem = FontWeights.Normal;
-        //                    break;
-
-        //                case "Bold":
-        //                    FontStyleItem = FontStyles.Normal;
-        //                    FontWeightItem = FontWeights.Bold;
-        //                    break;
-
-        //                case "Italic":
-        //                    FontStyleItem = FontStyles.Italic;
-        //                    FontWeightItem = FontWeights.Normal;
-        //                    break;
-
-        //                case "Bold Italic":
-        //                    FontStyleItem = FontStyles.Italic;
-        //                    FontWeightItem = FontWeights.Bold;
-        //                    break;
-        //            }
-                    
-        //        }
-        //    }
-        //}
         public DelegateCommand<object> SelectedFillOpacityCommand { get; set; }
         public DelegateCommand<object> SelectedFontStyleCommand { get; set; }
         public DelegateCommand<object> SelectedColorCommand { get; set; }
         public DelegateCommand<object> SelectedFillColorCommand { get; set; }
         public DelegateCommand<object> FontFamilyChangedCommand { get; set; }
-        public DelegateCommand<object> FontStyleChangedCommand { get; set; }
+
         public DelegateCommand<object> FontSizeChangedCommand { get; set; }
         public DelegateCommand<object> TextAlignCheckedCommand { get; set; }
         public DelegateCommand<object> LineModeCheckedCommand { get; set; }
@@ -140,7 +93,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             SelectedColorCommand = new DelegateCommand<object>(SelectedColor_Command);
             SelectedFillColorCommand = new DelegateCommand<object>(SelectedFillColor_Command);
             FontFamilyChangedCommand = new DelegateCommand<object>(FontFamilyChanged_Command);
-            FontStyleChangedCommand = new DelegateCommand<object>(FontStyleChanged_Command);
             FontSizeChangedCommand = new DelegateCommand<object>(FontSizeChanged_Command);
             TextAlignCheckedCommand = new DelegateCommand<object>(TextAlignChecked);
             LineModeCheckedCommand = new DelegateCommand<object>(LineMode_Checked);
@@ -279,53 +231,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        private void FontStyleChanged_Command(object obj)
-        {
-            if (obj != null)
-            {
-                var item  = (ComboBoxItem)obj;
-                var content = (string)item.Content;
-                if (content != null)
-                {
-                    if (content == "Regular")
-                    {
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Normal);
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Normal);
-                       // TextFontWeights = FontWeights.Normal;
-                        //TextFontStyle = FontStyles.Normal;
-                    }
-
-
-                    if (content == "Bold")
-                    {
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Normal);
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Bold);
-                        //TextFontWeights = FontWeights.Bold;
-                       // TextFontStyle = FontStyles.Normal;
-                    }
-
-
-                    if (content == "Italic")
-                    {
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Italic);
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Normal);
-                       // TextFontWeights = FontWeights.Normal;
-                       // TextFontStyle = FontStyles.Italic;
-                    }
-
-                    if (content == "Bold Italic")
-                    {
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Italic);
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Bold);
-                        //TextFontWeights = FontWeights.Bold;
-                       // TextFontStyle = FontStyles.Italic;
-                    }
-
-                    AnnotEvent?.UpdateAnnot();
-                }
-            }
-        }
-
         private void FontFamilyChanged_Command(object obj)
         {
 
@@ -459,6 +364,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 LoadPropertyHandler?.Invoke(this, Annot);
                 ChangedValue -= FontMode_ChangedValue;
                 ChangedValue += FontMode_ChangedValue;
+                SelectColor = new SolidColorBrush(Annot.FontColor);
+                FillColor = new SolidColorBrush(Annot.BgColor);
                 IsCanSave = true;
             }
         }
@@ -470,22 +377,40 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 switch (e)
                 {
                     case FontSetModeType.PresetFontStyes:
-                        
+                        if (PresetFontList != null && sender is string == true)
+                        {
+                            var item = PresetFontList.FirstOrDefault(temp => temp.mTag == (string)sender);
+                            if (item != null && Annot != null)
+                            {
+                            }
+                        }
                         break;
                     case FontSetModeType.FontFamilys:
-                      
+                        if (sender is string == true)
+                        {
+                            AnnotEvent.UpdateAttrib(AnnotAttrib.FontFamily, (string)sender);
+                            AnnotEvent.UpdateAnnot();
+                        }
+
                         break;
                     case FontSetModeType.FontSizes:
-                       
+                        if (sender is double == true && (double)sender > 0 && Annot.FontSize > 0)
+                        {
+                            AnnotEvent.UpdateAttrib(AnnotAttrib.FontSize, (double)sender);
+                            AnnotEvent.UpdateAnnot();
+                        }
+
                         break;
                     case FontSetModeType.FontWeight_Style:
                         UpdateFontWeight_Style();
-                    
+                        AnnotEvent.UpdateAttrib(AnnotAttrib.FontWeight, FontWeightItem);
+                        AnnotEvent.UpdateAttrib(AnnotAttrib.FontStyle, FontStyleItem);
+                        AnnotEvent.UpdateAnnot();
                         break;
                     case FontSetModeType.FontColor:
                         if (sender is Color == true)
                         {
-                            AnnotEvent.UpdateAttrib(AnnotAttrib.FontColor, CurrentFontColor);
+                            AnnotEvent.UpdateAttrib(AnnotAttrib.FontColor, (SelectColor as SolidColorBrush).Color );
                             AnnotEvent.UpdateAnnot();
                         }
 

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

@@ -111,6 +111,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             set { SetProperty(ref sampleTextBg, value); 
                 if(Annot.EventType == AnnotArgsType.AnnotHighlight)
                 {
+                    CurrentColor = sampleTextBg;
                     AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (sampleTextBg as SolidColorBrush).Color);
                     AnnotEvent?.UpdateAnnot();
                 }
@@ -127,7 +128,17 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 SetProperty(ref selectColor, value);
                 AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (selectColor as SolidColorBrush).Color);
                 AnnotEvent?.UpdateAnnot();
-               // SetAnnotProperty(); 
+                CurrentColor = selectColor;
+            }
+        }
+
+        private Brush _currentColor = new SolidColorBrush(Colors.Transparent);
+        public Brush CurrentColor
+        {
+            get { return _currentColor; }
+            set
+            {
+                SetProperty(ref _currentColor, value);
             }
         }
 

+ 6 - 3
PDF Office/ViewModels/PropertyPanel/FontBoardVM.cs

@@ -207,15 +207,18 @@ namespace PDF_Office.ViewModels.PropertyPanel
                 SetProperty(ref selectColor, value);
                 if (IsCanSave)
                 {
-                    CurrentFontColor = (selectColor as SolidColorBrush).Color;
                     ChangedValue?.Invoke((selectColor as SolidColorBrush).Color, FontSetModeType.FontColor);
                 }
+                else
+                {
+                    CurrentFontColor = selectColor;
+                }
                     
             }
         }
 
-        private Color _currentFontColor = Colors.Black;
-        public Color CurrentFontColor
+        private Brush _currentFontColor =new SolidColorBrush(Colors.Transparent);
+        public Brush CurrentFontColor
         {
             get { return _currentFontColor; }
             set

+ 16 - 2
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml

@@ -355,7 +355,15 @@
                                 x:Name="FontColorBox"
                                 Width="56"
                                 HorizontalAlignment="Right"
-                                ShowColorList="Collapsed" />
+                                ShowColorList="Collapsed"  
+                                UIColor="{Binding CurrentFontColor,Mode=OneWay}"
+                            >
+                            <i:Interaction.Triggers>
+                                <i:EventTrigger EventName="SelectedColorInvoke">
+                                    <i:InvokeCommandAction Command="{Binding SelectedColorCommand}" CommandParameter="{Binding ElementName=FontColorBox,Path=SelectedColor}"/>
+                                </i:EventTrigger>
+                            </i:Interaction.Triggers>
+                        </cusColor:ColorContent>
                     </Grid>
                 </StackPanel>
             </StackPanel>
@@ -371,7 +379,13 @@
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </CompositeControl:SlidContent>
-                <CompositeControl:ColorContent Grid.Row="1" x:Name="cusColor"/>
+                <CompositeControl:ColorContent Grid.Row="1" x:Name="cusColor" UIColor="{Binding CurrentFillColor,Mode=OneWay}">
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="SelectedColorInvoke">
+                            <i:InvokeCommandAction Command="{Binding SelectedFillColorCommand}" CommandParameter="{Binding ElementName=cusColor,Path=SelectedColor}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </CompositeControl:ColorContent>
             </Grid>
 
 

+ 2 - 101
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml.cs

@@ -27,13 +27,10 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
         public FreetextAnnotProperty()
         {
             InitializeComponent();
-            //FontFamilyBox.SelectionChanged += FontFamilyBox_SelectionChanged;
-            //FontStyleBox.SelectionChanged += FontStyleBox_SelectionChanged;
-            //FontSizeBox.SelectionChanged += FontSizeBox_SelectionChanged;
-           
+
             this.Loaded += usercontrol_Loaded;
             this.Unloaded += usercontrol_Unloaded;
-            // layerThick.SelectedValueChanged += layerThick_SelectedValue;
+          
         }
 
         private void usercontrol_Loaded(object sender, RoutedEventArgs e)
@@ -54,15 +51,11 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
         {
             UnBindingEvent();
             ThicknessBox.SelectionChanged += ThicknessBox_SelectionChanged;
-            cusColor.SelectedColorHandler += cusColor_SelectedColorHandler;
-            FontColorBox.SelectedColorHandler += FontColorBox_SelectedColorHandler;
         }
 
         private void UnBindingEvent()
         {
             ThicknessBox.SelectionChanged -= ThicknessBox_SelectionChanged;
-            cusColor.SelectedColorHandler -= cusColor_SelectedColorHandler;
-            FontColorBox.SelectedColorHandler -= FontColorBox_SelectedColorHandler;
         }
 
         private void ThicknessBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -75,97 +68,5 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
            
         }
 
-        private void layerThick_SelectedValue(object sender, double e)
-        {
-            var data = this.DataContext as FreetextAnnotPropertyViewModel;
-            if (data != null)
-            {
-                data.SelectedFillOpacityCommand?.Execute(e);
-            }
-        }
-
-        private void FontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            //var listItem = FontSizeBox.ItemContainerGenerator.ContainerFromItem(FontSizeBox.SelectedItem) as ComboBoxItem;
-            //if (listItem != null)
-            //    FontSizeText.Text = listItem.Content.ToString();
-            //else
-            //    FontSizeText.Text = "6";
-           
-        }
-
-        private void FontStyleBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            //var listItem = FontStyleBox.ItemContainerGenerator.ContainerFromItem(FontStyleBox.SelectedItem) as ComboBoxItem;
-            //if (listItem != null)
-            //    FontStyleText.Text = listItem.Content.ToString();
-            //else
-            //    FontStyleText.Text = "Regular";
-          
-        }
-
-        private void FontFamilyBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            //var listItem = FontFamilyBox.ItemContainerGenerator.ContainerFromItem(FontFamilyBox.SelectedItem) as ComboBoxItem;
-            //if (listItem != null)
-            //    FontFamilyText.Text = (listItem.Content as TextBlock).Text;
-            //else
-            //    FontFamilyText.Text = "Courier New";
-        }
-
-        private void BtnTextAlign_Click(object sender, RoutedEventArgs e)
-        {
-
-            //var btn = sender as ToggleButton;
-            //foreach(var item in ToolGrid.Children)
-            //{
-            //    var btnItem = item as ToggleButton;
-            //    if(btnItem != null)
-            //    {
-            //        if(btn!= btnItem)
-            //            btnItem.IsChecked = false;
-            //        else
-            //            btnItem.IsChecked = true;
-            //    }
-            //}
-           
-        }
-
-        private void BtnLineStyle_Click(object sender, RoutedEventArgs e)
-        {
-            //var btn = sender as CustomIconToggleBtn;
-            //foreach (var item in PnlLineStyle.Children)
-            //{
-            //    var btnItem = item as CustomIconToggleBtn;
-            //    if (btnItem != null)
-            //    {
-            //        if (btn != btnItem)
-            //            btnItem.IsChecked = false;
-            //        else
-            //            btnItem.IsChecked = true;
-            //    }
-            //}
-        }
-
-        private void FontColorBox_SelectedColorChanged(object sender, Color? e)
-        {
-           
-        }
-
-        private void cusColor_SelectedColorHandler(object sender, Color e)
-        {
-            var data = this.DataContext as FreetextAnnotPropertyViewModel;
-            if (data != null)
-                data.SelectedFillColorCommand?.Execute(e);
-        }
-
-        private void FontColorBox_SelectedColorHandler(object sender, Color e)
-        {
-            var data = this.DataContext as FreetextAnnotPropertyViewModel;
-            if (data != null)
-                data.SelectedColorCommand?.Execute(e);
-        }
-
-
     }
 }

+ 7 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/TextAnnotProperty.xaml

@@ -70,7 +70,13 @@
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </CompositeControl:SlidContent>
-                <CompositeControl:ColorContent Grid.Row="1" x:Name="cusColor" />
+                <CompositeControl:ColorContent Grid.Row="1" x:Name="cusColor" UIColor="{Binding CurrentColor,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>
             
         </StackPanel>

+ 0 - 44
PDF Office/Views/PropertyPanel/AnnotPanel/TextAnnotProperty.xaml.cs

@@ -29,8 +29,6 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
         public TextAnnotProperty()
         {
             InitializeComponent();
-            cusColor.SelectedColorHandler += cusColor_SelectedColor;
-          //  SlidOpacity.SelectedValueChanged += SlidOpacity_SelectedValue;
             ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
         }
 
@@ -44,7 +42,6 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
                         var annot = item as TextHighlightAnnotArgs;
                         if (annot != null)
                         {
-                            cusColor.SelectedColor=annot.Color;
                             SlidOpacity.SetSliOpacity(annot.Transparency);
                         }
                         break;
@@ -55,7 +52,6 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
                         var annot = item as TextUnderlineAnnotArgs;
                         if (annot != null)
                         {
-                            cusColor.SelectedColor=annot.Color;
                             SlidOpacity.SetSliOpacity(annot.Transparency);
                         }
                         break;
@@ -66,7 +62,6 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
                         var annot = item as TextStrikeoutAnnotArgs;
                         if (annot != null)
                         {
-                            cusColor.SelectedColor=annot.Color;
                             SlidOpacity.SetSliOpacity(annot.Transparency);
                         }
                         break;
@@ -74,46 +69,7 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             }
         }
 
-        private void SlidOpacity_SelectedValue(object sender, double e)
-        {
-            if (ViewModel != null)
-            {
-             //   ViewModel.SelectedValueChangedCommand?.Execute(e);
-            }
-        }
-
-        private void cusColor_SelectedColor(object sender, Color e)
-        { 
-            if (ViewModel != null)
-            {
-                ViewModel.SelectedColorChangedCommand?.Execute(e); 
-            }
-        }
-
-        private void OpacitySlider_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
-        {
-
-        }
-
-        private void OpacitySlider_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
-        {
-
-        }
-
-        private void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
-        {
-
-        }
-
-        private void ColorDropPicker_SelectedColorChanged(object sender, Color? e)
-        {
-            if(ViewModel != null)
-            {
-                ViewModel.SelectedColorChangedCommand?.Execute(e.Value);
-            }
-        }
 
-     
     }
    
 }