NotesForm.xaml.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Windows;
  5. using InABox.Wpf;
  6. namespace InABox.DynamicGrid
  7. {
  8. /// <summary>
  9. /// Interaction logic for NotesForm.xaml
  10. /// </summary>
  11. public partial class NotesForm : ThemableWindow
  12. {
  13. public NotesForm(Dictionary<Guid, string> employees = null)
  14. {
  15. InitializeComponent();
  16. EmployeeID = Guid.Empty;
  17. if (employees != null)
  18. {
  19. Task.Visibility = Visibility.Visible;
  20. TaskEmployee.Visibility = Visibility.Visible;
  21. TaskEmployee.ItemsSource = employees;
  22. }
  23. }
  24. public string Caption
  25. {
  26. get => (string)Heading.Content;
  27. set => Heading.Content = value;
  28. }
  29. public string Text
  30. {
  31. get => Editor.Text;
  32. set => Editor.Text = value;
  33. }
  34. public bool OKEnabled
  35. {
  36. get => OK.IsEnabled;
  37. set => OK.IsEnabled = value;
  38. }
  39. public bool CancelEnabled
  40. {
  41. get => Cancel.IsEnabled;
  42. set => Cancel.IsEnabled = value;
  43. }
  44. public Guid EmployeeID { get; private set; }
  45. private void OK_Click(object sender, RoutedEventArgs e)
  46. {
  47. if (Task.Visibility == Visibility.Visible && TaskEmployee.SelectedItem != null)
  48. {
  49. var emp = (KeyValuePair<Guid, string>)TaskEmployee.SelectedItem;
  50. EmployeeID = emp.Key;
  51. }
  52. DialogResult = true;
  53. Close();
  54. }
  55. private void Cancel_Click(object sender, RoutedEventArgs e)
  56. {
  57. DialogResult = false;
  58. Close();
  59. }
  60. private void Window_Closing(object sender, CancelEventArgs e)
  61. {
  62. if (CancelEnabled == false && DialogResult != true)
  63. e.Cancel = true;
  64. }
  65. }
  66. }