JobDock.xaml.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using Comal.Classes;
  6. using InABox.Clients;
  7. using InABox.Configuration;
  8. using InABox.Core;
  9. namespace PRSDesktop
  10. {
  11. /// <summary>
  12. /// Interaction logic for JobDock.xaml
  13. /// </summary>
  14. public partial class JobDock : UserControl, IDockPanel
  15. {
  16. private JobGrid _jobs;
  17. public JobDock()
  18. {
  19. InitializeComponent();
  20. }
  21. public void Setup()
  22. {
  23. _jobs = new JobGrid();
  24. _jobs.SetValue(Grid.RowProperty, 1);
  25. _jobs.Margin = new Thickness(2);
  26. grid.Children.Add(_jobs);
  27. var statustable = new Client<JobStatus>().Query(
  28. new Filter<JobStatus>(x => x.Active).IsEqualTo(true),
  29. new Columns<JobStatus>(
  30. x => x.ID,
  31. x => x.Description
  32. ),
  33. new SortOrder<JobStatus>(x => x.Description)
  34. );
  35. JobStatus.ItemsSource = statustable.IntoDictionary<JobStatus, Guid>(
  36. new Dictionary<Guid, string> { { Guid.Empty, "All Jobs" } },
  37. x => x.ID,
  38. x => x.Description
  39. );
  40. var settings = new UserConfiguration<JobScreenSettings>().Load();
  41. _jobs.StatusID = settings.JobStatus;
  42. _jobs.Refresh(true, false);
  43. }
  44. public void Refresh()
  45. {
  46. _jobs.Refresh(false, true);
  47. }
  48. private void JobStatus_SelectionChanged(object sender, SelectionChangedEventArgs e)
  49. {
  50. if (_jobs == null)
  51. return;
  52. _jobs.StatusID = (Guid)JobStatus.SelectedValue;
  53. }
  54. }
  55. }