1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop;
- /// <summary>
- /// Interaction logic for KanbanNotes.xaml
- /// </summary>
- public partial class KanbanNotes : UserControl, IDynamicEditorPage
- {
- private readonly string UserID = "";
- private bool _readOnly;
- public bool ReadOnly
- {
- get => _readOnly;
- set
- {
- if (_readOnly != value)
- {
- _readOnly = value;
- NotesList.IsEnabled = !_readOnly;
- }
- }
- }
- public bool Visible => true;
- public KanbanNotes(string userid)
- {
- UserID = userid;
- InitializeComponent();
- }
- public string AdditionalNote => NewNote.Text;
- public DynamicEditorGrid EditorGrid { get; set; }
- public PageType PageType => PageType.Other;
- public bool Ready { get; set; }
- public void Load(object item, Func<Type, CoreTable?>? PageDataHandler)
- {
- NotesList.ItemsSource = ((Kanban)item).Notes;
- Ready = true;
- }
- public void Cancel()
- {
- NotesList.ItemsSource = ((Kanban)(EditorGrid as IDynamicEditorHost).GetItems().First()).Notes;
- }
- public void BeforeSave(object item)
- {
- if (!string.IsNullOrWhiteSpace(AdditionalNote))
- {
- var kanban = (Kanban)item;
- var notes = kanban.Notes.ToList();
- notes.Add(string.Format("{0:yyyy-MM-dd HH:mm:ss} {1}: {2}", DateTime.Now, UserID, AdditionalNote));
- kanban.Notes = notes.ToArray();
- }
- }
- public string Caption()
- {
- return "Notes";
- }
- public int Order { get; set; } = int.MinValue;
- public void AfterSave(object item)
- {
- // no need to do anything here
- }
- public Size MinimumSize()
- {
- return new Size(400, 600);
- }
-
- public event EventHandler? OnChanged;
- public void DoChanged()
- {
- OnChanged?.Invoke(this, EventArgs.Empty);
- }
- }
|