git_bsmd/ENI2/EditControls/NewDGItemDialog.xaml.cs

78 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ENI2.Controls;
using bsmd.database;
namespace ENI2.EditControls
{
/// <summary>
/// Interaction logic for NewDGItemDialog.xaml
/// </summary>
public partial class NewDGItemDialog : EditWindowBase
{
private List<HAZPosTemplate> _data = null;
public NewDGItemDialog()
{
InitializeComponent();
}
public HAZPosTemplate SelectedTemplate
{
get
{
return this.comboBoxDescription.SelectedItem as HAZPosTemplate;
}
}
private void EditWindowBase_Loaded(object sender, RoutedEventArgs e)
{
// load combo boxes
_data = LocalizedLookup.LoadHAZTemplates();
this.comboBoxDescription.ItemsSource = _data;
this.comboBoxType.ItemsSource = Enum.GetValues(typeof(HAZPosTemplate.SublistType));
}
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;
}
private void comboBoxDescription_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
HAZPosTemplate selectedTemplate = this.comboBoxDescription.SelectedItem as HAZPosTemplate;
if (selectedTemplate != null)
{
this.textBlockDescription.Text = selectedTemplate.Description;
this.textBlockRemarks.Text = selectedTemplate.Comment;
}
else
{
this.textBlockDescription.Text = "";
this.textBlockRemarks.Text = "";
}
}
}
}