Added in-grid editing experimentically for BKRA in Arrival detail control
This commit is contained in:
parent
36b596709a
commit
d83413c623
@ -56,6 +56,33 @@
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Validation Error Template for a DataGrid Row -->
|
||||
|
||||
<Style TargetType="{x:Type DataGridRow}">
|
||||
<Setter Property="ValidationErrorTemplate">
|
||||
<Setter.Value>
|
||||
<ControlTemplate>
|
||||
<Grid Margin="0,-2,0,-2"
|
||||
ToolTip="{Binding RelativeSource={RelativeSource
|
||||
FindAncestor, AncestorType={x:Type DataGridRow}},
|
||||
Path=(Validation.Errors)[0].ErrorContent}">
|
||||
<Ellipse StrokeThickness="0" Fill="Red"
|
||||
Width="{TemplateBinding FontSize}"
|
||||
Height="{TemplateBinding FontSize}" />
|
||||
<TextBlock Text="!" FontSize="{TemplateBinding FontSize}"
|
||||
FontWeight="Bold" Foreground="White"
|
||||
HorizontalAlignment="Center" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
|
||||
<Style TargetType="{x:Type ToolTip}" >
|
||||
|
||||
<Setter Property="OverridesDefaultStyle" Value="true" />
|
||||
|
||||
@ -33,6 +33,7 @@ namespace ENI2
|
||||
private DependencyPropertyDescriptor _dpComboboxValue;
|
||||
private DependencyPropertyDescriptor _dpNumericUpdown;
|
||||
private DependencyPropertyDescriptor _dpIntUpdown;
|
||||
|
||||
private readonly Dictionary<Object, Message.NotificationClass> _controlClassDict = new Dictionary<object, Message.NotificationClass>();
|
||||
private readonly Dictionary<Message.NotificationClass, Message> _typeMessageDict = new Dictionary<Message.NotificationClass, Message>();
|
||||
|
||||
@ -132,8 +133,7 @@ namespace ENI2
|
||||
_dpComboboxIndex = DependencyPropertyDescriptor.FromProperty(ComboBox.SelectedIndexProperty, typeof(ComboBox));
|
||||
_dpComboboxValue = DependencyPropertyDescriptor.FromProperty(ComboBox.SelectedValueProperty, typeof(ComboBox));
|
||||
_dpNumericUpdown = DependencyPropertyDescriptor.FromProperty(Xceed.Wpf.Toolkit.DoubleUpDown.ValueProperty, typeof(Xceed.Wpf.Toolkit.DoubleUpDown));
|
||||
_dpIntUpdown = DependencyPropertyDescriptor.FromProperty(Xceed.Wpf.Toolkit.IntegerUpDown.ValueProperty, typeof(Xceed.Wpf.Toolkit.IntegerUpDown));
|
||||
|
||||
_dpIntUpdown = DependencyPropertyDescriptor.FromProperty(Xceed.Wpf.Toolkit.IntegerUpDown.ValueProperty, typeof(Xceed.Wpf.Toolkit.IntegerUpDown));
|
||||
|
||||
foreach(Message message in this.Messages)
|
||||
{
|
||||
@ -246,7 +246,7 @@ namespace ENI2
|
||||
{
|
||||
this._dpIntUpdown.AddValueChanged(intUpDown, this.controlContentChanged);
|
||||
this._controlClassDict[intUpDown] = notificationClass;
|
||||
}
|
||||
}
|
||||
|
||||
protected void SublistElementChanged(Message.NotificationClass notificationClass)
|
||||
{
|
||||
|
||||
@ -71,8 +71,24 @@
|
||||
AutoGenerateColumns="False" Margin="0,5,0,0">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
|
||||
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerType}" Binding="{Binding BunkerFuelType}" IsReadOnly="True" Width="0.2*" />
|
||||
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerQuantity}" Binding="{Binding BunkerFuelQuantity_TNE, Mode=TwoWay}" IsReadOnly="True" Width="0.8*" />
|
||||
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerType}" Width="0.2*">
|
||||
<DataGridTextColumn.Binding>
|
||||
<Binding Path="BunkerFuelType" Mode="TwoWay">
|
||||
<Binding.ValidationRules>
|
||||
<util:StringValidationRule MaxLength="100" />
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</DataGridTextColumn.Binding>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerQuantity}" IsReadOnly="False" Width="0.8*">
|
||||
<DataGridTextColumn.Binding>
|
||||
<Binding Path="BunkerFuelQuantity_TNE" Mode="TwoWay">
|
||||
<Binding.ValidationRules>
|
||||
<util:NumberValidationRule MaxValue="10000" />
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</DataGridTextColumn.Binding>
|
||||
</DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</enictrl:ENIDataGrid>
|
||||
</GroupBox>
|
||||
|
||||
@ -40,6 +40,7 @@ namespace ENI2.DetailViewControls
|
||||
this.RegisterIntegerUpDownChange(this.integerUpDownPersonsOnBoard, Message.NotificationClass.POBA);
|
||||
this.RegisterIntegerUpDownChange(this.integerUpDownStowawaysOnBoard, Message.NotificationClass.POBA);
|
||||
startupComplete = true;
|
||||
this.dataGridBKRA.CellEditEnding += (obj, ev) => { this.OnNotificationClassChanged(Message.NotificationClass.BKRA); };
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
|
||||
@ -454,7 +454,9 @@
|
||||
<Compile Include="Util\HighlightService.cs" />
|
||||
<Compile Include="Util\InverseBooleanConverter.cs" />
|
||||
<Compile Include="Util\NullImageConverter.cs" />
|
||||
<Compile Include="Util\NumberValidationRule.cs" />
|
||||
<Compile Include="Util\SettingBindingExtension.cs" />
|
||||
<Compile Include="Util\StringValidationRule.cs" />
|
||||
<Compile Include="Util\TrimStringConverter.cs" />
|
||||
<Compile Include="Util\UIHelper.cs" />
|
||||
<Compile Include="Util\UtcToLocalDateTimeConverter.cs" />
|
||||
|
||||
32
ENI2/Util/NumberValidationRule.cs
Normal file
32
ENI2/Util/NumberValidationRule.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2017- schick Informatik
|
||||
// Description: Validation for direct in-grid editing
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ENI2.Util
|
||||
{
|
||||
public class NumberValidationRule : ValidationRule
|
||||
{
|
||||
public double? MaxValue { get; set; }
|
||||
|
||||
public double MinValue { get; set; } = 0;
|
||||
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
if (!double.TryParse(Convert.ToString(value), out double aDouble))
|
||||
return new ValidationResult(false, "Illegal characters");
|
||||
|
||||
if (((MaxValue != null) && (aDouble > MaxValue)) || (aDouble < MinValue))
|
||||
{
|
||||
return new ValidationResult(false, string.Format("Please enter a number in the range: {0} - {1}", MinValue, MaxValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ValidationResult(true, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
ENI2/Util/StringValidationRule.cs
Normal file
28
ENI2/Util/StringValidationRule.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2017- schick Informatik
|
||||
// Description: Validation for direct in-grid editing
|
||||
//
|
||||
|
||||
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ENI2.Util
|
||||
{
|
||||
public class StringValidationRule : ValidationRule
|
||||
{
|
||||
|
||||
public int MaxLength { get; set; } = 100;
|
||||
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
if ((value is string text) && text.Length > MaxLength)
|
||||
{
|
||||
return new ValidationResult(false, string.Format("Text is longer than {0} chars", MaxLength));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ValidationResult(true, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user