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:p="clr-namespace:ENI2.Properties"
|
||||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||||
mc:Ignorable="d"
|
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">
|
Icon="/ENI2;component/Resources/bullet_ball_yellow.ico" Loaded="EditWindowBase_Loaded">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@ -19,6 +19,7 @@
|
|||||||
<RowDefinition Height="28" />
|
<RowDefinition Height="28" />
|
||||||
<RowDefinition Height="28" />
|
<RowDefinition Height="28" />
|
||||||
<RowDefinition Height="28" />
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="28" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="80" />
|
<ColumnDefinition Width="80" />
|
||||||
@ -28,12 +29,13 @@
|
|||||||
<Label Content="{x:Static p:Resources.textType}" Grid.Row="0" Grid.Column="0" />
|
<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" />
|
<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" />
|
<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"/>
|
<xctk:WatermarkTextBox Margin="2" Watermark="{x:Static p:Resources.textSearch}" Name="textBoxSearchDescription" Grid.Row="1" Grid.Column="1" TextChanged="textBoxSearchDescription_TextChanged" />
|
||||||
<Label Content="{x:Static p:Resources.textRemarks}" Grid.Row="4" Grid.Column="0" />
|
<ComboBox Name="comboBoxDescription" Grid.Column="1" Grid.Row="2" Margin="2" SelectionChanged="comboBoxDescription_SelectionChanged" />
|
||||||
<Border BorderThickness="1" Grid.Column="1" Grid.Row="2" Grid.RowSpan="2" BorderBrush="Black" Margin="2">
|
<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"/>
|
<TextBlock Name="textBlockDescription" Margin="2" Background="LightGray" TextWrapping="Wrap"/>
|
||||||
</Border>
|
</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" />
|
<TextBlock Name="textBlockRemarks" Margin="2" Background="LightGray" TextWrapping="Wrap" />
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@ namespace ENI2.EditControls
|
|||||||
public partial class NewDGItemDialog : EditWindowBase
|
public partial class NewDGItemDialog : EditWindowBase
|
||||||
{
|
{
|
||||||
private List<HAZPosTemplate> _data = null;
|
private List<HAZPosTemplate> _data = null;
|
||||||
|
private static object filterLock = new object();
|
||||||
|
|
||||||
public NewDGItemDialog()
|
public NewDGItemDialog()
|
||||||
{
|
{
|
||||||
@ -47,31 +48,48 @@ namespace ENI2.EditControls
|
|||||||
|
|
||||||
private void comboBoxType_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void comboBoxType_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
// filter description against type
|
FilterDescriptions();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void comboBoxDescription_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void comboBoxDescription_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
HAZPosTemplate selectedTemplate = this.comboBoxDescription.SelectedItem as HAZPosTemplate;
|
if (this.comboBoxDescription.SelectedItem is HAZPosTemplate selectedTemplate)
|
||||||
if (selectedTemplate != null)
|
|
||||||
{
|
{
|
||||||
this.textBlockDescription.Text = selectedTemplate.Description;
|
this.textBlockDescription.Text = selectedTemplate.Description;
|
||||||
this.textBlockRemarks.Text = selectedTemplate.Comment;
|
this.textBlockRemarks.Text = selectedTemplate.Comment;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.textBlockDescription.Text = "";
|
this.textBlockDescription.Text = "";
|
||||||
this.textBlockRemarks.Text = "";
|
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