| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- /// <summary>
- /// Interaction logic for KitPanel.xaml
- /// </summary>
- public partial class KitPanel : UserControl, IPanel<Kit>
- {
- public KitPanel()
- {
- InitializeComponent();
- Kits.OnSelectItem += Kits_OnSelectItem;
- }
- public bool IsReady { get; set; }
- public event DataModelUpdateEvent OnUpdateDataModel;
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]> { { typeof(Kit).EntityName(), Kits.SelectedRows } };
- }
- public void CreateToolbarButtons(IPanelHost host)
- {
- }
- public string SectionName => "Kits";
- public DataModel DataModel(Selection selection)
- {
- var ids = Kits.ExtractValues(x => x.ID, selection).ToArray();
- return new BaseDataModel<Kit>(new Filter<Kit>(x => x.ID).InList(ids));
- }
- public void Refresh()
- {
- Kits.Refresh(false, true);
- Products.Refresh(false, true);
- }
- public void Setup()
- {
- Products.Kit = null;
- Kits.Refresh(true, false);
- Products.Refresh(true, false);
- }
- public void Shutdown()
- {
- }
- public void Heartbeat(TimeSpan time)
- {
- }
- private void Kits_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
- {
- var row = Kits.SelectedRows.Length == 1 ? Kits.SelectedRows.SingleOrDefault() : null;
- Products.Kit = row?.ToObject<Kit>();
- Products.Refresh(false, true);
- }
- }
- }
|