using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using InABox.Clients;
using InABox.Core;
using InABox.Wpf;
namespace InABox.DynamicGrid
{
///
/// Interaction logic for MultiSelectWindow.xaml
///
public partial class MultiSelectWindow : ThemableWindow
{
public MultiSelectWindow(Type type, Guid[] exclusions)
{
InitializeComponent();
Setup(type, exclusions);
}
//added for when wanting to prepopulate - only been tested on Manufacturing Packet Trolley selection so far
public MultiSelectWindow(Type type, Guid[] exclusions, List prepopulateValues)
{
InitializeComponent();
Setup(type, exclusions);
try
{
if (prepopulateValues.Count > 0)
{
foreach (var item in Items.Items)
{
string stringvalue = (item as KeyValuePair?).Value.ToString();
var pairstring = stringvalue.Split(',');
string pairvalue = pairstring[1];
if (pairvalue.Contains('/'))
{
var substring = pairvalue.Split('/');
string s = substring[0].Trim();
if (prepopulateValues.Contains(s) && !Items.SelectedItems.Contains(item))
{
Items.SelectedItems.Add(item);
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Unable to Prepopulate", ex.Message);
}
}
private void Setup(Type type, Guid[] exclusions)
{
Values = new Entity[] { };
var source = new Dictionary();
var client = ClientFactory.CreateClient(type);
//var columns = Entity.DefaultLookupColumns(type) as IColumns;
var columns = LookupFactory.DefineColumns(type);
var filter = LookupFactory.DefineFilter(type);
//var sort = BaseObject.DefaultSortOrder(type);
var sort = LookupFactory.DefineSort(type);
var items = client.Load(filter, sort);
foreach (var item in items)
if (!exclusions.Contains(item.ID))
{
var display = new List