ImportBillWindow.xaml.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.IO;
  2. using System.Linq;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using Comal.Classes;
  6. using InABox.Clients;
  7. using InABox.Core;
  8. using InABox.DynamicGrid;
  9. using InABox.Wpf;
  10. namespace PRSDesktop
  11. {
  12. /// <summary>
  13. /// Interaction logic for ImportBillWindow.xaml
  14. /// </summary>
  15. public partial class ImportBillWindow : ThemableWindow
  16. {
  17. private readonly Bill _bill;
  18. private BillDocument[] _documents;
  19. public ImportBillWindow(Bill bill)
  20. {
  21. _bill = bill;
  22. InitializeComponent();
  23. new Client<BillDocument>().Load(
  24. new Filter<BillDocument>(x => x.EntityLink.ID).IsEqualTo(_bill.ID),
  25. null,
  26. (o, e) =>
  27. {
  28. Dispatcher.Invoke(() =>
  29. {
  30. _documents = o;
  31. ReloadDocuments();
  32. });
  33. }
  34. );
  35. }
  36. private void ReloadDocuments()
  37. {
  38. string[] exts = { ".pdf", ".png", ".jpg", ".jpeg", ".bmp" };
  39. foreach (var document in _documents)
  40. {
  41. var ext = Path.GetExtension(document.DocumentLink.FileName).ToLower();
  42. if (exts.Contains(ext))
  43. {
  44. var tab = new DynamicTabItem { Header = Path.GetFileName(document.DocumentLink.FileName) };
  45. Documents.Items.Add(tab);
  46. }
  47. }
  48. }
  49. private void Documents_SelectionChanged(object sender, SelectionChangedEventArgs e)
  50. {
  51. }
  52. }
  53. }