You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
using System.Windows.Controls; |
|
using System.Windows.Input; |
|
using System.Windows.Media; |
|
using HandyControl.Controls; |
|
using HandyControl.Tools; |
|
|
|
namespace SparkClient.Views.Configuration.SettingPages; |
|
|
|
public partial class ModelColorSetPage |
|
{ |
|
public ModelColorSetPage() |
|
{ |
|
InitializeComponent(); |
|
} |
|
|
|
private void LabelsColor_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
{ |
|
if (sender is Label label) |
|
{ |
|
var picker = SingleOpenHelper.CreateControl<ColorPicker>(); |
|
var window = new PopupWindow |
|
{ |
|
PopupElement = picker |
|
}; |
|
picker.SelectedBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString((label.Content??"#FFFFFF").ToString())); |
|
picker.Canceled += delegate { window.Close(); }; |
|
picker.Confirmed += delegate |
|
{ |
|
label.Background = picker.SelectedBrush; |
|
label.Foreground = picker.SelectedBrush; |
|
label.Content = picker.SelectedBrush.ToString(); |
|
|
|
window.Close(); |
|
}; |
|
window.Show(label, false); |
|
} |
|
} |
|
|
|
public SolidColorBrush GetInverseBrush(SolidColorBrush selectedBrush) |
|
{ |
|
Color originalColor = selectedBrush.Color; |
|
Color inverseColor = Color.FromRgb((byte)(255 - originalColor.R), |
|
(byte)(255 - originalColor.G), |
|
(byte)(255 - originalColor.B)); |
|
return new SolidColorBrush(inverseColor); |
|
} |
|
} |