diff --git a/UserInterface/ColorSelector.xaml b/UserInterface/ColorSelector.xaml new file mode 100644 index 0000000..63aed34 --- /dev/null +++ b/UserInterface/ColorSelector.xaml @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/UserInterface/ColorSelector.xaml.cs b/UserInterface/ColorSelector.xaml.cs new file mode 100644 index 0000000..a6b5bc5 --- /dev/null +++ b/UserInterface/ColorSelector.xaml.cs @@ -0,0 +1,86 @@ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +#nullable enable + +namespace SystemTrayMenu.UserInterface +{ + using System; + using System.Diagnostics; + using System.Text.RegularExpressions; + using System.Windows; + using System.Windows.Controls; + using System.Windows.Input; + using System.Windows.Media; + + /// + /// Logic of ColorSelector . + /// + public partial class ColorSelector : UserControl + { + public ColorSelector() + { + InitializeComponent(); + label.Content = string.Empty; + } + + public event Action? ColorChanged; + + public string Text + { + get + { + try + { + Color color = (Color)ColorConverter.ConvertFromString(txtbox.Text.Trim()); + return txtbox.Text.Trim(); + } + catch + { + return Colors.White.ToString(); + } + } + + set + { + txtbox.Text = value; + } + } + + public string Description + { + get => (string)label.Content; + set => label.Content = value ?? string.Empty; + } + + private void Txtbox_TextChanged(object sender, TextChangedEventArgs e) + { + try + { + Color color = (Color)ColorConverter.ConvertFromString(txtbox.Text.Trim()); + pane.Background = new SolidColorBrush(color); + } + catch + { + return; + } + + ColorChanged?.Invoke(this); + } + +#if TODO + private void PictureBoxClick(object sender, EventArgs e) + { + PictureBox pictureBox = (PictureBox)sender; + TextBox textBox = (TextBox)pictureBox.Tag; + colorDialog.Color = pictureBox.BackColor; + if (colorDialog.ShowDialog() == DialogResult.OK) + { + textBox.Text = ColorTranslator.ToHtml(colorDialog.Color); + pictureBox.BackColor = colorDialog.Color; + } + } +#endif + } +} diff --git a/UserInterface/NumericUpDown.xaml b/UserInterface/NumericUpDown.xaml index b048477..2f08170 100644 --- a/UserInterface/NumericUpDown.xaml +++ b/UserInterface/NumericUpDown.xaml @@ -1,11 +1,11 @@  - @@ -17,7 +17,7 @@ -