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