ChartWindow: Make gebunden type fixed more user friendly
This commit is contained in:
@ -43,10 +43,6 @@ namespace Elwig.Windows {
|
||||
private bool HoverActive = false;
|
||||
private bool FillingInputs = false;
|
||||
|
||||
private const int MinOechsle = 50;
|
||||
private const int MinOechsleGebunden = 73;
|
||||
private const int MaxOechsle = 140;
|
||||
|
||||
private List<GraphEntry> GraphEntries = [];
|
||||
private GraphEntry? SelectedGraphEntry;
|
||||
|
||||
@ -125,12 +121,15 @@ namespace Elwig.Windows {
|
||||
private void FillInputs() {
|
||||
FillingInputs = true;
|
||||
|
||||
if (SelectedGraphEntry?.GebundenFlatBonus != null) {
|
||||
if (SelectedGraphEntry?.GebundenFlatBonus is double bonus) {
|
||||
GebundenTypeFixed.IsChecked = true;
|
||||
GebundenFlatBonus.Text = $"{bonus}";
|
||||
} else if (SelectedGraphEntry?.GebundenGraph != null) {
|
||||
GebundenTypeGraph.IsChecked = true;
|
||||
GebundenFlatBonus.Text = "";
|
||||
} else {
|
||||
GebundenTypeNone.IsChecked = true;
|
||||
GebundenFlatBonus.Text = "";
|
||||
}
|
||||
|
||||
ControlUtils.SelectCheckComboBoxItems(ContractInput, SelectedGraphEntry?.Contracts ?? [], i => (i as ContractSelection)?.Listing);
|
||||
@ -165,7 +164,7 @@ namespace Elwig.Windows {
|
||||
OechslePricePlot.Configuration.DoubleClickBenchmark = false;
|
||||
//OechslePricePlot.Plot.XAxis.ManualTickSpacing(1);
|
||||
OechslePricePlot.Plot.YAxis.ManualTickSpacing(0.1);
|
||||
OechslePricePlot.Plot.SetAxisLimits(Math.Min(MinOechsle, MinOechsleGebunden) - 1, MaxOechsle + 1, -0.1, 2);
|
||||
OechslePricePlot.Plot.SetAxisLimits(Math.Min(GraphEntry.MinX, GraphEntry.MinXGeb) - 1, GraphEntry.MaxX + 1, -0.1, 2);
|
||||
|
||||
OechslePricePlot.Plot.Layout(padding: 0);
|
||||
OechslePricePlot.Plot.XAxis2.Layout(padding: 0);
|
||||
@ -247,17 +246,17 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void LockZoom() {
|
||||
OechslePricePlot.Plot.XAxis.SetBoundary(MinOechsle - 1, MaxOechsle + 1);
|
||||
OechslePricePlot.Plot.XAxis.SetBoundary(GraphEntry.MinX - 1, GraphEntry.MaxX + 1);
|
||||
OechslePricePlot.Plot.YAxis.SetBoundary(-0.1, 2);
|
||||
OechslePricePlot.Plot.XAxis.SetZoomOutLimit(MaxOechsle - MinOechsle + 2);
|
||||
OechslePricePlot.Plot.XAxis.SetZoomOutLimit(GraphEntry.MaxX - GraphEntry.MinX + 2);
|
||||
OechslePricePlot.Plot.YAxis.SetZoomOutLimit(2.1);
|
||||
OechslePricePlot.Plot.SetAxisLimits(MinOechsle - 1, MaxOechsle + 1, -0.1, 2);
|
||||
OechslePricePlot.Plot.SetAxisLimits(GraphEntry.MinX - 1, GraphEntry.MaxX + 1, -0.1, 2);
|
||||
}
|
||||
|
||||
private void UnlockZoom() {
|
||||
OechslePricePlot.Plot.XAxis.SetBoundary();
|
||||
OechslePricePlot.Plot.YAxis.SetBoundary();
|
||||
OechslePricePlot.Plot.XAxis.SetZoomOutLimit((MaxOechsle - MinOechsle) * 1.5);
|
||||
OechslePricePlot.Plot.XAxis.SetZoomOutLimit((GraphEntry.MaxX - GraphEntry.MinX) * 1.5);
|
||||
OechslePricePlot.Plot.YAxis.SetZoomOutLimit(3.5);
|
||||
}
|
||||
|
||||
@ -342,12 +341,11 @@ namespace Elwig.Windows {
|
||||
|
||||
private void PriceInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
if (PrimaryMarkedPoint != -1 && ActiveGraph != null) {
|
||||
bool success = double.TryParse(PriceInput.Text, out double price);
|
||||
|
||||
if (success) {
|
||||
if (double.TryParse(PriceInput.Text, out double price)) {
|
||||
ActiveGraph.SetPriceAt(PrimaryMarkedPoint, price);
|
||||
PrimaryMarkedPointPlot.Y = price;
|
||||
OechslePricePlot.Refresh();
|
||||
CheckGebundenTypeFixed();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -358,6 +356,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
ActiveGraph.FlattenGraphLeft(PrimaryMarkedPoint);
|
||||
OechslePricePlot.Render();
|
||||
CheckGebundenTypeFixed();
|
||||
}
|
||||
|
||||
private void RightFlatButton_Click(object sender, RoutedEventArgs evt) {
|
||||
@ -366,6 +365,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
ActiveGraph.FlattenGraphRight(PrimaryMarkedPoint);
|
||||
OechslePricePlot.Render();
|
||||
CheckGebundenTypeFixed();
|
||||
}
|
||||
|
||||
private void InterpolateButton_Click(object sender, RoutedEventArgs evt) {
|
||||
@ -374,6 +374,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
ActiveGraph.InterpolateGraph(PrimaryMarkedPoint, SecondaryMarkedPoint);
|
||||
OechslePricePlot.Render();
|
||||
CheckGebundenTypeFixed();
|
||||
}
|
||||
|
||||
private void LinearIncreaseButton_Click(object sender, RoutedEventArgs e) {
|
||||
@ -386,6 +387,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
ActiveGraph.LinearIncreaseGraphToEnd(PrimaryMarkedPoint, priceIncrease.Value);
|
||||
OechslePricePlot.Render();
|
||||
CheckGebundenTypeFixed();
|
||||
}
|
||||
|
||||
private void OechslePricePlot_MouseDown(object sender, MouseEventArgs e) {
|
||||
@ -500,7 +502,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, RoutedEventArgs e) {
|
||||
GraphEntry newGraphEntry = new(GetMaxGraphId() + 1, Season.Precision, BillingData.CurveMode.Oe, MinOechsle, MinOechsleGebunden, MaxOechsle);
|
||||
GraphEntry newGraphEntry = new(GetMaxGraphId() + 1, Season.Precision, BillingData.CurveMode.Oe);
|
||||
GraphEntries.Add(newGraphEntry);
|
||||
GraphList.Items.Refresh();
|
||||
GraphList.SelectedItem = newGraphEntry;
|
||||
@ -600,9 +602,12 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void GebundenFlatBonus_TextChanged(object sender, TextChangedEventArgs e) {
|
||||
var r = Validator.CheckDecimal(GebundenFlatBonus.TextBox, true, 2, 8);
|
||||
if (r.IsValid) {
|
||||
SelectedGraphEntry?.SetGebundenFlatBonus(decimal.Parse(GebundenFlatBonus.Text));
|
||||
if (FillingInputs) return;
|
||||
var r = Validator.CheckDecimal(GebundenFlatBonus.TextBox, true, 2, Season.Precision);
|
||||
if (r.IsValid && SelectedGraphEntry != null) {
|
||||
SelectedGraphEntry.GebundenFlatBonus = double.Parse(GebundenFlatBonus.Text);
|
||||
ResetPlot();
|
||||
InitPlot();
|
||||
}
|
||||
}
|
||||
|
||||
@ -635,23 +640,32 @@ namespace Elwig.Windows {
|
||||
if (SelectedGraphEntry == null) {
|
||||
DisableUnitTextBox(GebundenFlatBonus);
|
||||
return;
|
||||
} else if (GebundenTypeNone.IsChecked == true) {
|
||||
SelectedGraphEntry.SetGebundenFlatBonus(null);
|
||||
}
|
||||
if (GebundenTypeNone.IsChecked == true) {
|
||||
SelectedGraphEntry.RemoveGebundenGraph();
|
||||
DisableUnitTextBox(GebundenFlatBonus);
|
||||
RefreshInputs();
|
||||
} else if (GebundenTypeFixed.IsChecked == true) {
|
||||
SelectedGraphEntry.SetGebundenFlatBonus(0);
|
||||
SelectedGraphEntry.RemoveGebundenGraph();
|
||||
SelectedGraphEntry.GebundenFlatBonus = double.TryParse(GebundenFlatBonus.Text, out var val) ? val : 0.1;
|
||||
SelectedGraphEntry.AddGebundenGraph();
|
||||
EnableUnitTextBox(GebundenFlatBonus);
|
||||
RefreshInputs();
|
||||
} else if (GebundenTypeGraph.IsChecked == true) {
|
||||
GebundenFlatBonus.Text = "";
|
||||
SelectedGraphEntry.SetGebundenFlatBonus(null);
|
||||
SelectedGraphEntry.AddGebundenGraph();
|
||||
DisableUnitTextBox(GebundenFlatBonus);
|
||||
RefreshInputs();
|
||||
}
|
||||
RefreshInputs();
|
||||
}
|
||||
|
||||
private void CheckGebundenTypeFixed() {
|
||||
FillingInputs = true;
|
||||
if (SelectedGraphEntry?.GebundenFlatBonus is double bonus) {
|
||||
GebundenTypeFixed.IsChecked = true;
|
||||
GebundenFlatBonus.Text = $"{bonus}";
|
||||
EnableUnitTextBox(GebundenFlatBonus);
|
||||
} else {
|
||||
GebundenTypeGraph.IsChecked = true;
|
||||
DisableUnitTextBox(GebundenFlatBonus);
|
||||
}
|
||||
FillingInputs = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user