|
@@ -20,7 +20,7 @@ using System.Windows.Shapes;
|
|
|
|
|
|
namespace PDF_Master.CustomControl.CompositeControl
|
|
|
{
|
|
|
- public class ColorItem: BindableBase
|
|
|
+ public class ColorItem : BindableBase
|
|
|
{
|
|
|
public int Index = 0;
|
|
|
private Brush _color;
|
|
@@ -54,7 +54,7 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public ColorItem(Color color,int index = 0)
|
|
|
+ public ColorItem(Color color, int index = 0)
|
|
|
{
|
|
|
var colorBrush = new SolidColorBrush(color);
|
|
|
Color = colorBrush;
|
|
@@ -91,8 +91,16 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
}
|
|
|
|
|
|
public static readonly DependencyProperty ColorTypeProperty =
|
|
|
- DependencyProperty.Register("ColorType", typeof(ColorSelectorType), typeof(ColorContent), new PropertyMetadata(ColorSelectorType.Highlight));
|
|
|
+ DependencyProperty.Register("ColorType", typeof(ColorSelectorType), typeof(ColorContent), new PropertyMetadata(ColorSelectorType.Highlight));
|
|
|
+
|
|
|
+ public bool IsColorDropPickerClick
|
|
|
+ {
|
|
|
+ get { return (bool)GetValue(IsColorDropPickerClickProperty); }
|
|
|
+ set { SetValue(IsColorDropPickerClickProperty, value); }
|
|
|
+ }
|
|
|
|
|
|
+ public static readonly DependencyProperty IsColorDropPickerClickProperty =
|
|
|
+ DependencyProperty.Register("IsColorDropPickerClick", typeof(bool), typeof(ColorContent), new PropertyMetadata(true));
|
|
|
|
|
|
/// <summary>
|
|
|
/// 选中项的颜色,当前颜色
|
|
@@ -114,7 +122,7 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
}
|
|
|
|
|
|
public static readonly DependencyProperty ceshiColorProperty =
|
|
|
- DependencyProperty.Register("UIColor", typeof(Brush), typeof(ColorContent), new PropertyMetadata(new SolidColorBrush(Color.FromArgb(0x6C,0x33,0xF8,0xCC)), SelectedColorPropertyChanged));
|
|
|
+ DependencyProperty.Register("UIColor", typeof(Brush), typeof(ColorContent), new PropertyMetadata(new SolidColorBrush(Color.FromArgb(0x6C, 0x33, 0xF8, 0xCC)), SelectedColorPropertyChanged));
|
|
|
|
|
|
public Brush DefaultColor
|
|
|
{
|
|
@@ -170,15 +178,15 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
var control = d as ColorContent;
|
|
|
var co = (SolidColorBrush)e.NewValue;
|
|
|
bool isFoundListItem = false;
|
|
|
- if(control != null)
|
|
|
+ if (control != null)
|
|
|
{
|
|
|
- if(control.ShowColorList == Visibility.Collapsed)
|
|
|
+ if (control.ShowColorList == Visibility.Collapsed)
|
|
|
{
|
|
|
control.ElcustomColor.Fill = co;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- foreach(var item in control.colors)
|
|
|
+ foreach (var item in control.colors)
|
|
|
{
|
|
|
if (co == null) { break; }
|
|
|
var colorItem = (item.Color as SolidColorBrush).Color;
|
|
@@ -186,9 +194,10 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
{
|
|
|
control.ListColor.SelectedItem = item;
|
|
|
control.SelectedColor = colorItem;
|
|
|
- control.Grid_Color.Background= new SolidColorBrush(Color.FromArgb(0x00, 0xff, 0xFf, 0xff));
|
|
|
+ if (control.IsColorDropPickerClick)
|
|
|
+ control.Grid_Color.Background = new SolidColorBrush(Color.FromArgb(0x00, 0xff, 0xFf, 0xff));
|
|
|
if (control.ElcustomColor.Fill == null) { control.ElcustomColor.Fill = co; }
|
|
|
-
|
|
|
+
|
|
|
isFoundListItem = true;
|
|
|
break;
|
|
|
}
|
|
@@ -198,7 +207,8 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
{
|
|
|
control.ElcustomColor.Fill = co;
|
|
|
control.DefaultColor = co;
|
|
|
- control.Grid_Color.Background = new SolidColorBrush(Color.FromArgb(0xff, 0xe2, 0xe3, 0xe5));
|
|
|
+ if (control.IsColorDropPickerClick)
|
|
|
+ control.Grid_Color.Background = new SolidColorBrush(Color.FromArgb(0xff, 0xe2, 0xe3, 0xe5));
|
|
|
control.DefaultColorInvoke?.Invoke(co.Color, null);
|
|
|
control.ListColor.SelectedItem = null;
|
|
|
}
|
|
@@ -209,16 +219,17 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
colors.Add(new ColorItem(Color.FromArgb(0xFF, 0xFF, 0xFF, 0x10)));
|
|
|
- colors.Add(new ColorItem(Color.FromArgb(0xFF, 0xFF, 0x10, 0x10)));
|
|
|
+ colors.Add(new ColorItem(Color.FromArgb(0xFF, 0xFF, 0x10, 0x10)));
|
|
|
colors.Add(new ColorItem(Color.FromArgb(0xFF, 0x10, 0xFF, 0x10)));
|
|
|
- colors.Add(new ColorItem(Color.FromArgb(0xFF, 0x10, 0x70, 0xFF)));
|
|
|
+ colors.Add(new ColorItem(Color.FromArgb(0xFF, 0x10, 0x70, 0xFF)));
|
|
|
ListColor.ItemsSource = colors;
|
|
|
}
|
|
|
|
|
|
private void ColorDropPicker_SelectedColorChanged(object sender, Color? e)
|
|
|
{
|
|
|
- if (ElcustomColor.Fill == null) {
|
|
|
- ElcustomColor.Fill= new SolidColorBrush(Colors.Transparent);
|
|
|
+ if (ElcustomColor.Fill == null)
|
|
|
+ {
|
|
|
+ ElcustomColor.Fill = new SolidColorBrush(Colors.Transparent);
|
|
|
}
|
|
|
IsExistForContainer((ElcustomColor.Fill as SolidColorBrush).Color);
|
|
|
SelectedColorHandler?.Invoke(this, e.Value);
|
|
@@ -229,8 +240,8 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
}
|
|
|
|
|
|
private void ListColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
+ {
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void listboxItem_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
@@ -241,8 +252,8 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
var selectCo = (item.Color as SolidColorBrush).Color;
|
|
|
SelectedColor = selectCo;
|
|
|
SelectedColorHandler?.Invoke(this, selectCo);
|
|
|
- SelectedColorInvoke?.Invoke(selectCo, null);
|
|
|
-
|
|
|
+ SelectedColorInvoke?.Invoke(selectCo, null);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -299,7 +310,7 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
|
|
|
if (newColor.A != oldColor.A || newColor.B != oldColor.B || newColor.R != oldColor.R || newColor.G != oldColor.G)
|
|
|
{
|
|
|
- if(ColorType != ColorSelectorType.None)
|
|
|
+ if (ColorType != ColorSelectorType.None)
|
|
|
{
|
|
|
ColorSelectorItem selectorItem = new ColorSelectorItem();
|
|
|
selectorItem.SelectorType = ColorType;
|
|
@@ -310,23 +321,23 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
}
|
|
|
|
|
|
colorIem.RestoreColor();
|
|
|
- if(colorIem == ListColor.SelectedItem as ColorItem)
|
|
|
+ if (colorIem == ListColor.SelectedItem as ColorItem)
|
|
|
{
|
|
|
SelectedColorHandler?.Invoke(this, (colorIem.Color as SolidColorBrush).Color);
|
|
|
SelectedColorInvoke?.Invoke((colorIem.Color as SolidColorBrush).Color, null);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void listboxItem_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
- {
|
|
|
+ {
|
|
|
e.Handled = true;
|
|
|
- }
|
|
|
-
|
|
|
- //外部把颜色值传回来作为当前值
|
|
|
+ }
|
|
|
+
|
|
|
+ //外部把颜色值传回来作为当前值
|
|
|
public void SetSelectedColor(Color newColor)
|
|
|
{
|
|
|
if (newColor != null)
|
|
@@ -361,20 +372,22 @@ namespace PDF_Master.CustomControl.CompositeControl
|
|
|
|
|
|
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
- Grid_Color.Background = new SolidColorBrush(Color.FromArgb(0xff, 0xe2, 0xe3, 0xe5));
|
|
|
+ if (IsColorDropPickerClick)
|
|
|
+ Grid_Color.Background = new SolidColorBrush(Color.FromArgb(0xff, 0xe2, 0xe3, 0xe5));
|
|
|
if (ElcustomColor.Fill == null)
|
|
|
{
|
|
|
ElcustomColor.Fill = new SolidColorBrush(Colors.Transparent);
|
|
|
}
|
|
|
- Color ecolor=new Color();
|
|
|
+ Color ecolor = new Color();
|
|
|
if (defaultColor.Visibility == Visibility.Visible)
|
|
|
{
|
|
|
ecolor = (defaultColor.Fill as SolidColorBrush).Color;
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
ecolor = (ElcustomColor.Fill as SolidColorBrush).Color;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
IsExistForContainer((ElcustomColor.Fill as SolidColorBrush).Color);
|
|
|
SelectedColorHandler?.Invoke(this, ecolor);
|
|
|
ElcustomColor.Fill = new SolidColorBrush(ecolor);
|