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