using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls;
using Comal.Classes;
using InABox.Core;
using InABox.DynamicGrid;
namespace PRSDesktop
{
///
/// Interaction logic for QuoteTakeoffs.xaml
///
public partial class QuoteDesigns : UserControl, IQuotePage, IPanel
{
public QuoteDesigns()
{
InitializeComponent();
Designs.OnSelectItem += Designs_OnSelectItem;
}
public bool IsReady { get; set; }
public event DataModelUpdateEvent OnUpdateDataModel;
public void CreateToolbarButtons(IPanelHost host)
{
}
public string SectionName => "Quote Designs";
public DataModel DataModel(Selection selected)
{
var designs = Designs.ExtractValues(x => x.ID, selected).ToArray();
return new BaseDataModel(new Filter(x => x.ID).InList(designs));
}
public void Heartbeat(TimeSpan time)
{
}
public void Refresh()
{
Designs.Refresh(false, true);
Items.Refresh(false, true);
}
public Dictionary Selected()
{
return new Dictionary();
}
public void Setup()
{
Designs.Refresh(true, false);
Items.Refresh(true, false);
}
public void Shutdown()
{
}
public Guid ParentID
{
get => Designs.QuoteID;
set
{
Designs.QuoteID = value;
Items.QuoteID = value;
}
}
public Dictionary DataEnvironment()
{
return new Dictionary();
}
private void Designs_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
{
var row = e.Rows?.FirstOrDefault();
Items.DesignID = row != null ? row.Get(x => x.ID) : CoreUtils.FullGuid;
}
}
}