[#33] ChartWindow: Add CheckBox to indicate which graph (gebunden, normal) is currently selected
All checks were successful
Test / Run tests (push) Successful in 2m54s
All checks were successful
Test / Run tests (push) Successful in 2m54s
This commit is contained in:
@ -132,17 +132,20 @@
|
|||||||
<GroupBox Header="Datenpunkt" Grid.Row="0" Margin="0,5,5,5">
|
<GroupBox Header="Datenpunkt" Grid.Row="0" Margin="0,5,5,5">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="85"/>
|
<ColumnDefinition Width="65"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Content="Oechsle:" Margin="10,10,0,0" Grid.Column="0"/>
|
<Label Content="Oechsle:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||||
<ctrl:UnitTextBox x:Name="OechsleInput" Unit="°Oe" TextChanged="OechsleInput_TextChanged" IsEnabled="False"
|
<ctrl:UnitTextBox x:Name="OechsleInput" Unit="°Oe" TextChanged="OechsleInput_TextChanged" IsEnabled="False"
|
||||||
Grid.Column="1" Width="90" Margin="0,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
Grid.Column="1" Width="52" Margin="0,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||||
|
<CheckBox x:Name="GebInput" Content="Geb." IsEnabled="False"
|
||||||
|
Grid.Column="1" Margin="0,15,10,0" HorizontalAlignment="Right" VerticalAlignment="Top"
|
||||||
|
Checked="GebInput_Changed" Unchecked="GebInput_Changed"/>
|
||||||
|
|
||||||
<Label Content="Preis:" Margin="10,40,0,0" Grid.Column="0"/>
|
<Label Content="Preis:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||||
<ctrl:UnitTextBox x:Name="PriceInput" Unit="€/kg" TextChanged="PriceInput_TextChanged" IsEnabled="False"
|
<ctrl:UnitTextBox x:Name="PriceInput" Unit="€/kg" TextChanged="PriceInput_TextChanged" IsEnabled="False"
|
||||||
Grid.Column="1" Width="90" Margin="0,40,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
Grid.Column="1" Margin="0,40,10,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ using Elwig.Models.Entities;
|
|||||||
using ScottPlot.Plottables;
|
using ScottPlot.Plottables;
|
||||||
using ScottPlot;
|
using ScottPlot;
|
||||||
using ScottPlot.Control;
|
using ScottPlot.Control;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Elwig.Windows {
|
namespace Elwig.Windows {
|
||||||
public partial class ChartWindow : ContextWindow {
|
public partial class ChartWindow : ContextWindow {
|
||||||
@ -25,6 +24,7 @@ namespace Elwig.Windows {
|
|||||||
public string CurrencySymbol;
|
public string CurrencySymbol;
|
||||||
private PaymentVar PaymentVar;
|
private PaymentVar PaymentVar;
|
||||||
private bool HasChanged = false;
|
private bool HasChanged = false;
|
||||||
|
private bool Updating = false;
|
||||||
|
|
||||||
private Scatter DataPlot;
|
private Scatter DataPlot;
|
||||||
private Scatter? GebundenPlot;
|
private Scatter? GebundenPlot;
|
||||||
@ -153,6 +153,8 @@ namespace Elwig.Windows {
|
|||||||
if (SelectedGraphEntry != null) {
|
if (SelectedGraphEntry != null) {
|
||||||
CopyButton.IsEnabled = true;
|
CopyButton.IsEnabled = true;
|
||||||
DeleteButton.IsEnabled = true;
|
DeleteButton.IsEnabled = true;
|
||||||
|
EnableTextBox(OechsleInput);
|
||||||
|
GebInput.IsEnabled = SelectedGraphEntry?.GebundenGraph != null;
|
||||||
GebundenTypeFixed.IsEnabled = true;
|
GebundenTypeFixed.IsEnabled = true;
|
||||||
GebundenTypeGraph.IsEnabled = true;
|
GebundenTypeGraph.IsEnabled = true;
|
||||||
GebundenTypeNone.IsEnabled = true;
|
GebundenTypeNone.IsEnabled = true;
|
||||||
@ -164,13 +166,13 @@ namespace Elwig.Windows {
|
|||||||
CopyButton.IsEnabled = false;
|
CopyButton.IsEnabled = false;
|
||||||
DeleteButton.IsEnabled = false;
|
DeleteButton.IsEnabled = false;
|
||||||
DisableTextBox(OechsleInput);
|
DisableTextBox(OechsleInput);
|
||||||
|
GebInput.IsEnabled = false;
|
||||||
DisableOptionButtons();
|
DisableOptionButtons();
|
||||||
}
|
}
|
||||||
if (!PaymentVar.TestVariant) {
|
if (!PaymentVar.TestVariant) {
|
||||||
AddButton.IsEnabled = false;
|
AddButton.IsEnabled = false;
|
||||||
CopyButton.IsEnabled = false;
|
CopyButton.IsEnabled = false;
|
||||||
DeleteButton.IsEnabled = false;
|
DeleteButton.IsEnabled = false;
|
||||||
DisableTextBox(OechsleInput);
|
|
||||||
DisableTextBox(PriceInput);
|
DisableTextBox(PriceInput);
|
||||||
GebundenTypeFixed.IsEnabled = false;
|
GebundenTypeFixed.IsEnabled = false;
|
||||||
GebundenTypeGraph.IsEnabled = false;
|
GebundenTypeGraph.IsEnabled = false;
|
||||||
@ -395,19 +397,16 @@ namespace Elwig.Windows {
|
|||||||
OechslePricePlot.Plot.Legend.ManualItems.Clear();
|
OechslePricePlot.Plot.Legend.ManualItems.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OechsleInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
private void UpdateSelectedPoint() {
|
||||||
if (ActiveGraph == null || SelectedGraphEntry == null) {
|
if (ActiveGraph == null || SelectedGraphEntry == null)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
bool success = int.TryParse(OechsleInput.Text, out int oechsle);
|
|
||||||
|
|
||||||
SecondaryMarkedPoint = -1;
|
SecondaryMarkedPoint = -1;
|
||||||
ChangeMarker(SecondaryMarkedPointPlot, false);
|
ChangeMarker(SecondaryMarkedPointPlot, false);
|
||||||
|
|
||||||
if (success) {
|
if (int.TryParse(OechsleInput.Text, out int oe)) {
|
||||||
if (oechsle >= ActiveGraph.MinX && oechsle <= ActiveGraph.MaxX) {
|
if (oe >= ActiveGraph.MinX && oe <= ActiveGraph.MaxX) {
|
||||||
PrimaryMarkedPoint = oechsle - ActiveGraph.MinX;
|
PrimaryMarkedPoint = oe - ActiveGraph.MinX;
|
||||||
ChangeMarker(PrimaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(PrimaryMarkedPoint), ActiveGraph.GetPriceAt(PrimaryMarkedPoint));
|
ChangeMarker(PrimaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(PrimaryMarkedPoint), ActiveGraph.GetPriceAt(PrimaryMarkedPoint));
|
||||||
|
|
||||||
PriceInput.Text = Math.Round(ActiveGraph.GetPriceAt(PrimaryMarkedPoint), Season.Precision).ToString();
|
PriceInput.Text = Math.Round(ActiveGraph.GetPriceAt(PrimaryMarkedPoint), Season.Precision).ToString();
|
||||||
@ -428,6 +427,18 @@ namespace Elwig.Windows {
|
|||||||
DisableTextBox(PriceInput);
|
DisableTextBox(PriceInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OechsleInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
|
UpdateSelectedPoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GebInput_Changed(object sender, RoutedEventArgs evt) {
|
||||||
|
if (Updating)
|
||||||
|
return;
|
||||||
|
var sel = GebInput.IsChecked == true ? SelectedGraphEntry?.GebundenGraph : SelectedGraphEntry?.DataGraph;
|
||||||
|
if (sel != ActiveGraph) ChangeActiveGraph(sel);
|
||||||
|
UpdateSelectedPoint();
|
||||||
|
}
|
||||||
|
|
||||||
private void PriceInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
private void PriceInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
if (PrimaryMarkedPoint != -1 && ActiveGraph != null && PriceInput.IsKeyboardFocusWithin == true) {
|
if (PrimaryMarkedPoint != -1 && ActiveGraph != null && PriceInput.IsKeyboardFocusWithin == true) {
|
||||||
var res = Validator.CheckDecimal(PriceInput, true, 2, Season.Precision);
|
var res = Validator.CheckDecimal(PriceInput, true, 2, Season.Precision);
|
||||||
@ -486,31 +497,34 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OechslePricePlot_MouseDown(object sender, MouseEventArgs e) {
|
private void OechslePricePlot_MouseDown(object sender, MouseEventArgs e) {
|
||||||
if (GraphList.SelectedItem == null) {
|
if (GraphList.SelectedItem == null)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (HoverActive) {
|
if (HoverActive) {
|
||||||
if (PaymentVar.TestVariant && Keyboard.IsKeyDown(System.Windows.Input.Key.LeftCtrl)) {
|
if (PaymentVar.TestVariant && Keyboard.IsKeyDown(System.Windows.Input.Key.LeftCtrl)) {
|
||||||
if (PrimaryMarkedPoint == -1 || ActiveGraph == null || ActiveGraph != Highlighted.Graph) {
|
if (SecondaryMarkedPoint == -1 || ActiveGraph == null || ActiveGraph != Highlighted.Graph)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
SecondaryMarkedPoint = Highlighted.Index;
|
SecondaryMarkedPoint = Highlighted.Index;
|
||||||
|
|
||||||
ChangeMarker(SecondaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(SecondaryMarkedPoint), ActiveGraph.GetPriceAt(SecondaryMarkedPoint));
|
ChangeMarker(SecondaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(SecondaryMarkedPoint), ActiveGraph.GetPriceAt(SecondaryMarkedPoint));
|
||||||
|
|
||||||
InterpolateButton.IsEnabled = true;
|
InterpolateButton.IsEnabled = true;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Updating = true;
|
||||||
PrimaryMarkedPoint = Highlighted.Index;
|
PrimaryMarkedPoint = Highlighted.Index;
|
||||||
if (ActiveGraph != Highlighted.Graph) ChangeActiveGraph(Highlighted.Graph);
|
if (ActiveGraph != Highlighted.Graph)
|
||||||
|
ChangeActiveGraph(Highlighted.Graph);
|
||||||
|
Updating = false;
|
||||||
|
if (PrimaryMarkedPoint == -1 || ActiveGraph == null)
|
||||||
|
return;
|
||||||
|
|
||||||
ChangeMarker(PrimaryMarkedPointPlot, true, ActiveGraph!.GetOechsleAt(PrimaryMarkedPoint), ActiveGraph.GetPriceAt(PrimaryMarkedPoint));
|
ChangeMarker(PrimaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(PrimaryMarkedPoint), ActiveGraph.GetPriceAt(PrimaryMarkedPoint));
|
||||||
|
|
||||||
|
Updating = true;
|
||||||
OechsleInput.Text = Highlighted.Graph!.GetOechsleAt(Highlighted.Index).ToString();
|
OechsleInput.Text = Highlighted.Graph!.GetOechsleAt(Highlighted.Index).ToString();
|
||||||
|
GebInput.IsChecked = Highlighted.Graph == SelectedGraphEntry?.GebundenGraph;
|
||||||
PriceInput.Text = Math.Round(Highlighted.Graph.GetPriceAt(Highlighted.Index), Season.Precision).ToString();
|
PriceInput.Text = Math.Round(Highlighted.Graph.GetPriceAt(Highlighted.Index), Season.Precision).ToString();
|
||||||
|
Updating = false;
|
||||||
|
|
||||||
EnableActionButtons();
|
EnableActionButtons();
|
||||||
} else {
|
} else {
|
||||||
@ -523,6 +537,7 @@ namespace Elwig.Windows {
|
|||||||
ChangeMarker(SecondaryMarkedPointPlot, false);
|
ChangeMarker(SecondaryMarkedPointPlot, false);
|
||||||
|
|
||||||
OechsleInput.Text = "";
|
OechsleInput.Text = "";
|
||||||
|
GebInput.IsChecked = false;
|
||||||
PriceInput.Text = "";
|
PriceInput.Text = "";
|
||||||
DisableTextBox(PriceInput);
|
DisableTextBox(PriceInput);
|
||||||
|
|
||||||
@ -667,7 +682,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void EnableTextBox(TextBox u) {
|
private void EnableTextBox(TextBox u) {
|
||||||
if (PaymentVar.TestVariant) {
|
if (PaymentVar.TestVariant || u == OechsleInput) {
|
||||||
u.IsEnabled = true;
|
u.IsEnabled = true;
|
||||||
u.IsReadOnly = false;
|
u.IsReadOnly = false;
|
||||||
}
|
}
|
||||||
@ -683,14 +698,20 @@ namespace Elwig.Windows {
|
|||||||
EnableTextBox(OechsleInput);
|
EnableTextBox(OechsleInput);
|
||||||
if (SelectedGraphEntry?.GebundenGraph != null) ChangeLineWidth(DataPlot, 4);
|
if (SelectedGraphEntry?.GebundenGraph != null) ChangeLineWidth(DataPlot, 4);
|
||||||
ChangeLineWidth(GebundenPlot, 1);
|
ChangeLineWidth(GebundenPlot, 1);
|
||||||
|
GebInput.IsEnabled = SelectedGraphEntry?.GebundenGraph != null;
|
||||||
|
GebInput.IsChecked = false;
|
||||||
} else if (g != null && g == SelectedGraphEntry?.GebundenGraph) {
|
} else if (g != null && g == SelectedGraphEntry?.GebundenGraph) {
|
||||||
EnableTextBox(OechsleInput);
|
EnableTextBox(OechsleInput);
|
||||||
ChangeLineWidth(GebundenPlot, 4);
|
ChangeLineWidth(GebundenPlot, 4);
|
||||||
ChangeLineWidth(DataPlot, 1);
|
ChangeLineWidth(DataPlot, 1);
|
||||||
|
GebInput.IsEnabled = SelectedGraphEntry?.GebundenGraph != null;
|
||||||
|
GebInput.IsChecked = true;
|
||||||
} else {
|
} else {
|
||||||
DisableTextBox(OechsleInput);
|
DisableTextBox(OechsleInput);
|
||||||
DisableTextBox(PriceInput);
|
DisableTextBox(PriceInput);
|
||||||
OechsleInput.Text = "";
|
OechsleInput.Text = "";
|
||||||
|
GebInput.IsEnabled = false;
|
||||||
|
GebInput.IsChecked = false;
|
||||||
PriceInput.Text = "";
|
PriceInput.Text = "";
|
||||||
ChangeLineWidth(DataPlot, 1);
|
ChangeLineWidth(DataPlot, 1);
|
||||||
ChangeLineWidth(GebundenPlot, 1);
|
ChangeLineWidth(GebundenPlot, 1);
|
||||||
|
Reference in New Issue
Block a user