Compare commits
2 Commits
d43633cb65
...
75322da405
| Author | SHA1 | Date | |
|---|---|---|---|
| 75322da405 | |||
| 9ba45e58f6 |
+17
-12
@@ -65,31 +65,31 @@ namespace Elwig.Helpers {
|
||||
return client;
|
||||
}
|
||||
|
||||
public static void SetInputChanged(Control input) {
|
||||
var brush = Brushes.Orange;
|
||||
private static void SetControlBrush(Control input, Brush brush) {
|
||||
if (input is ComboBox cb) {
|
||||
var border = GetComboBoxBorder(cb);
|
||||
if (border != null)
|
||||
border.BorderBrush = brush;
|
||||
if (border != null) border.BorderBrush = brush;
|
||||
} else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
||||
var border = GetComboBoxBorder(ccb);
|
||||
if (border != null) border.BorderBrush = brush;
|
||||
} else {
|
||||
input.BorderBrush = brush;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetInputChanged(Control input) {
|
||||
SetControlBrush(input, Brushes.Orange);
|
||||
}
|
||||
|
||||
public static void SetInputInvalid(Control input) {
|
||||
var brush = Brushes.Red;
|
||||
if (input is ComboBox cb) {
|
||||
var border = GetComboBoxBorder(cb);
|
||||
if (border != null)
|
||||
border.BorderBrush = brush;
|
||||
} else {
|
||||
input.BorderBrush = brush;
|
||||
}
|
||||
SetControlBrush(input, Brushes.Red);
|
||||
}
|
||||
|
||||
public static void ClearInputState(Control input) {
|
||||
if (input is ComboBox cb) {
|
||||
GetComboBoxBorder(cb)?.ClearValue(Border.BorderBrushProperty);
|
||||
} else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
||||
GetComboBoxBorder(ccb)?.ClearValue(Border.BorderBrushProperty);
|
||||
} else {
|
||||
input.ClearValue(Control.BorderBrushProperty);
|
||||
}
|
||||
@@ -100,6 +100,11 @@ namespace Elwig.Helpers {
|
||||
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 {
|
||||
if (depObj == null)
|
||||
yield return (T)Enumerable.Empty<T>();
|
||||
|
||||
@@ -107,7 +107,8 @@ namespace Elwig.Windows {
|
||||
Utils.ClearInputState(tb);
|
||||
foreach (var cb in ComboBoxInputs)
|
||||
Utils.ClearInputState(cb);
|
||||
// TODO ComboCheckBox
|
||||
foreach (var ccb in CheckComboBoxInputs)
|
||||
Utils.ClearInputState(ccb);
|
||||
foreach (var cb in CheckBoxInputs)
|
||||
Utils.ClearInputState(cb);
|
||||
foreach (var rb in RadioButtonInputs)
|
||||
@@ -126,8 +127,10 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected void LockInputs() {
|
||||
foreach (var tb in TextBoxInputs)
|
||||
foreach (var tb in TextBoxInputs) {
|
||||
tb.IsReadOnly = true;
|
||||
tb.Focusable = false;
|
||||
}
|
||||
foreach (var cb in ComboBoxInputs)
|
||||
cb.IsEnabled = false;
|
||||
foreach (var ccb in CheckComboBoxInputs)
|
||||
@@ -139,8 +142,10 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected void UnlockInputs() {
|
||||
foreach (var tb in TextBoxInputs)
|
||||
foreach (var tb in TextBoxInputs) {
|
||||
tb.IsReadOnly = false;
|
||||
tb.Focusable = true;
|
||||
}
|
||||
foreach (var cb in ComboBoxInputs)
|
||||
cb.IsEnabled = true;
|
||||
foreach (var ccb in CheckComboBoxInputs)
|
||||
@@ -160,7 +165,8 @@ namespace Elwig.Windows {
|
||||
OriginalValues[tb] = tb.Text;
|
||||
foreach (var cb in ComboBoxInputs)
|
||||
OriginalValues[cb] = cb.SelectedItem;
|
||||
// TODO ComboCheckBox
|
||||
foreach (var ccb in CheckComboBoxInputs)
|
||||
OriginalValues[ccb] = ccb.SelectedItems.Cast<object>().ToArray();
|
||||
foreach (var cb in CheckBoxInputs)
|
||||
OriginalValues[cb] = (cb.IsChecked ?? false) ? bool.TrueString : null;
|
||||
foreach (var rb in RadioButtonInputs)
|
||||
@@ -180,6 +186,8 @@ namespace Elwig.Windows {
|
||||
tb.Text = "";
|
||||
foreach (var cb in ComboBoxInputs)
|
||||
cb.SelectedItem = null;
|
||||
foreach (var ccb in CheckComboBoxInputs)
|
||||
ccb.SelectedItems.Clear();
|
||||
foreach (var cb in CheckBoxInputs)
|
||||
cb.IsChecked = false;
|
||||
foreach (var rb in RadioButtonInputs)
|
||||
@@ -200,6 +208,8 @@ namespace Elwig.Windows {
|
||||
return OriginalValues[tb]?.ToString() != tb.Text;
|
||||
} else if (input is ComboBox sb) {
|
||||
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) {
|
||||
return (OriginalValues[cb] != null) != (cb.IsChecked ?? false);
|
||||
} else if (input is RadioButton rb) {
|
||||
|
||||
@@ -94,19 +94,25 @@
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Button x:Name="NewMemberButton" Content="Neu" Click="NewMemberButton_Click"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"/>
|
||||
<Button x:Name="EditMemberButton" Content="Bearbeiten" Click="EditMemberButton_Click" IsEnabled="False"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"/>
|
||||
<Button x:Name="DeleteMemberButton" Content="Löschen" Click="DeleteMemberButton_Click" IsEnabled="False"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"/>
|
||||
<Button x:Name="NewMemberButton" Content="Neu"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
|
||||
Click="NewMemberButton_Click"/>
|
||||
<Button x:Name="EditMemberButton" Content="Bearbeiten" IsEnabled="False"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"
|
||||
Click="EditMemberButton_Click"/>
|
||||
<Button x:Name="DeleteMemberButton" Content="Löschen" IsEnabled="False"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"
|
||||
Click="DeleteMemberButton_Click"/>
|
||||
|
||||
<Button x:Name="SaveButton" Content="Speichern" Click="SaveButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"/>
|
||||
<Button x:Name="ResetButton" Content="Zurücksetzen" Click="ResetButton_Click" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"/>
|
||||
<Button x:Name="CancelButton" Content="Abbrechen" Click="CancelButton_Click" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"/>
|
||||
<Button x:Name="SaveButton" Content="Speichern" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
|
||||
Click="SaveButton_Click"/>
|
||||
<Button x:Name="ResetButton" Content="Zurücksetzen" IsEnabled="False" Visibility="Hidden"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"
|
||||
Click="ResetButton_Click"/>
|
||||
<Button x:Name="CancelButton" Content="Abbrechen" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"
|
||||
Click="CancelButton_Click"/>
|
||||
</Grid>
|
||||
|
||||
<GroupBox Header="Persönliche Daten" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" Margin="5,5,5,5">
|
||||
|
||||
@@ -30,8 +30,6 @@ namespace Elwig.Windows {
|
||||
CommandBindings.Add(new CommandBinding(CtrlF, FocusSearchInput));
|
||||
ExemptInputs = new Control[] {
|
||||
SearchInput, ActiveMemberInput, MemberList,
|
||||
NewMemberButton, EditMemberButton, DeleteMemberButton,
|
||||
ResetButton, SaveButton, CancelButton
|
||||
};
|
||||
RequiredInputs = new Control[] {
|
||||
MgNrInput, GivenNameInput, FamilyNameInput,
|
||||
@@ -74,12 +72,14 @@ namespace Elwig.Windows {
|
||||
List<Member> members = await memberQuery.ToListAsync();
|
||||
|
||||
if (TextFilter.Count > 0) {
|
||||
members = members
|
||||
var dict = members
|
||||
.ToDictionary(m => m, m => m.SearchScore(TextFilter))
|
||||
.OrderByDescending(a => a.Value)
|
||||
.ThenBy(a => a.Key.FamilyName)
|
||||
.ThenBy(a => a.Key.GivenName)
|
||||
.Where(a => a.Value > 0)
|
||||
.ThenBy(a => a.Key.GivenName);
|
||||
var threshold = dict.Select(a => a.Value).Max() * 3 / 4;
|
||||
members = dict
|
||||
.Where(a => a.Value > threshold)
|
||||
.Select(a => a.Key)
|
||||
.ToList();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user