diff --git a/Elwig/Windows/MemberAdminWindow.xaml b/Elwig/Windows/MemberAdminWindow.xaml
index 36ed4d6..c77068c 100644
--- a/Elwig/Windows/MemberAdminWindow.xaml
+++ b/Elwig/Windows/MemberAdminWindow.xaml
@@ -2,8 +2,6 @@
x:Class="Elwig.Windows.MemberAdminWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Windows"
Title="Mitglieder - Elwig" Height="700" Width="1250" MinHeight="650" MinWidth="1150"
Loaded="Window_Loaded">
@@ -239,14 +237,42 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Elwig/Windows/MemberAdminWindow.xaml.cs b/Elwig/Windows/MemberAdminWindow.xaml.cs
index 435ec19..d09ab1c 100644
--- a/Elwig/Windows/MemberAdminWindow.xaml.cs
+++ b/Elwig/Windows/MemberAdminWindow.xaml.cs
@@ -17,7 +17,8 @@ namespace Elwig.Windows {
public partial class MemberAdminWindow : AdministrationWindow {
private List TextFilter = [];
- private readonly (ComboBox, TextBox, TextBox)[] PhoneNrInputs;
+ private readonly (ComboBox Type, TextBox Number, TextBox Comment)[] PhoneNrInputs;
+ private readonly (Label Label, TextBox Address)[] EmailAddressInputs;
private readonly RoutedCommand CtrlF = new("CtrlF", typeof(MemberAdminWindow), [new KeyGesture(Key.F, ModifierKeys.Control)]);
private readonly RoutedCommand CtrlP = new("CtrlP", typeof(MemberAdminWindow), [new KeyGesture(Key.P, ModifierKeys.Control)]);
@@ -38,6 +39,17 @@ namespace Elwig.Windows {
AddressInput, PlzInput, OrtInput, BillingOrtInput,
BusinessSharesInput, BranchInput, DefaultKgInput
];
+ EmailAddressInputs = [
+ (EmailAddress1Label, EmailAddress1Input),
+ (EmailAddress2Label, EmailAddress2Input),
+ (EmailAddress3Label, EmailAddress3Input),
+ (EmailAddress4Label, EmailAddress4Input),
+ (EmailAddress5Label, EmailAddress5Input),
+ (EmailAddress6Label, EmailAddress6Input),
+ (EmailAddress7Label, EmailAddress7Input),
+ (EmailAddress8Label, EmailAddress8Input),
+ (EmailAddress9Label, EmailAddress9Input),
+ ];
PhoneNrInputs = [
(PhoneNr1TypeInput, PhoneNr1Input, PhoneNr1CommentInput),
(PhoneNr2TypeInput, PhoneNr2Input, PhoneNr2CommentInput),
@@ -63,7 +75,7 @@ namespace Elwig.Windows {
Menu_Print_MemberDataSheet.IsEnabled = App.IsPrintingReady;
ActiveMemberInput.IsChecked = true;
- UpdatePhoneNrInputVisibility();
+ UpdateContactInfoVisibility();
LockInputs();
}
@@ -236,27 +248,55 @@ namespace Elwig.Windows {
private void SetPhoneNrInput(int nr, string? type, string? number, string? comment) {
var inputs = PhoneNrInputs[nr];
- inputs.Item1.SelectedItem = (type == null) ? null : inputs.Item1.ItemsSource.Cast>().FirstOrDefault(p => p.Key == type);
- inputs.Item2.Text = number;
- inputs.Item3.Text = comment;
+ inputs.Type.SelectedItem = (type == null) ? null : inputs.Type.ItemsSource.Cast>().FirstOrDefault(p => p.Key == type);
+ inputs.Number.Text = number;
+ inputs.Comment.Text = comment;
+ }
+
+ private void SetEmailAddressInput(int nr, string? address) {
+ var inputs = EmailAddressInputs[nr];
+ inputs.Address.Text = address;
}
private (string, string, string?)? GetPhoneNrInput(int nr) {
var inputs = PhoneNrInputs[nr];
- var number = inputs.Item2.Text;
+ var number = inputs.Number.Text;
if (string.IsNullOrEmpty(number))
return null;
- var type = (inputs.Item1.SelectedItem as KeyValuePair?)?.Key ?? (number.StartsWith("+43 ") && number[4] == '6' ? "mobile" : "landline");
- var comment = inputs.Item3.Text;
+ var type = (inputs.Type.SelectedItem as KeyValuePair?)?.Key ?? (number.StartsWith("+43 ") && number[4] == '6' ? "mobile" : "landline");
+ var comment = inputs.Comment.Text;
return (type, number, comment == "" ? null : comment);
}
- private void SetPhoneNrInputVisible(int nr, bool visible) {
+ private string? GetEmailAddressInput(int nr) {
+ var inputs = EmailAddressInputs[nr];
+ return inputs.Address.Text == "" ? null : inputs.Address.Text;
+ }
+
+ private void SetPhoneNrInputVisible(int nr, bool visible, int? position = null) {
var inputs = PhoneNrInputs[nr];
+ if (position is int p) {
+ var mt = 10 + p * 30;
+ inputs.Type.Margin = new(6, mt, 5, 0);
+ inputs.Number.Margin = new(0, mt, 5, 0);
+ inputs.Comment.Margin = new(0, mt, 10, 0);
+ }
var vis = visible ? Visibility.Visible : Visibility.Hidden;
- inputs.Item1.Visibility = vis;
- inputs.Item2.Visibility = vis;
- inputs.Item3.Visibility = vis;
+ inputs.Type.Visibility = vis;
+ inputs.Number.Visibility = vis;
+ inputs.Comment.Visibility = vis;
+ }
+
+ private void SetEmailAddressInputVisible(int nr, bool visible, int? position = null) {
+ var inputs = EmailAddressInputs[nr];
+ if (position is int p) {
+ var mt = 10 + p * 30;
+ inputs.Label.Margin = new(10, mt, 0, 0);
+ inputs.Address.Margin = new(0, mt, 10, 0);
+ }
+ var vis = visible ? Visibility.Visible : Visibility.Hidden;
+ inputs.Label.Visibility = vis;
+ inputs.Address.Visibility = vis;
}
private void MemberList_SelectionChanged(object sender, RoutedEventArgs evt) {
@@ -274,7 +314,7 @@ namespace Elwig.Windows {
HideNewEditDeleteButtons();
ShowSaveResetCancelButtons();
UnlockInputs();
- UpdatePhoneNrInputVisibility(true);
+ UpdateContactInfoVisibility(true);
InitInputs();
LockSearchInputs();
}
@@ -289,7 +329,7 @@ namespace Elwig.Windows {
HideNewEditDeleteButtons();
ShowSaveResetCancelButtons();
UnlockInputs();
- UpdatePhoneNrInputVisibility(true);
+ UpdateContactInfoVisibility(true);
LockSearchInputs();
}
@@ -315,7 +355,7 @@ namespace Elwig.Windows {
HideSaveResetCancelButtons();
ShowNewEditDeleteButtons();
LockInputs();
- UpdatePhoneNrInputVisibility();
+ UpdateContactInfoVisibility();
UnlockSearchInputs();
FinishInputFilling();
await RefreshMemberList();
@@ -342,7 +382,7 @@ namespace Elwig.Windows {
ShowNewEditDeleteButtons();
RefreshInputs();
LockInputs();
- UpdatePhoneNrInputVisibility();
+ UpdateContactInfoVisibility();
UnlockSearchInputs();
}
@@ -504,13 +544,24 @@ namespace Elwig.Windows {
ActiveMemberInput.IsEnabled = true;
}
- private void UpdatePhoneNrInputVisibility(bool extra = false) {
- bool lastVisible = true;
- var m = (Member)MemberList.SelectedItem;
+ private void UpdateContactInfoVisibility(bool extra = false) {
+ var m = MemberList.SelectedItem as Member;
+ bool lastVisible;
+ int num = 0;
+ lastVisible = true;
+ for (int i = 0; i < EmailAddressInputs.Length; i++) {
+ var input = EmailAddressInputs[i];
+ var vis = !string.IsNullOrEmpty(input.Address.Text) || (m?.EmailAddresses.Any(a => a.Nr - 1 == i) ?? false);
+ var cVis = vis || (extra && lastVisible);
+ SetEmailAddressInputVisible(i, cVis, cVis ? num++ : null);
+ lastVisible = vis;
+ }
+ lastVisible = true;
for (int i = 0; i < PhoneNrInputs.Length; i++) {
var input = PhoneNrInputs[i];
- var vis = !string.IsNullOrEmpty(input.Item2.Text) || (m?.TelephoneNumbers.Any(p => p.Nr - 1 == i) ?? false);
- SetPhoneNrInputVisible(i, vis || (extra && lastVisible));
+ var vis = !string.IsNullOrEmpty(input.Number.Text) || (m?.TelephoneNumbers.Any(n => n.Nr - 1 == i) ?? false);
+ var cVis = vis || (extra && lastVisible);
+ SetPhoneNrInputVisible(i, cVis, cVis ? num++ : null);
lastVisible = vis;
}
}
@@ -605,17 +656,17 @@ namespace Elwig.Windows {
}
}
- for (int i = 0; i < 2; i++) {
- var input = i == 0 ? EmailAddress1Input : EmailAddress2Input;
+ for (int i = 0; i < EmailAddressInputs.Length; i++) {
+ var input = GetEmailAddressInput(i);
var emailAddr = m.EmailAddresses.FirstOrDefault(a => a.Nr - 1 == i);
- if (input.Text == "") {
+ if (input == null || input == "") {
if (emailAddr != null) {
Context.Remove(emailAddr);
}
} else {
MemberEmailAddr a = emailAddr ?? Context.CreateProxy();
a.Nr = i + 1;
- a.Address = input.Text;
+ a.Address = input ?? "";
a.Comment = null;
if (emailAddr == null) {
a.MgNr = newMgNr;
@@ -678,8 +729,14 @@ namespace Elwig.Windows {
}
var emailAddrs = m.EmailAddresses.OrderBy(a => a.Nr).ToList();
- EmailAddress1Input.Text = emailAddrs.Count > 0 ? emailAddrs[0].Address : "";
- EmailAddress2Input.Text = emailAddrs.Count > 1 ? emailAddrs[1].Address : "";
+ for (int i = 0; i< EmailAddressInputs.Length; i++) {
+ if (i < emailAddrs.Count) {
+ var emailAddr = emailAddrs[i];
+ SetEmailAddressInput(i, emailAddr.Address);
+ } else {
+ SetEmailAddressInput(i, null);
+ }
+ }
var phoneNrs = m.TelephoneNumbers.OrderBy(p => p.Nr).ToList();
for (int i = 0; i < PhoneNrInputs.Length; i++) {
@@ -690,7 +747,7 @@ namespace Elwig.Windows {
SetPhoneNrInput(i, null, null, null);
}
}
- UpdatePhoneNrInputVisibility(IsEditing || IsCreating);
+ UpdateContactInfoVisibility(IsEditing || IsCreating);
IbanInput.Text = m.Iban;
BicInput.Text = m.Bic;
@@ -786,9 +843,14 @@ namespace Elwig.Windows {
InputLostFocus((TextBox)sender, Validator.CheckPredecessorMgNr);
}
+ private new void EmailAddressInput_TextChanged(object sender, TextChangedEventArgs evt) {
+ base.EmailAddressInput_TextChanged(sender, evt);
+ UpdateContactInfoVisibility(IsEditing || IsCreating);
+ }
+
private new void PhoneNrInput_TextChanged(object sender, TextChangedEventArgs evt) {
base.PhoneNrInput_TextChanged(sender, evt);
- UpdatePhoneNrInputVisibility(IsEditing || IsCreating);
+ UpdateContactInfoVisibility(IsEditing || IsCreating);
}
private void KgDetailsButton_Click(object sender, RoutedEventArgs evt) {