KanbanNotes.xaml.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. /// <summary>
  10. /// Interaction logic for KanbanNotes.xaml
  11. /// </summary>
  12. public partial class KanbanNotes : UserControl, IDynamicEditorPage
  13. {
  14. private readonly string UserID = "";
  15. private bool _readOnly;
  16. public bool ReadOnly
  17. {
  18. get => _readOnly;
  19. set
  20. {
  21. if (_readOnly != value)
  22. {
  23. _readOnly = value;
  24. NotesList.IsEnabled = !_readOnly;
  25. }
  26. }
  27. }
  28. public bool Visible => true;
  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 Cancel()
  44. {
  45. NotesList.ItemsSource = ((Kanban)(EditorGrid as IDynamicEditorHost).GetItems().First()).Notes;
  46. }
  47. public void BeforeSave(object item)
  48. {
  49. if (!string.IsNullOrWhiteSpace(AdditionalNote))
  50. {
  51. var kanban = (Kanban)item;
  52. var notes = kanban.Notes.ToList();
  53. notes.Add(string.Format("{0:yyyy-MM-dd HH:mm:ss} {1}: {2}", DateTime.Now, UserID, AdditionalNote));
  54. kanban.Notes = notes.ToArray();
  55. }
  56. }
  57. public string Caption()
  58. {
  59. return "Notes";
  60. }
  61. public int Order { get; set; } = int.MinValue;
  62. public void AfterSave(object item)
  63. {
  64. // no need to do anything here
  65. }
  66. public Size MinimumSize()
  67. {
  68. return new Size(400, 600);
  69. }
  70. public event EventHandler? OnChanged;
  71. public void DoChanged()
  72. {
  73. OnChanged?.Invoke(this, EventArgs.Empty);
  74. }
  75. }