Controls: Rewrite UnitTextBox as extension of TextBox instead of UserControl
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
Exit="Application_Exit">
|
||||
<Application.Resources>
|
||||
<ctrl:BoolToStringConverter x:Key="BoolToStarConverter" FalseValue="" TrueValue="*"/>
|
||||
<ctrl:WidthToPaddingConverter x:Key="WidthToPaddingConverter"/>
|
||||
<ctrl:WidthToMarginConverter x:Key="WidthToMarginConverter"/>
|
||||
|
||||
<DataTemplate x:Key="PostalDestTemplate">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
17
Elwig/Controls/UnitTextBox.cs
Normal file
17
Elwig/Controls/UnitTextBox.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Elwig.Controls {
|
||||
public class UnitTextBox : TextBox {
|
||||
|
||||
public static readonly DependencyProperty UnitProperty = DependencyProperty.Register("Unit", typeof(string), typeof(UnitTextBox), new FrameworkPropertyMetadata(""));
|
||||
public string Unit {
|
||||
get => (string)GetValue(UnitProperty);
|
||||
set => SetValue(UnitProperty, value);
|
||||
}
|
||||
|
||||
static UnitTextBox() {
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(UnitTextBox), new FrameworkPropertyMetadata(typeof(UnitTextBox)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,30 @@
|
||||
<UserControl x:Class="Elwig.Controls.UnitTextBox"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="25">
|
||||
<TextBox x:Name="TextBox" TextAlignment="Right" FontSize="14" VerticalAlignment="Stretch"
|
||||
Padding="{Binding ElementName=UnitBlock, Path=ActualWidth, Converter={StaticResource WidthToPaddingConverter}}"
|
||||
Text="{Binding Path=Text}" TextChanged="TextBox_TextChanged"/>
|
||||
<TextBlock x:Name="UnitBlock" Text="{Binding Path=Unit}" Margin="0,0,4,4" FontSize="10"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ctrl="clr-namespace:Elwig.Controls">
|
||||
<Style TargetType="ctrl:UnitTextBox" BasedOn="{StaticResource {x:Type TextBox}}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ctrl:UnitTextBox">
|
||||
<Border BorderThickness="{Binding Path=BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||
BorderBrush="{Binding Path=BorderBrush, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||
SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Bottom">
|
||||
<ScrollViewer.Margin>
|
||||
<Binding ElementName="UnitBlock" Path="ActualWidth">
|
||||
<Binding.Converter>
|
||||
<ctrl:WidthToMarginConverter/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</ScrollViewer.Margin>
|
||||
</ScrollViewer>
|
||||
<TextBlock x:Name="UnitBlock" Text="{Binding Path=Unit, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||
FontSize="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="3"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="TextAlignment" Value="Right"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
|
@ -1,37 +0,0 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Elwig.Controls {
|
||||
public partial class UnitTextBox : UserControl {
|
||||
|
||||
public event TextChangedEventHandler? TextChanged;
|
||||
|
||||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(UnitTextBox));
|
||||
public string Text {
|
||||
get => (string)GetValue(TextProperty);
|
||||
set => SetValue(TextProperty, value ?? "");
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty UnitProperty = DependencyProperty.Register("Unit", typeof(string), typeof(UnitTextBox));
|
||||
public string Unit {
|
||||
get => (string)GetValue(UnitProperty);
|
||||
set => SetValue(UnitProperty, value ?? "");
|
||||
}
|
||||
|
||||
public UnitTextBox() {
|
||||
Text = "";
|
||||
Unit = "";
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
private void TextBox_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
Text = TextBox.Text;
|
||||
TextChanged?.Invoke(sender, evt);
|
||||
}
|
||||
|
||||
public new void Focus() {
|
||||
TextBox.Focus();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,13 +4,13 @@ using System.Windows.Data;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Elwig.Controls {
|
||||
public class WidthToPaddingConverter : IValueConverter {
|
||||
public class WidthToMarginConverter : IValueConverter {
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
return new Thickness(2, 2, 4 + (double)value, 2);
|
||||
return new Thickness(0, 0, 2 + (double)value, 0);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
return ((Thickness)value).Right - 4;
|
||||
return ((Thickness)value).Right - 2;
|
||||
}
|
||||
}
|
||||
}
|
5
Elwig/Themes/Generic.xaml
Normal file
5
Elwig/Themes/Generic.xaml
Normal file
@ -0,0 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/Elwig;component/Controls/UnitTextBox.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
@ -133,7 +133,6 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected void ValidateInput(Control input, bool valid) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
Valid[input] = valid;
|
||||
}
|
||||
|
||||
@ -234,7 +233,6 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected void SetOriginalValue(Control input, object? value) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
OriginalValues[input] = Utils.GetEntityIdentifier(value);
|
||||
if (InputHasChanged(input)) {
|
||||
ControlUtils.SetInputChanged(input);
|
||||
@ -244,18 +242,15 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected void SetOriginalValue(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
SetOriginalValue(input, ControlUtils.GetInputHashCode(input));
|
||||
}
|
||||
|
||||
protected void UnsetOriginalValue(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
OriginalValues.Remove(input);
|
||||
ControlUtils.ClearInputState(input);
|
||||
}
|
||||
|
||||
protected void SetDefaultValue(Control input, object? value) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
DefaultValues[input] = Utils.GetEntityIdentifier(value);
|
||||
if (!InputHasChanged(input)) {
|
||||
if (InputIsNotDefault(input)) {
|
||||
@ -267,12 +262,10 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected void SetDefaultValue(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
SetDefaultValue(input, ControlUtils.GetInputHashCode(input));
|
||||
}
|
||||
|
||||
protected void UnsetDefaultValue(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
DefaultValues.Remove(input);
|
||||
if (!InputHasChanged(input)) {
|
||||
ControlUtils.ClearInputState(input);
|
||||
@ -296,12 +289,10 @@ namespace Elwig.Windows {
|
||||
protected bool IsValid => Valid.All(kv => kv.Value);
|
||||
|
||||
protected bool GetInputValid(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
return Valid[input];
|
||||
}
|
||||
|
||||
protected bool InputHasChanged(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
if (!OriginalValues.TryGetValue(input, out int? original)) {
|
||||
return false;
|
||||
} else {
|
||||
@ -311,7 +302,6 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected bool InputIsNotDefault(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
if (!DefaultValues.TryGetValue(input, out int? defaultValue)) {
|
||||
return false;
|
||||
} else {
|
||||
@ -436,7 +426,7 @@ namespace Elwig.Windows {
|
||||
|
||||
protected void TextBox_TextChanged(object sender, RoutedEventArgs? evt) {
|
||||
var input = (Control)sender;
|
||||
var tb = input as TextBox ?? (input as UnitTextBox)?.TextBox;
|
||||
var tb = input as TextBox;
|
||||
if (SenderIsRequired(input) && tb?.Text.Length == 0) {
|
||||
ValidateInput(input, false);
|
||||
ControlUtils.SetInputInvalid(input);
|
||||
@ -482,12 +472,12 @@ namespace Elwig.Windows {
|
||||
|
||||
protected void IntegerInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
// FIXME
|
||||
InputTextChanged((sender as UnitTextBox)?.TextBox ?? (TextBox)sender, Validator.CheckInteger);
|
||||
InputTextChanged((TextBox)sender, Validator.CheckInteger);
|
||||
}
|
||||
|
||||
protected void DecimalInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
// FIXME
|
||||
InputTextChanged((sender as UnitTextBox)?.TextBox ?? (TextBox)sender, Validator.CheckDecimal);
|
||||
InputTextChanged((TextBox)sender, Validator.CheckDecimal);
|
||||
}
|
||||
|
||||
protected void PartialDateInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
|
@ -29,7 +29,7 @@ namespace Elwig.Windows {
|
||||
];
|
||||
RequiredInputs = [
|
||||
FbNrInput, YearFromInput, KgInput, RdInput,
|
||||
GstNrInput, AreaInput.TextBox, AreaComTypeInput, WineCultivationInput
|
||||
GstNrInput, AreaInput, AreaComTypeInput, WineCultivationInput
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,14 @@
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||
</Style>
|
||||
<Style TargetType="ctrl:UnitTextBox">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Padding" Value="2"/>
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||
</Style>
|
||||
<Style TargetType="ComboBox">
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
|
@ -23,15 +23,15 @@ namespace Elwig.Windows {
|
||||
BranchIdInput, BranchNameInput, BranchPlzInput, BranchOrtInput,
|
||||
BranchAddressInput, BranchPhoneNrInput, BranchFaxNrInput, BranchMobileNrInput,
|
||||
WineAttributeIdInput, WineAttributeNameInput, WineAttributeActiveInput,
|
||||
WineAttributeMaxKgPerHaInput.TextBox, WineAttributeStrictInput, WineAttributeFillLowerInput,
|
||||
WineAttributeMaxKgPerHaInput, WineAttributeStrictInput, WineAttributeFillLowerInput,
|
||||
WineCultivationIdInput, WineCultivationNameInput, WineCultivationDescriptionInput,
|
||||
AreaCommitmentTypeIdInput, AreaCommitmentTypeWineVariantInput, AreaCommitmentTypeWineAttributeInput,
|
||||
AreaCommitmentTypeMinKgPerHaInput.TextBox, AreaCommitmentTypePenaltyPerKgInput.TextBox,
|
||||
AreaCommitmentTypePenaltyInput.TextBox, AreaCommitmentTypePenaltyNoneInput.TextBox,
|
||||
SeasonMaxKgPerHaInput.TextBox, SeasonVatNormalInput.TextBox, SeasonVatFlatrateInput.TextBox, SeasonStartInput, SeasonEndInput,
|
||||
SeasonMinKgPerBsInput.TextBox, SeasonMaxKgPerBsInput.TextBox, SeasonBsValueInput.TextBox,
|
||||
SeasonPenaltyPerKgInput.TextBox, SeasonPenaltyInput.TextBox, SeasonPenaltyNoneInput.TextBox,
|
||||
SeasonModifierIdInput, SeasonModifierNameInput, SeasonModifierRelInput.TextBox, SeasonModifierAbsInput.TextBox,
|
||||
AreaCommitmentTypeMinKgPerHaInput, AreaCommitmentTypePenaltyPerKgInput,
|
||||
AreaCommitmentTypePenaltyInput, AreaCommitmentTypePenaltyNoneInput,
|
||||
SeasonMaxKgPerHaInput, SeasonVatNormalInput, SeasonVatFlatrateInput, SeasonStartInput, SeasonEndInput,
|
||||
SeasonMinKgPerBsInput, SeasonMaxKgPerBsInput, SeasonBsValueInput,
|
||||
SeasonPenaltyPerKgInput, SeasonPenaltyInput, SeasonPenaltyNoneInput,
|
||||
SeasonModifierIdInput, SeasonModifierNameInput, SeasonModifierRelInput, SeasonModifierAbsInput,
|
||||
];
|
||||
WineAttributeFillLowerInput.Visibility = Visibility.Hidden;
|
||||
WineAttributeFillLowerLabel.Visibility = Visibility.Hidden;
|
||||
@ -57,7 +57,7 @@ namespace Elwig.Windows {
|
||||
WineAttributeIdInput.IsReadOnly = true;
|
||||
WineAttributeNameInput.IsReadOnly = true;
|
||||
WineAttributeActiveInput.IsEnabled = false;
|
||||
WineAttributeMaxKgPerHaInput.TextBox.IsReadOnly = true;
|
||||
WineAttributeMaxKgPerHaInput.IsReadOnly = true;
|
||||
WineAttributeStrictInput.IsEnabled = false;
|
||||
WineAttributeFillLowerInput.IsEnabled = false;
|
||||
|
||||
@ -67,25 +67,25 @@ namespace Elwig.Windows {
|
||||
|
||||
AreaCommitmentTypeWineVariantInput.IsEnabled = false;
|
||||
AreaCommitmentTypeWineAttributeInput.IsEnabled = false;
|
||||
AreaCommitmentTypeMinKgPerHaInput.TextBox.IsReadOnly = true;
|
||||
AreaCommitmentTypePenaltyPerKgInput.TextBox.IsReadOnly = true;
|
||||
AreaCommitmentTypePenaltyInput.TextBox.IsReadOnly = true;
|
||||
AreaCommitmentTypePenaltyNoneInput.TextBox.IsReadOnly = true;
|
||||
AreaCommitmentTypeMinKgPerHaInput.IsReadOnly = true;
|
||||
AreaCommitmentTypePenaltyPerKgInput.IsReadOnly = true;
|
||||
AreaCommitmentTypePenaltyInput.IsReadOnly = true;
|
||||
AreaCommitmentTypePenaltyNoneInput.IsReadOnly = true;
|
||||
|
||||
SeasonMaxKgPerHaInput.TextBox.IsReadOnly = true;
|
||||
SeasonVatNormalInput.TextBox.IsReadOnly = true;
|
||||
SeasonVatFlatrateInput.TextBox.IsReadOnly = true;
|
||||
SeasonMinKgPerBsInput.TextBox.IsReadOnly = true;
|
||||
SeasonMaxKgPerBsInput.TextBox.IsReadOnly = true;
|
||||
SeasonPenaltyPerKgInput.TextBox.IsReadOnly = true;
|
||||
SeasonPenaltyInput.TextBox.IsReadOnly = true;
|
||||
SeasonPenaltyNoneInput.TextBox.IsReadOnly = true;
|
||||
SeasonBsValueInput.TextBox.IsReadOnly = true;
|
||||
SeasonMaxKgPerHaInput.IsReadOnly = true;
|
||||
SeasonVatNormalInput.IsReadOnly = true;
|
||||
SeasonVatFlatrateInput.IsReadOnly = true;
|
||||
SeasonMinKgPerBsInput.IsReadOnly = true;
|
||||
SeasonMaxKgPerBsInput.IsReadOnly = true;
|
||||
SeasonPenaltyPerKgInput.IsReadOnly = true;
|
||||
SeasonPenaltyInput.IsReadOnly = true;
|
||||
SeasonPenaltyNoneInput.IsReadOnly = true;
|
||||
SeasonBsValueInput.IsReadOnly = true;
|
||||
|
||||
SeasonModifierIdInput.IsReadOnly = true;
|
||||
SeasonModifierNameInput.IsReadOnly = true;
|
||||
SeasonModifierRelInput.TextBox.IsReadOnly = true;
|
||||
SeasonModifierAbsInput.TextBox.IsReadOnly = true;
|
||||
SeasonModifierRelInput.IsReadOnly = true;
|
||||
SeasonModifierAbsInput.IsReadOnly = true;
|
||||
|
||||
ParameterAllowAttrIntoLowerInput.IsEnabled = false;
|
||||
ParameterAvoidUnderDeliveriesInput.IsEnabled = false;
|
||||
@ -107,7 +107,7 @@ namespace Elwig.Windows {
|
||||
WineAttributeIdInput.IsReadOnly = false;
|
||||
WineAttributeNameInput.IsReadOnly = false;
|
||||
WineAttributeActiveInput.IsEnabled = true;
|
||||
WineAttributeMaxKgPerHaInput.TextBox.IsReadOnly = false;
|
||||
WineAttributeMaxKgPerHaInput.IsReadOnly = false;
|
||||
WineAttributeStrictInput.IsEnabled = true;
|
||||
WineAttributeFillLowerInput.IsEnabled = true;
|
||||
|
||||
@ -117,25 +117,25 @@ namespace Elwig.Windows {
|
||||
|
||||
AreaCommitmentTypeWineVariantInput.IsEnabled = true;
|
||||
AreaCommitmentTypeWineAttributeInput.IsEnabled = true;
|
||||
AreaCommitmentTypeMinKgPerHaInput.TextBox.IsReadOnly = false;
|
||||
AreaCommitmentTypePenaltyPerKgInput.TextBox.IsReadOnly = false;
|
||||
AreaCommitmentTypePenaltyInput.TextBox.IsReadOnly = false;
|
||||
AreaCommitmentTypePenaltyNoneInput.TextBox.IsReadOnly = false;
|
||||
AreaCommitmentTypeMinKgPerHaInput.IsReadOnly = false;
|
||||
AreaCommitmentTypePenaltyPerKgInput.IsReadOnly = false;
|
||||
AreaCommitmentTypePenaltyInput.IsReadOnly = false;
|
||||
AreaCommitmentTypePenaltyNoneInput.IsReadOnly = false;
|
||||
|
||||
SeasonMaxKgPerHaInput.TextBox.IsReadOnly = false;
|
||||
SeasonVatNormalInput.TextBox.IsReadOnly = false;
|
||||
SeasonVatFlatrateInput.TextBox.IsReadOnly = false;
|
||||
SeasonMinKgPerBsInput.TextBox.IsReadOnly = false;
|
||||
SeasonMaxKgPerBsInput.TextBox.IsReadOnly = false;
|
||||
SeasonPenaltyPerKgInput.TextBox.IsReadOnly = false;
|
||||
SeasonPenaltyInput.TextBox.IsReadOnly = false;
|
||||
SeasonPenaltyNoneInput.TextBox.IsReadOnly = false;
|
||||
SeasonBsValueInput.TextBox.IsReadOnly = false;
|
||||
SeasonMaxKgPerHaInput.IsReadOnly = false;
|
||||
SeasonVatNormalInput.IsReadOnly = false;
|
||||
SeasonVatFlatrateInput.IsReadOnly = false;
|
||||
SeasonMinKgPerBsInput.IsReadOnly = false;
|
||||
SeasonMaxKgPerBsInput.IsReadOnly = false;
|
||||
SeasonPenaltyPerKgInput.IsReadOnly = false;
|
||||
SeasonPenaltyInput.IsReadOnly = false;
|
||||
SeasonPenaltyNoneInput.IsReadOnly = false;
|
||||
SeasonBsValueInput.IsReadOnly = false;
|
||||
|
||||
SeasonModifierIdInput.IsReadOnly = false;
|
||||
SeasonModifierNameInput.IsReadOnly = false;
|
||||
SeasonModifierRelInput.TextBox.IsReadOnly = false;
|
||||
SeasonModifierAbsInput.TextBox.IsReadOnly = false;
|
||||
SeasonModifierRelInput.IsReadOnly = false;
|
||||
SeasonModifierAbsInput.IsReadOnly = false;
|
||||
|
||||
ParameterAllowAttrIntoLowerInput.IsEnabled = true;
|
||||
ParameterAvoidUnderDeliveriesInput.IsEnabled = true;
|
||||
|
@ -29,6 +29,15 @@
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||
</Style>
|
||||
<Style TargetType="ctrl:UnitTextBox">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Padding" Value="2"/>
|
||||
<Setter Property="IsReadOnly" Value="True"/>
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||
</Style>
|
||||
<Style TargetType="ComboBox">
|
||||
<Setter Property="IsEnabled" Value="False"/>
|
||||
<Setter Property="Height" Value="25"/>
|
||||
|
@ -429,7 +429,7 @@ namespace Elwig.Windows {
|
||||
|
||||
private void PriceInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
if (PrimaryMarkedPoint != -1 && ActiveGraph != null && PriceInput.IsKeyboardFocusWithin == true) {
|
||||
var res = Validator.CheckDecimal(PriceInput.TextBox, true, 2, Season.Precision);
|
||||
var res = Validator.CheckDecimal(PriceInput, true, 2, Season.Precision);
|
||||
if (res.IsValid && double.TryParse(PriceInput.Text, out double price)) {
|
||||
ActiveGraph.SetPriceAt(PrimaryMarkedPoint, price);
|
||||
PrimaryMarkedPointPlot.Location = new Coordinates(PrimaryMarkedPointPlot.Location.X, price);
|
||||
@ -667,13 +667,13 @@ namespace Elwig.Windows {
|
||||
private void EnableUnitTextBox(UnitTextBox u) {
|
||||
if (PaymentVar.TestVariant) {
|
||||
u.IsEnabled = true;
|
||||
u.TextBox.IsReadOnly = false;
|
||||
u.IsReadOnly = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableUnitTextBox(UnitTextBox u) {
|
||||
u.IsEnabled = false;
|
||||
u.TextBox.IsReadOnly = true;
|
||||
u.IsReadOnly = true;
|
||||
}
|
||||
|
||||
private void ChangeActiveGraph(Graph? g) {
|
||||
@ -716,7 +716,7 @@ namespace Elwig.Windows {
|
||||
|
||||
private void GebundenFlatBonus_TextChanged(object sender, TextChangedEventArgs e) {
|
||||
if (FillingInputs) return;
|
||||
var r = Validator.CheckDecimal(GebundenFlatBonus.TextBox, true, 2, Season.Precision);
|
||||
var r = Validator.CheckDecimal(GebundenFlatBonus, true, 2, Season.Precision);
|
||||
if (r.IsValid && SelectedGraphEntry != null) {
|
||||
SelectedGraphEntry.GebundenFlatBonus = double.Parse(GebundenFlatBonus.Text);
|
||||
ResetPlot();
|
||||
|
@ -21,6 +21,14 @@
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||
</Style>
|
||||
<Style TargetType="ctrl:UnitTextBox">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Padding" Value="2"/>
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||
</Style>
|
||||
<Style TargetType="ComboBox">
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
|
@ -63,9 +63,9 @@ namespace Elwig.Windows {
|
||||
MgNrInput, MemberInput,
|
||||
LsNrInput, DateInput, BranchInput,
|
||||
SortIdInput, WineVarietyInput,
|
||||
GradationOeInput.TextBox, GradationKmwInput.TextBox, WineQualityLevelInput,
|
||||
GradationOeInput, GradationKmwInput, WineQualityLevelInput,
|
||||
WineOriginInput, WineKgInput,
|
||||
WeightInput.TextBox
|
||||
WeightInput
|
||||
];
|
||||
ExemptInputs = [
|
||||
SearchInput, SeasonInput, TodayOnlyInput, AllSeasonsInput,
|
||||
@ -529,7 +529,7 @@ namespace Elwig.Windows {
|
||||
SortIdInput.SelectAll();
|
||||
} else if (ctrl == SortIdInput || ctrl == WineVarietyInput || ctrl == AttributeInput || ctrl == CultivationInput) {
|
||||
GradationOeInput.Focus();
|
||||
GradationOeInput.TextBox.SelectAll();
|
||||
GradationOeInput.SelectAll();
|
||||
} else if (ctrl == GradationKmwInput || ctrl == GradationOeInput || ctrl == WineQualityLevelInput) {
|
||||
if (WeighingAButton.IsVisible) WeighingAButton.Focus();
|
||||
else WeighingManualButton.Focus();
|
||||
@ -1894,7 +1894,7 @@ namespace Elwig.Windows {
|
||||
WineOriginInput.IsEnabled = false;
|
||||
if (WineKgInput.SelectedItem == null)
|
||||
WineRdInput.IsEnabled = false;
|
||||
WeightInput.TextBox.IsReadOnly = true;
|
||||
WeightInput.IsReadOnly = true;
|
||||
AbgewertetInput.IsEnabled = false;
|
||||
ManualWeighingInput.IsEnabled = false;
|
||||
LsNrInput.IsReadOnly = true;
|
||||
@ -1996,17 +1996,17 @@ namespace Elwig.Windows {
|
||||
|
||||
private void UpdateGradationKmw() {
|
||||
IsUpdatingGradation = true;
|
||||
var caret = GradationKmwInput.TextBox.CaretIndex;
|
||||
var caret = GradationKmwInput.CaretIndex;
|
||||
GradationKmwInput.Text = $"{Utils.OeToKmw(double.Parse(GradationOeInput.Text)):#.0}";
|
||||
GradationKmwInput.TextBox.CaretIndex = caret;
|
||||
GradationKmwInput.CaretIndex = caret;
|
||||
IsUpdatingGradation = false;
|
||||
}
|
||||
|
||||
private void UpdateGradationOe() {
|
||||
IsUpdatingGradation = true;
|
||||
var caret = GradationOeInput.TextBox.CaretIndex;
|
||||
var caret = GradationOeInput.CaretIndex;
|
||||
GradationOeInput.Text = $"{Utils.KmwToOe(double.Parse(GradationKmwInput.Text)):#}";
|
||||
GradationOeInput.TextBox.CaretIndex = caret;
|
||||
GradationOeInput.CaretIndex = caret;
|
||||
IsUpdatingGradation = false;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,14 @@
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||
</Style>
|
||||
<Style TargetType="ctrl:UnitTextBox">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Padding" Value="2"/>
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="TextWrapping" Value="NoWrap"/>
|
||||
</Style>
|
||||
<Style TargetType="ComboBox">
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
|
@ -94,7 +94,7 @@ namespace Elwig.Windows {
|
||||
WeightModifierInput.Text = "";
|
||||
DataInput.Text = v.Data;
|
||||
}
|
||||
WeightModifierInput.TextBox.IsReadOnly = false;
|
||||
WeightModifierInput.IsReadOnly = false;
|
||||
ConsiderModifiersInput.IsEnabled = !locked;
|
||||
ConsiderPenaltiesInput.IsEnabled = !locked;
|
||||
ConsiderPenaltyInput.IsEnabled = !locked;
|
||||
@ -126,7 +126,7 @@ namespace Elwig.Windows {
|
||||
TransferDateInput.Text = "";
|
||||
TransferDateInput.IsReadOnly = true;
|
||||
WeightModifierInput.Text = "";
|
||||
WeightModifierInput.TextBox.IsReadOnly = true;
|
||||
WeightModifierInput.IsReadOnly = true;
|
||||
ConsiderModifiersInput.IsChecked = false;
|
||||
ConsiderModifiersInput.IsEnabled = false;
|
||||
ConsiderPenaltiesInput.IsChecked = false;
|
||||
@ -554,18 +554,18 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void WeightModifierInput_TextChanged(object? sender, TextChangedEventArgs? evt) {
|
||||
var res = Validator.CheckDecimal(WeightModifierInput.TextBox, false, 3, 2, true);
|
||||
var res = Validator.CheckDecimal(WeightModifierInput, false, 3, 2, true);
|
||||
if (BillingData == null) {
|
||||
ControlUtils.ClearInputState(WeightModifierInput.TextBox);
|
||||
ControlUtils.ClearInputState(WeightModifierInput);
|
||||
return;
|
||||
}
|
||||
var val = WeightModifierInput.Text.Length > 0 && res.IsValid ? double.Parse(WeightModifierInput.Text) : 0;
|
||||
WeightModifierChanged = (val != Math.Round(BillingData.NetWeightModifier * 100.0, 8) && val != Math.Round(BillingData.GrossWeightModifier * 100.0, 8)) ||
|
||||
(val == 0 && (BillingData.NetWeightModifier != 0 || BillingData.GrossWeightModifier != 0));
|
||||
if (WeightModifierChanged) {
|
||||
ControlUtils.SetInputChanged(WeightModifierInput.TextBox);
|
||||
ControlUtils.SetInputChanged(WeightModifierInput);
|
||||
} else {
|
||||
ControlUtils.ClearInputState(WeightModifierInput.TextBox);
|
||||
ControlUtils.ClearInputState(WeightModifierInput);
|
||||
}
|
||||
UpdateSaveButton();
|
||||
}
|
||||
|
Reference in New Issue
Block a user