JobDock.xaml.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 ProjectsGrid _projects;
  17. public JobDock()
  18. {
  19. InitializeComponent();
  20. }
  21. public void Setup()
  22. {
  23. _projects = new ProjectsGrid();
  24. _projects.SetValue(Grid.RowProperty, 1);
  25. _projects.ColumnsTag = "JobDock";
  26. _projects.Refresh(true, false);
  27. grid.Children.Add(_projects);
  28. var statustable = new Client<JobStatus>().Query(
  29. new Filter<JobStatus>(x => x.Active).IsEqualTo(true),
  30. Columns.None<JobStatus>().Add(
  31. x => x.ID,
  32. x => x.Description
  33. ),
  34. new SortOrder<JobStatus>(x => x.Description)
  35. );
  36. JobStatus.ItemsSource = statustable.IntoDictionary<JobStatus, Guid>(
  37. new Dictionary<Guid, string> { { Guid.Empty, "All Jobs" } },
  38. x => x.ID,
  39. x => x.Description
  40. );
  41. var settings = new UserConfiguration<JobScreenSettings>().Load();
  42. _projects.StatusID = settings.JobStatus;
  43. _projects.Refresh(true, false);
  44. }
  45. public void Refresh()
  46. {
  47. _projects.Refresh(false, true);
  48. }
  49. private void JobStatus_SelectionChanged(object sender, SelectionChangedEventArgs e)
  50. {
  51. if (_projects == null)
  52. return;
  53. _projects.StatusID = (Guid)JobStatus.SelectedValue;
  54. _projects.Refresh(false, true);
  55. }
  56. }
  57. }