rote rahmen für req im fallabschluss
This commit is contained in:
@@ -21,8 +21,17 @@ using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
public partial class CloseTicketDialog : UserControl
|
||||
{
|
||||
public partial class CloseTicketDialog : UserControl
|
||||
{
|
||||
private static readonly Brush ValidationBrush = CreateValidationBrush();
|
||||
private static Brush CreateValidationBrush()
|
||||
{
|
||||
var brush = new SolidColorBrush(Color.FromRgb(0xF5, 0x7C, 0x73));
|
||||
if (brush.CanFreeze)
|
||||
brush.Freeze();
|
||||
return brush;
|
||||
}
|
||||
private Brush defaultErrorTypeBorderBrush;
|
||||
#region Properties
|
||||
|
||||
public event EventHandler ErrorTypeValueChanged;
|
||||
@@ -68,21 +77,33 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for SelectedErrorType. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty SelectedErrorTypeProperty =
|
||||
DependencyProperty.Register("SelectedErrorType", typeof(ComboBoxItem), typeof(CloseTicketDialog), new PropertyMetadata(null, OnSelectedErrorTypeChanged));
|
||||
private static void OnSelectedErrorTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var control = (CloseTicketDialog)d;
|
||||
control.ErrorTypeValueChanged?.Invoke(control, EventArgs.Empty);
|
||||
}
|
||||
public static readonly DependencyProperty SelectedErrorTypeProperty =
|
||||
DependencyProperty.Register("SelectedErrorType", typeof(ComboBoxItem), typeof(CloseTicketDialog), new PropertyMetadata(null, OnSelectedErrorTypeChanged));
|
||||
private static void OnSelectedErrorTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is CloseTicketDialog control))
|
||||
return;
|
||||
|
||||
var newItem = e.NewValue as ComboBoxItem;
|
||||
bool hasError = newItem == null || newItem.Tag == null;
|
||||
|
||||
if (control.ErrorTypeComboBox != null && !Equals(control.ErrorTypeComboBox.SelectedItem, newItem))
|
||||
{
|
||||
control.ErrorTypeComboBox.SelectedItem = newItem;
|
||||
}
|
||||
|
||||
control.UpdateErrorTypeValidationState(hasError);
|
||||
control.ErrorTypeValueChanged?.Invoke(control, EventArgs.Empty);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public CloseTicketDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public CloseTicketDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
defaultErrorTypeBorderBrush = ErrorTypeValidationBorder?.BorderBrush?.CloneCurrentValue();
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
@@ -170,11 +191,36 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
}
|
||||
|
||||
private void ErrorTypeComboBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if(e.Key == Key.Escape) {
|
||||
DropDownClosed(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ErrorTypeComboBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if(e.Key == Key.Escape) {
|
||||
DropDownClosed(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void ErrorTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var selected = ErrorTypeComboBox?.SelectedItem as ComboBoxItem;
|
||||
|
||||
if (!Equals(SelectedErrorType, selected))
|
||||
{
|
||||
SelectedErrorType = selected;
|
||||
return;
|
||||
}
|
||||
|
||||
bool hasError = selected == null || selected.Tag == null;
|
||||
UpdateErrorTypeValidationState(hasError);
|
||||
}
|
||||
|
||||
public void UpdateErrorTypeValidationState(bool hasError)
|
||||
{
|
||||
if (ErrorTypeValidationBorder == null)
|
||||
return;
|
||||
|
||||
if (defaultErrorTypeBorderBrush == null)
|
||||
defaultErrorTypeBorderBrush = ErrorTypeValidationBorder.BorderBrush?.CloneCurrentValue();
|
||||
|
||||
ErrorTypeValidationBorder.BorderBrush = hasError ? ValidationBrush : defaultErrorTypeBorderBrush;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user