Neues Gefahrgut: Zur Combobox eine zusätzliche Textbox mit Suchmöglichkeit inkl. gegenseitiger Filterung
This commit is contained in:
parent
67145c50c3
commit
a3019b7a30
@ -8,7 +8,7 @@
|
||||
xmlns:p="clr-namespace:ENI2.Properties"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
mc:Ignorable="d"
|
||||
Title="{x:Static p:Resources.textNewDGItem}" Height="260" Width="600" WindowStyle="SingleBorderWindow" Background="AliceBlue" ResizeMode="CanResize"
|
||||
Title="{x:Static p:Resources.textNewDGItem}" Height="290" Width="600" WindowStyle="SingleBorderWindow" Background="AliceBlue" ResizeMode="CanResize"
|
||||
Icon="/ENI2;component/Resources/bullet_ball_yellow.ico" Loaded="EditWindowBase_Loaded">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@ -19,6 +19,7 @@
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80" />
|
||||
@ -28,12 +29,13 @@
|
||||
<Label Content="{x:Static p:Resources.textType}" Grid.Row="0" Grid.Column="0" />
|
||||
<ComboBox Name="comboBoxType" Grid.Column="1" Grid.Row="0" Margin="2" SelectionChanged="comboBoxType_SelectionChanged" />
|
||||
<Label Content="{x:Static p:Resources.textDescription}" Grid.Row="1" Grid.Column="0" />
|
||||
<ComboBox Name="comboBoxDescription" Grid.Column="1" Grid.Row="1" Margin="2" SelectionChanged="comboBoxDescription_SelectionChanged" IsEditable="True"/>
|
||||
<Label Content="{x:Static p:Resources.textRemarks}" Grid.Row="4" Grid.Column="0" />
|
||||
<Border BorderThickness="1" Grid.Column="1" Grid.Row="2" Grid.RowSpan="2" BorderBrush="Black" Margin="2">
|
||||
<xctk:WatermarkTextBox Margin="2" Watermark="{x:Static p:Resources.textSearch}" Name="textBoxSearchDescription" Grid.Row="1" Grid.Column="1" TextChanged="textBoxSearchDescription_TextChanged" />
|
||||
<ComboBox Name="comboBoxDescription" Grid.Column="1" Grid.Row="2" Margin="2" SelectionChanged="comboBoxDescription_SelectionChanged" />
|
||||
<Label Content="{x:Static p:Resources.textRemarks}" Grid.Row="5" Grid.Column="0" />
|
||||
<Border BorderThickness="1" Grid.Column="1" Grid.Row="3" Grid.RowSpan="2" BorderBrush="Black" Margin="2">
|
||||
<TextBlock Name="textBlockDescription" Margin="2" Background="LightGray" TextWrapping="Wrap"/>
|
||||
</Border>
|
||||
<Border BorderThickness="1" Grid.Column="1" Grid.Row="4" Grid.RowSpan="2" BorderBrush="Black" Margin="2">
|
||||
<Border BorderThickness="1" Grid.Column="1" Grid.Row="5" Grid.RowSpan="2" BorderBrush="Black" Margin="2">
|
||||
<TextBlock Name="textBlockRemarks" Margin="2" Background="LightGray" TextWrapping="Wrap" />
|
||||
</Border>
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ namespace ENI2.EditControls
|
||||
public partial class NewDGItemDialog : EditWindowBase
|
||||
{
|
||||
private List<HAZPosTemplate> _data = null;
|
||||
private static object filterLock = new object();
|
||||
|
||||
public NewDGItemDialog()
|
||||
{
|
||||
@ -47,22 +48,12 @@ namespace ENI2.EditControls
|
||||
|
||||
private void comboBoxType_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
// filter description against type
|
||||
List<HAZPosTemplate> comboData = new List<HAZPosTemplate>();
|
||||
HAZPosTemplate.SublistType sType = (HAZPosTemplate.SublistType) this.comboBoxType.SelectedItem;
|
||||
|
||||
foreach (HAZPosTemplate ht in this._data)
|
||||
{
|
||||
if (ht.TemplateType == sType)
|
||||
comboData.Add(ht);
|
||||
}
|
||||
this.comboBoxDescription.ItemsSource = comboData;
|
||||
FilterDescriptions();
|
||||
}
|
||||
|
||||
private void comboBoxDescription_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
HAZPosTemplate selectedTemplate = this.comboBoxDescription.SelectedItem as HAZPosTemplate;
|
||||
if (selectedTemplate != null)
|
||||
if (this.comboBoxDescription.SelectedItem is HAZPosTemplate selectedTemplate)
|
||||
{
|
||||
this.textBlockDescription.Text = selectedTemplate.Description;
|
||||
this.textBlockRemarks.Text = selectedTemplate.Comment;
|
||||
@ -73,5 +64,32 @@ namespace ENI2.EditControls
|
||||
this.textBlockRemarks.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void textBoxSearchDescription_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
FilterDescriptions();
|
||||
}
|
||||
|
||||
private void FilterDescriptions()
|
||||
{
|
||||
string searchText = this.textBoxSearchDescription.Text.Trim();
|
||||
|
||||
lock (filterLock)
|
||||
{
|
||||
IEnumerable<HAZPosTemplate> filtered = _data;
|
||||
if (searchText.Length > 0)
|
||||
{
|
||||
filtered = _data.Where(elem => elem.Description.ToUpperInvariant().Contains(searchText.ToUpperInvariant()));
|
||||
}
|
||||
if (this.comboBoxType.SelectedItem != null)
|
||||
{
|
||||
HAZPosTemplate.SublistType sType = (HAZPosTemplate.SublistType)this.comboBoxType.SelectedItem;
|
||||
filtered = filtered.Where(elem => elem.TemplateType == sType);
|
||||
}
|
||||
this.comboBoxDescription.ItemsSource = filtered;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user