using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using Comal.Classes;
using InABox.Clients;
using InABox.Core;
using InABox.DynamicGrid;
using InABox.Wpf;
namespace PRSDesktop
{
///
/// Interaction logic for ImportBillWindow.xaml
///
public partial class ImportBillWindow : ThemableWindow
{
private readonly Bill _bill;
private BillDocument[] _documents;
public ImportBillWindow(Bill bill)
{
_bill = bill;
InitializeComponent();
new Client().Load(
new Filter(x => x.EntityLink.ID).IsEqualTo(_bill.ID),
null,
(o, e) =>
{
Dispatcher.Invoke(() =>
{
_documents = o;
ReloadDocuments();
});
}
);
}
private void ReloadDocuments()
{
string[] exts = { ".pdf", ".png", ".jpg", ".jpeg", ".bmp" };
foreach (var document in _documents)
{
var ext = Path.GetExtension(document.DocumentLink.FileName).ToLower();
if (exts.Contains(ext))
{
var tab = new DynamicTabItem { Header = Path.GetFileName(document.DocumentLink.FileName) };
Documents.Items.Add(tab);
}
}
}
private void Documents_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
}
}