KanbanNotes.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Linq;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using Comal.Classes;
  6. using InABox.Core;
  7. using InABox.DynamicGrid;
  8. namespace PRSDesktop
  9. {
  10. /// <summary>
  11. /// Interaction logic for KanbanNotes.xaml
  12. /// </summary>
  13. public partial class KanbanNotes : UserControl, IDynamicEditorPage
  14. {
  15. private readonly string UserID = "";
  16. private bool _readOnly;
  17. public bool ReadOnly
  18. {
  19. get => _readOnly;
  20. set
  21. {
  22. if (_readOnly != value)
  23. {
  24. _readOnly = value;
  25. NotesList.IsEnabled = !_readOnly;
  26. }
  27. }
  28. }
  29. public KanbanNotes(string userid)
  30. {
  31. UserID = userid;
  32. InitializeComponent();
  33. }
  34. public string AdditionalNote => NewNote.Text;
  35. public DynamicEditorGrid EditorGrid { get; set; }
  36. public PageType PageType => PageType.Other;
  37. public bool Ready { get; set; }
  38. public void Load(object item, Func<Type, CoreTable?>? PageDataHandler)
  39. {
  40. NotesList.ItemsSource = ((Kanban)item).Notes;
  41. Ready = true;
  42. }
  43. public void BeforeSave(object item)
  44. {
  45. if (!string.IsNullOrWhiteSpace(AdditionalNote))
  46. {
  47. var kanban = (Kanban)item;
  48. var notes = kanban.Notes.ToList();
  49. notes.Add(string.Format("{0:yyyy-MM-dd HH:mm:ss} {1}: {2}", DateTime.Now, UserID, AdditionalNote));
  50. kanban.Notes = notes.ToArray();
  51. }
  52. }
  53. public string Caption()
  54. {
  55. return "Notes";
  56. }
  57. public int Order()
  58. {
  59. return int.MinValue;
  60. }
  61. public void AfterSave(object item)
  62. {
  63. // no need to do anything here
  64. }
  65. public Size MinimumSize()
  66. {
  67. return new Size(400, 600);
  68. }
  69. public event EventHandler? OnChanged;
  70. public void DoChanged()
  71. {
  72. OnChanged?.Invoke(this, EventArgs.Empty);
  73. }
  74. }
  75. }