using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Controls;
using Comal.Classes;
using InABox.Core;
using InABox.DynamicGrid;
using InABox.Wpf;
namespace PRSDesktop
{
///
/// Interaction logic for JobDesigns.xaml
///
public partial class JobDesignPanel : UserControl, IPanel, IMasterDetailControl
{
public JobDesignPanel()
{
InitializeComponent();
Designs.OnSelectItem += Designs_OnSelectItem;
}
public Job? Master
{
get => Designs.Master;
set => Designs.Master = value;
}
public bool IsReady { get; set; }
public event DataModelUpdateEvent? OnUpdateDataModel;
public void CreateToolbarButtons(IPanelHost host)
{
}
public string SectionName => "Job Designs";
public DataModel DataModel(Selection selection)
{
var ids = Designs.ExtractValues(c => c.ID, selection).ToArray();
return new BaseDataModel(new Filter(x => x.ID).InList(ids));
}
public void Refresh()
{
Designs.Refresh(false, true);
}
public Dictionary Selected()
{
return new Dictionary();
}
public void Setup()
{
Designs.Refresh(true, false);
Documents.Refresh(true, false);
Packets.Refresh(true, false);
}
public void Shutdown(CancelEventArgs? cancel)
{
}
public void Heartbeat(TimeSpan time)
{
}
private void Designs_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
{
var design = e.Rows?.FirstOrDefault()?.ToObject();
Documents.Design = design;
Documents.Refresh(true, true);
Packets.Master = Master;
Packets.Design = design;
Packets.Refresh(true, true);
}
}
}