Handle ComboCheckBoxes in AdministrationWindow
This commit is contained in:
@ -65,31 +65,31 @@ namespace Elwig.Helpers {
|
|||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetInputChanged(Control input) {
|
private static void SetControlBrush(Control input, Brush brush) {
|
||||||
var brush = Brushes.Orange;
|
|
||||||
if (input is ComboBox cb) {
|
if (input is ComboBox cb) {
|
||||||
var border = GetComboBoxBorder(cb);
|
var border = GetComboBoxBorder(cb);
|
||||||
if (border != null)
|
if (border != null) border.BorderBrush = brush;
|
||||||
border.BorderBrush = brush;
|
} else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
||||||
|
var border = GetComboBoxBorder(ccb);
|
||||||
|
if (border != null) border.BorderBrush = brush;
|
||||||
} else {
|
} else {
|
||||||
input.BorderBrush = brush;
|
input.BorderBrush = brush;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetInputChanged(Control input) {
|
||||||
|
SetControlBrush(input, Brushes.Orange);
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetInputInvalid(Control input) {
|
public static void SetInputInvalid(Control input) {
|
||||||
var brush = Brushes.Red;
|
SetControlBrush(input, Brushes.Red);
|
||||||
if (input is ComboBox cb) {
|
|
||||||
var border = GetComboBoxBorder(cb);
|
|
||||||
if (border != null)
|
|
||||||
border.BorderBrush = brush;
|
|
||||||
} else {
|
|
||||||
input.BorderBrush = brush;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ClearInputState(Control input) {
|
public static void ClearInputState(Control input) {
|
||||||
if (input is ComboBox cb) {
|
if (input is ComboBox cb) {
|
||||||
GetComboBoxBorder(cb)?.ClearValue(Border.BorderBrushProperty);
|
GetComboBoxBorder(cb)?.ClearValue(Border.BorderBrushProperty);
|
||||||
|
} else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
||||||
|
GetComboBoxBorder(ccb)?.ClearValue(Border.BorderBrushProperty);
|
||||||
} else {
|
} else {
|
||||||
input.ClearValue(Control.BorderBrushProperty);
|
input.ClearValue(Control.BorderBrushProperty);
|
||||||
}
|
}
|
||||||
@ -100,6 +100,11 @@ namespace Elwig.Helpers {
|
|||||||
return toggleButton?.Template.FindName("templateRoot", toggleButton) as Border;
|
return toggleButton?.Template.FindName("templateRoot", toggleButton) as Border;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Border? GetComboBoxBorder(Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
||||||
|
var toggleButton = ccb.Template.FindName("toggleButton", ccb) as ToggleButton;
|
||||||
|
return toggleButton?.Template.FindName("templateRoot", toggleButton) as Border;
|
||||||
|
}
|
||||||
|
|
||||||
public static IEnumerable<T> FindAllChildren<T>(DependencyObject depObj) where T : DependencyObject {
|
public static IEnumerable<T> FindAllChildren<T>(DependencyObject depObj) where T : DependencyObject {
|
||||||
if (depObj == null)
|
if (depObj == null)
|
||||||
yield return (T)Enumerable.Empty<T>();
|
yield return (T)Enumerable.Empty<T>();
|
||||||
|
@ -107,7 +107,8 @@ namespace Elwig.Windows {
|
|||||||
Utils.ClearInputState(tb);
|
Utils.ClearInputState(tb);
|
||||||
foreach (var cb in ComboBoxInputs)
|
foreach (var cb in ComboBoxInputs)
|
||||||
Utils.ClearInputState(cb);
|
Utils.ClearInputState(cb);
|
||||||
// TODO ComboCheckBox
|
foreach (var ccb in CheckComboBoxInputs)
|
||||||
|
Utils.ClearInputState(ccb);
|
||||||
foreach (var cb in CheckBoxInputs)
|
foreach (var cb in CheckBoxInputs)
|
||||||
Utils.ClearInputState(cb);
|
Utils.ClearInputState(cb);
|
||||||
foreach (var rb in RadioButtonInputs)
|
foreach (var rb in RadioButtonInputs)
|
||||||
@ -126,8 +127,10 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void LockInputs() {
|
protected void LockInputs() {
|
||||||
foreach (var tb in TextBoxInputs)
|
foreach (var tb in TextBoxInputs) {
|
||||||
tb.IsReadOnly = true;
|
tb.IsReadOnly = true;
|
||||||
|
tb.Focusable = false;
|
||||||
|
}
|
||||||
foreach (var cb in ComboBoxInputs)
|
foreach (var cb in ComboBoxInputs)
|
||||||
cb.IsEnabled = false;
|
cb.IsEnabled = false;
|
||||||
foreach (var ccb in CheckComboBoxInputs)
|
foreach (var ccb in CheckComboBoxInputs)
|
||||||
@ -139,8 +142,10 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void UnlockInputs() {
|
protected void UnlockInputs() {
|
||||||
foreach (var tb in TextBoxInputs)
|
foreach (var tb in TextBoxInputs) {
|
||||||
tb.IsReadOnly = false;
|
tb.IsReadOnly = false;
|
||||||
|
tb.Focusable = true;
|
||||||
|
}
|
||||||
foreach (var cb in ComboBoxInputs)
|
foreach (var cb in ComboBoxInputs)
|
||||||
cb.IsEnabled = true;
|
cb.IsEnabled = true;
|
||||||
foreach (var ccb in CheckComboBoxInputs)
|
foreach (var ccb in CheckComboBoxInputs)
|
||||||
@ -160,7 +165,8 @@ namespace Elwig.Windows {
|
|||||||
OriginalValues[tb] = tb.Text;
|
OriginalValues[tb] = tb.Text;
|
||||||
foreach (var cb in ComboBoxInputs)
|
foreach (var cb in ComboBoxInputs)
|
||||||
OriginalValues[cb] = cb.SelectedItem;
|
OriginalValues[cb] = cb.SelectedItem;
|
||||||
// TODO ComboCheckBox
|
foreach (var ccb in CheckComboBoxInputs)
|
||||||
|
OriginalValues[ccb] = ccb.SelectedItems.Cast<object>().ToArray();
|
||||||
foreach (var cb in CheckBoxInputs)
|
foreach (var cb in CheckBoxInputs)
|
||||||
OriginalValues[cb] = (cb.IsChecked ?? false) ? bool.TrueString : null;
|
OriginalValues[cb] = (cb.IsChecked ?? false) ? bool.TrueString : null;
|
||||||
foreach (var rb in RadioButtonInputs)
|
foreach (var rb in RadioButtonInputs)
|
||||||
@ -180,6 +186,8 @@ namespace Elwig.Windows {
|
|||||||
tb.Text = "";
|
tb.Text = "";
|
||||||
foreach (var cb in ComboBoxInputs)
|
foreach (var cb in ComboBoxInputs)
|
||||||
cb.SelectedItem = null;
|
cb.SelectedItem = null;
|
||||||
|
foreach (var ccb in CheckComboBoxInputs)
|
||||||
|
ccb.SelectedItems.Clear();
|
||||||
foreach (var cb in CheckBoxInputs)
|
foreach (var cb in CheckBoxInputs)
|
||||||
cb.IsChecked = false;
|
cb.IsChecked = false;
|
||||||
foreach (var rb in RadioButtonInputs)
|
foreach (var rb in RadioButtonInputs)
|
||||||
@ -200,6 +208,8 @@ namespace Elwig.Windows {
|
|||||||
return OriginalValues[tb]?.ToString() != tb.Text;
|
return OriginalValues[tb]?.ToString() != tb.Text;
|
||||||
} else if (input is ComboBox sb) {
|
} else if (input is ComboBox sb) {
|
||||||
return OriginalValues[sb] != sb.SelectedItem;
|
return OriginalValues[sb] != sb.SelectedItem;
|
||||||
|
} else if (input is CheckComboBox ccb) {
|
||||||
|
return !ccb.SelectedItems.Cast<object>().ToArray().SequenceEqual(((object[]?)OriginalValues[ccb]) ?? Array.Empty<object>());
|
||||||
} else if (input is CheckBox cb) {
|
} else if (input is CheckBox cb) {
|
||||||
return (OriginalValues[cb] != null) != (cb.IsChecked ?? false);
|
return (OriginalValues[cb] != null) != (cb.IsChecked ?? false);
|
||||||
} else if (input is RadioButton rb) {
|
} else if (input is RadioButton rb) {
|
||||||
|
Reference in New Issue
Block a user