using System.Windows;
using System.Windows.Controls;
using Comal.Classes;
using InABox.Clients;
using InABox.Core;
using InABox.Wpf;
namespace PRSDesktop
{
///
/// Interaction logic for FactoryLostTimeChooser.xaml
///
public partial class FactoryLostTimeChooser : ThemableWindow
{
public FactoryLostTimeChooser()
{
InitializeComponent();
new Client().Query(
LookupFactory.DefineFilter(),
null, //LookupFactory.DefineColumns(),
LookupFactory.DefineSort(),
(o, e) => { Dispatcher.Invoke(() => { LoadLostTime(o); }); });
}
public ManufacturingLostTime SelectedLostTime { get; set; }
private void LoadLostTime(CoreTable losttime)
{
foreach (var row in losttime.Rows)
{
LostTime.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
var label = new Label
{
Content = row.Get(x => x.Description), Margin = new Thickness(10),
VerticalContentAlignment = VerticalAlignment.Center
};
label.SetValue(Grid.RowProperty, LostTime.RowDefinitions.Count - 1);
label.SetValue(Grid.ColumnProperty, 0);
LostTime.Children.Add(label);
var button = new Button { Content = "Select", Margin = new Thickness(10, 0, 10, 20), MinWidth = 100, MinHeight = 50 };
button.Tag = row.ToObject();
button.Click += Button_Click;
button.SetValue(Grid.RowProperty, LostTime.RowDefinitions.Count - 1);
button.SetValue(Grid.ColumnProperty, 1);
LostTime.Children.Add(button);
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
SelectedLostTime = (sender as Button).Tag as ManufacturingLostTime;
DialogResult = true;
Close();
}
}
}