diff --git a/Elwig/Helpers/Billing/ContractSelection.cs b/Elwig/Helpers/Billing/ContractSelection.cs index 49798aa..e37c154 100644 --- a/Elwig/Helpers/Billing/ContractSelection.cs +++ b/Elwig/Helpers/Billing/ContractSelection.cs @@ -9,6 +9,7 @@ namespace Elwig.Helpers.Billing { public WineVar? Variety { get; } public WineAttr? Attribute { get; } public string Listing => $"{Variety?.SortId}{Attribute?.AttrId}"; + public string FullName => $"{Variety?.Name}" + (Variety != null && Attribute != null ? " " : "") + $"{Attribute?.Name}"; public ContractSelection(WineVar? var, WineAttr? attr) { Variety = var; diff --git a/Elwig/Helpers/Billing/GraphEntry.cs b/Elwig/Helpers/Billing/GraphEntry.cs index eb86887..29c8d8b 100644 --- a/Elwig/Helpers/Billing/GraphEntry.cs +++ b/Elwig/Helpers/Billing/GraphEntry.cs @@ -12,7 +12,7 @@ namespace Elwig.Helpers.Billing { public decimal? GebundenFlatBonus { get; set; } public List Contracts { get; set; } public string ContractsStringSimple => Contracts.Any() ? string.Join(", ", Contracts.Select(c => c.Listing)) : "-"; - public string ContractsString => Contracts.Any() ? string.Join("\n", Contracts.Select(c => c.ToString())) : "-"; + public string ContractsString => Contracts.Any() ? string.Join("\n", Contracts.Select(c => c.FullName)) : "-"; private int MinX { get; set; } private int MaxX { get; set; } diff --git a/Elwig/Windows/ChartWindow.xaml.cs b/Elwig/Windows/ChartWindow.xaml.cs index 125af1d..f4526b5 100644 --- a/Elwig/Windows/ChartWindow.xaml.cs +++ b/Elwig/Windows/ChartWindow.xaml.cs @@ -40,6 +40,7 @@ namespace Elwig.Windows { private int SecondaryMarkedPoint = -1; private bool HoverChanged = false; private bool HoverActive = false; + private bool FillingInputs = false; private const int MinOechsle = 50; private const int MaxOechsle = 140; @@ -62,11 +63,11 @@ namespace Elwig.Windows { private async Task RefreshGraphList() { await Context.PaymentVariants.LoadAsync(); - var attrVariants = Context.DeliveryParts + var attrVariants = (await Context.DeliveryParts .Where(d => d.Year == Year) .Select(d => $"{d.SortId}{d.AttrId}") .Distinct() - .ToList() + .ToListAsync()) .Union(Context.WineVarieties.Select(v => v.SortId)) .Order() .ToList(); @@ -74,7 +75,7 @@ namespace Elwig.Windows { GraphEntries = [ ..data.GetPaymentGraphEntries(Context), ..data.GetQualityGraphEntries(Context)]; var contracts = ContractSelection.GetContractsForYear(Context, Year); - ControlUtils.RenewItemsSource(ContractInput, contracts, g => (g as ContractSelection)?.ToString()); + ControlUtils.RenewItemsSource(ContractInput, contracts, g => (g as ContractSelection)?.Listing); ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.Id, null, ControlUtils.RenewSourceDefault.First); RefreshInputs(); @@ -109,9 +110,11 @@ namespace Elwig.Windows { GebundenTypeNone.IsEnabled = false; ContractInput.IsEnabled = false; } + GC.Collect(); } private void FillInputs() { + FillingInputs = true; GraphNum.Text = SelectedGraphEntry?.Id.ToString(); if (SelectedGraphEntry?.GebundenFlatBonus != null) { @@ -119,13 +122,14 @@ namespace Elwig.Windows { } else if (SelectedGraphEntry?.GebundenGraph != null) { GebundenTypeGraph.IsChecked = true; } else { - GebundenTypeNone.IsChecked = true; ; + GebundenTypeNone.IsChecked = true; } ControlUtils.SelectCheckComboBoxItems(ContractInput, SelectedGraphEntry?.Contracts ?? [], i => (i as ContractSelection)?.Listing); InitPlot(); OechslePricePlot.IsEnabled = true; + FillingInputs = false; } protected override async Task OnRenewContext() { @@ -277,9 +281,9 @@ namespace Elwig.Windows { } private void ShowGradationLines() { - OechslePricePlot.Plot.AddVerticalLine(68, Color.Red, 2, label: "68 Oechsle (LDW)"); - OechslePricePlot.Plot.AddVerticalLine(73, Color.Orange, 2, label: "73 Oechsle (QUW)"); - OechslePricePlot.Plot.AddVerticalLine(84, Color.Green, 2, label: "84 Oechsle (KAB)"); + OechslePricePlot.Plot.AddVerticalLine(68, Color.Red, 2, label: "68 °Oe (LDW)"); + OechslePricePlot.Plot.AddVerticalLine(73, Color.Orange, 2, label: "73 °Oe (QUW)"); + OechslePricePlot.Plot.AddVerticalLine(84, Color.Green, 2, label: "84 °Oe (KAB)"); } private void HideGradationLines() { @@ -597,9 +601,6 @@ namespace Elwig.Windows { private void GraphList_SelectionChanged(object sender, SelectionChangedEventArgs e) { SelectedGraphEntry = GraphList.SelectedItem as GraphEntry; RefreshInputs(); - - //var x = OechslePricePlot.Plot.GetPlottables().OfType(); - //MessageBox.Show($"SelectionChanged\nLength: {x.ToList().Count}, Ys: {string.Join(", ", ((ScatterPlot)x.First()).Ys)}"); } private void PriceInput_LostFocus(object sender, RoutedEventArgs e) { @@ -618,13 +619,14 @@ namespace Elwig.Windows { } private void ContractInput_Changed(object sender, RoutedEventArgs e) { + if (FillingInputs) return; var r = ContractInput.SelectedItems.Cast(); SelectedGraphEntry!.Contracts = r.ToList(); - // FIXME when using arrow keys, selection does not work nicely GraphList.Items.Refresh(); } private void GebundenType_Checked(object sender, RoutedEventArgs e) { + if (FillingInputs) return; if (SelectedGraphEntry == null) { DisableUnitTextBox(GebundenFlatBonus); return;