ChartWindow: Add MessageBox when removing contract from other graph
This commit is contained in:
@ -95,7 +95,7 @@ namespace Elwig.Windows {
|
||||
FillingInputs = true;
|
||||
ControlUtils.RenewItemsSource(ContractInput, contracts, g => (g as ContractSelection)?.Listing);
|
||||
FillingInputs = false;
|
||||
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.ContractsStringSimple, GraphList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.ContractsStringChange, GraphList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
|
||||
|
||||
RefreshInputs();
|
||||
}
|
||||
@ -718,7 +718,10 @@ namespace Elwig.Windows {
|
||||
private void ContractInput_Changed(object sender, ItemSelectionChangedEventArgs e) {
|
||||
if (FillingInputs) return;
|
||||
if (e.IsSelected == true) {
|
||||
RemoveContractFromOtherGraphEntries(e.Item.ToString());
|
||||
bool success = RemoveContractFromOtherGraphEntries(e.Item.ToString());
|
||||
if (!success) {
|
||||
ContractInput.SelectedItems.Remove(e.Item);
|
||||
}
|
||||
}
|
||||
var r = ContractInput.SelectedItems.Cast<ContractSelection>();
|
||||
SelectedGraphEntry!.Contracts = r.ToList();
|
||||
@ -726,13 +729,21 @@ namespace Elwig.Windows {
|
||||
GraphList.Items.Refresh();
|
||||
}
|
||||
|
||||
private void RemoveContractFromOtherGraphEntries(string? contract) {
|
||||
if (contract == null) return;
|
||||
private bool RemoveContractFromOtherGraphEntries(string? contract) {
|
||||
if (contract == null) return true;
|
||||
foreach (var ge in GraphEntries) {
|
||||
if (ge != SelectedGraphEntry && ge.Abgewertet == SelectedGraphEntry?.Abgewertet) {
|
||||
var toRemove = ge.Contracts.Where(c => c.Listing.Equals(contract)).ToList();
|
||||
if (toRemove.Count == 0) continue;
|
||||
var r = MessageBox.Show($"Achtung: {string.Join(", ", toRemove)} ist bereits in Graph {ge.Id} in Verwendung!\nSoll die Zuweisung dort entfernt werden?", "Entfernen bestätigen",
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||
if (r != MessageBoxResult.Yes) {
|
||||
return false;
|
||||
}
|
||||
ge.Contracts.RemoveAll(c => c.Listing.Equals(contract));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AbgewertetInput_Changed(object sender, RoutedEventArgs e) {
|
||||
|
Reference in New Issue
Block a user