diff --git a/MainWindow.axaml b/MainWindow.axaml index 16af180..926b0f9 100644 --- a/MainWindow.axaml +++ b/MainWindow.axaml @@ -220,7 +220,6 @@ - Lösche ursprüngliche Sets + + + + + + + + + + + + diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs index b1ed756..8cabd25 100644 --- a/MainWindow.axaml.cs +++ b/MainWindow.axaml.cs @@ -669,6 +669,15 @@ public partial class MainWindow : Window BtnRepair.IsEnabled = false; } } + + LstCombineAddressSetSort.Items.Clear(); + foreach (var selected in LstCustomerAdressSets.SelectedItems) + { + try + { + LstCombineAddressSetSort.Items.Add(selected as KasAddressList); + } catch {} + } } private async void BtnSettingsImportCustomerAddressPatch_OnClick(object? sender, RoutedEventArgs e) @@ -728,7 +737,7 @@ public partial class MainWindow : Window private void BtnCombineDifference_OnClick(object? sender, RoutedEventArgs e) { var list = new List(); - foreach (var item in LstCustomerAdressSets.SelectedItems) + foreach (var item in LstCombineAddressSetSort.Items) list.Add((KasAddressList)item); try { @@ -743,7 +752,7 @@ public partial class MainWindow : Window private void BtnCombineUnion_OnClick(object? sender, RoutedEventArgs e) { var list = new List(); - foreach (var item in LstCustomerAdressSets.SelectedItems) + foreach (var item in LstCombineAddressSetSort.Items) list.Add((KasAddressList)item); try { @@ -759,7 +768,7 @@ public partial class MainWindow : Window private void BtnCombineIntersection_OnClick(object? sender, RoutedEventArgs e) { var list = new List(); - foreach (var item in LstCustomerAdressSets.SelectedItems) + foreach (var item in LstCombineAddressSetSort.Items) list.Add((KasAddressList)item); try { @@ -788,7 +797,7 @@ public partial class MainWindow : Window private void BtnCombineSymmetricDifference_OnClick(object? sender, RoutedEventArgs e) { var list = new List(); - foreach (var item in LstCustomerAdressSets.SelectedItems) + foreach (var item in LstCombineAddressSetSort.Items) list.Add((KasAddressList)item); StartCombine(list, Convert.ToInt32((LstCustomers.SelectedItem as Customer).ID), "symdiff", GetCombiningTyp()); @@ -1301,4 +1310,56 @@ public partial class MainWindow : Window StartAddressRepairer((KasAddressList)LstCustomerAdressSets.SelectedItem); } + + private void BtnCombineAddressSetSortUp_OnClick(object? sender, RoutedEventArgs e) + { + var selected = (LstCombineAddressSetSort.SelectedItem as KasAddressList); + int index = LstCombineAddressSetSort.SelectedIndex; + if (LstCombineAddressSetSort.SelectedIndex != null && LstCombineAddressSetSort.SelectedIndex != -1) + { + try + { + LstCombineAddressSetSort.Items.RemoveAt(index); + LstCombineAddressSetSort.Items.Insert(index-1, selected); + LstCombineAddressSetSort.SelectedIndex = index - 1; + } catch {} + } + } + + private void BtnCombineAddressSetSortDown_OnClick(object? sender, RoutedEventArgs e) + { + var selected = (LstCombineAddressSetSort.SelectedItem as KasAddressList); + int index = LstCombineAddressSetSort.SelectedIndex; + if (LstCombineAddressSetSort.SelectedIndex != null && LstCombineAddressSetSort.SelectedIndex != -1) + { + try + { + LstCombineAddressSetSort.Items.RemoveAt(index); + LstCombineAddressSetSort.Items.Insert(index+1, selected); + LstCombineAddressSetSort.SelectedIndex = index + 1; + } catch {} + } + } + + private void LstCombineAddressSetSort_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) + { + if (LstCombineAddressSetSort.SelectedIndex == 0) + { + BtnCombineAddressSetSortDown.IsEnabled = true; + BtnCombineAddressSetSortUp.IsEnabled = false; + } else if (LstCombineAddressSetSort.SelectedIndex == LstCombineAddressSetSort.Items.Count - 1) + { + BtnCombineAddressSetSortUp.IsEnabled = true; + BtnCombineAddressSetSortDown.IsEnabled = false; + } else if (LstCombineAddressSetSort.SelectedIndex == LstCombineAddressSetSort.Items.Count - 1 && LstCombineAddressSetSort.SelectedIndex == 0) + { + BtnCombineAddressSetSortUp.IsEnabled = false; + BtnCombineAddressSetSortDown.IsEnabled = false; + } + else + { + BtnCombineAddressSetSortDown.IsEnabled = true; + BtnCombineAddressSetSortUp.IsEnabled = true; + } + } }