123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Media.Imaging;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.Wpf;
- using java.text;
- using Syncfusion.Windows.Controls;
- namespace PRSDesktop
- {
- public partial class MeetingPanel : UserControl, IPanel<Meeting>
- {
- private DynamicGrid<MeetingItem> MeetingItemGrid = new DynamicDataGrid<MeetingItem>();
-
- public MeetingPanel()
- {
- InitializeComponent();
- MeetingItemGrid.OnEditorValueChanged += MeetingItemGrid_OnEditorValueChanged;
- MeetingItemGrid.OnCustomiseEditor += MeetingItemGrid_OnCustomiseEditor;
- }
- #region IPanel
-
- public void Setup()
- {
- foreach (var column in MeetingModel.Columns.Items)
- MeetingGrid.AddHiddenColumn(column.Property);
- MeetingGrid.Refresh(true, false);
- MeetingAssignments.Refresh(true, false);
- MeetingItemDocuments.Refresh(true, false);
- MeetingItemTasks.Refresh(true, false);
- MeetingTasks.Refresh(true, false);
- MeetingDocuments.Refresh(true, false);
- }
- public void Shutdown()
- {
-
- }
- public void Refresh()
- {
- MeetingGrid.Refresh(false, true);
- }
- public string SectionName => "Meetings";
-
- public DataModel DataModel(Selection selection)
- {
- return new AutoDataModel<Meeting>(null);
- }
- public event DataModelUpdateEvent? OnUpdateDataModel;
-
- public bool IsReady { get; set; }
-
- public void CreateToolbarButtons(IPanelHost host)
- {
-
- }
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]>();
- }
- public void Heartbeat(TimeSpan time)
- {
-
- }
-
- #endregion
- private bool _meetingSelected = false;
- private TimeSpan _meetingstart = TimeSpan.Zero;
- private TimeSpan _meetingduration = TimeSpan.Zero;
- private TimeSpan _meetingfinish = TimeSpan.Zero;
- private bool _meetingitemSelected = false;
-
- private void Meetings_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
- {
- CoreRow? row = e.Rows?.FirstOrDefault();
- _meetingSelected = row != null;
-
- var meeting = row?.ToObject<Meeting>() ?? new Meeting();
- _meetingstart = meeting.Time.Start;
- _meetingduration = meeting.Time.Duration;
- _meetingfinish = meeting.Time.Finish;
-
- MeetingGrid.InitialiseEditorForm(MeetingDetailsForm, new Meeting[] { meeting });
- _meetingitemSelected = false;
- MeetingItemGrid.InitialiseEditorForm(MeetingItemDetailsForm, new MeetingItem[] { new MeetingItem() });
- var model = new MeetingModel(row);
-
- MeetingItems.Model = model;
- MeetingItems.Refresh();
-
- MeetingAssignments.Model = model;
- MeetingAssignments.Refresh(false,true);
- MeetingItemTasks.MeetingID = meeting.ID;
- MeetingTasks.Model = model;
- MeetingTasks.Refresh(false, true);
-
- MeetingDocuments.Model = model;
- MeetingDocuments.Refresh(false, true);
-
- }
-
- private void MeetingDetailsForm_OnBeforeLoad(IDynamicEditorForm form)
- {
- form.ReadOnly = !_meetingSelected;
- }
-
- private void Meetings_OnCustomiseEditor(IDynamicEditorForm sender, Meeting[]? items, DynamicGridColumn column, BaseEditor editor)
- {
- if (String.Equals(column.ColumnName, "Time"))
- editor.Editable = sender.ReadOnly ? Editable.Disabled : Editable.Enabled;
- }
-
- private Dictionary<string, object?> Meetings_OnEditorValueChanged(object sender, string name, object value)
- {
- var item = MeetingDetailsForm.Items.FirstOrDefault();
- if (item is Meeting meeting)
- {
- if (String.Equals(name, "Time.Start") && TimeSpan.Equals(meeting.Time.Start, _meetingstart))
- return new Dictionary<string, object?>();
- if (String.Equals(name, "Time.Duration") && TimeSpan.Equals(meeting.Time.Duration, _meetingduration))
- return new Dictionary<string, object?>();
- if (String.Equals(name, "Time.Finish") && TimeSpan.Equals(meeting.Time.Finish, _meetingfinish))
- return new Dictionary<string, object?>();
-
- new Client<Meeting>().Save(meeting, "");
- var row = MeetingGrid.SelectedRows[0];
- MeetingGrid.Data.LoadRow(row, meeting);
- MeetingGrid.InvalidateRow(row);
-
- _meetingstart = meeting.Time.Start;
- _meetingduration = meeting.Time.Duration;
- _meetingfinish = meeting.Time.Finish;
-
- }
- return new Dictionary<string, object?>();
- }
-
- private void MeetingItemGrid_OnSelectItem(DynamicTreeNode node)
- {
- _meetingitemSelected = node != null;
- MeetingItemDocuments.MeetingItemID = node != null ? node.ID : Guid.Empty;
- MeetingItemDocuments.Refresh(false, true);
-
- MeetingItemTasks.MeetingItemID = node != null ? node.ID : Guid.Empty;
- MeetingItemTasks.Refresh(false, true);
-
- var row = node != null
- ? MeetingItems.Data?.Rows.FirstOrDefault(r => r.Get<MeetingItem, Guid>(x => x.ID) == node.ID)
- : null;
-
- var meetingitem = row != null ? row.ToObject<MeetingItem>() : new MeetingItem();
-
- MeetingItemGrid.InitialiseEditorForm(MeetingItemDetailsForm, new MeetingItem[] { meetingitem });
- }
-
- private void MeetingItemDetailsForm_OnBeforeLoad(IDynamicEditorForm form)
- {
- form.ReadOnly = !_meetingSelected || !_meetingitemSelected;
- }
-
- private void MeetingItemGrid_OnCustomiseEditor(IDynamicEditorForm sender, MeetingItem[] items, DynamicGridColumn column, BaseEditor editor)
- {
- }
-
- private Dictionary<string, object?> MeetingItemGrid_OnEditorValueChanged(object sender, string name, object value)
- {
- var item = MeetingItemDetailsForm.Items.FirstOrDefault();
- if(item is MeetingItem meetingitem)
- {
- new Client<MeetingItem>().Save(meetingitem, "");
- var row = MeetingItems.Data.Rows.FirstOrDefault(r => r.Get<MeetingItem, Guid>(c => c.ID) == meetingitem.ID);
- MeetingItems.Data.LoadRow(row, meetingitem);
- var node = MeetingItems.Nodes[meetingitem.ID];
- node.Description = meetingitem.Title;
- }
- return new Dictionary<string, object?>();
- }
-
- private void MeetingItemTasks_OnOnChanged(IDynamicGrid sender)
- {
- MeetingTasks.Refresh(false, true);
- }
- #region MeetingItemDocuments
-
- private void MeetingItemDocuments_OnChanged(IDynamicGrid sender)
- {
- MeetingDocuments.Refresh(false, true);
- }
-
- private void MeetingDocumentPreview_OnSizeChanged(object sender, SizeChangedEventArgs e)
- {
- }
- private void MeetingDocuments_OnOnSelectItem(object sender, DynamicGridSelectionEventArgs e)
- {
- var doc = e.Rows?.FirstOrDefault()?.ToObject<MeetingItemDocument>();
- if (doc == null)
- {
- DocumentSplitPanel.Detail = null;
- return;
- }
-
- IDocumentEditor editor = null;
- var extension = Path.GetExtension(doc.DocumentLink.FileName).ToLower();
- if (extension.Equals(".pdf"))
- {
- var pdf = new PDFEditorControl();
- //pdf.PrintAllowed = PrintAllowed;
- pdf.SaveAllowed = false;
- pdf.ButtonsVisible = false;
- pdf.Watermark = "";
- editor = pdf;
- }
- else if (extension.Equals(".png") || extension.Equals(".bmp") || extension.Equals(".jpg") || extension.Equals(".jpeg"))
- {
- editor = new ImageEditorControl();
- }
- else if (extension.Equals(".xls") || extension.Equals(".xlsx") )
- {
- editor = new SpreadsheetEditorControl();
- }
- else if (extension.Equals(".doc") || extension.Equals(".docx") || extension.Equals(".rtf") || extension.Equals(".html") || extension.Equals(".htm") || extension.Equals(".txt"))
- {
- editor = new RTFEditorControl();
- }
- if (editor != null)
- {
- DocumentSplitPanel.Detail = editor as FrameworkElement;
- editor.Document = doc;
- }
- else
- {
- DocumentSplitPanel.Detail = null;
- }
- }
- #endregion
- private void Meetings_OnCustomiseEditor(IDynamicEditorForm sender, Meeting items, DynamicGridColumn column, BaseEditor editor)
- {
- }
- }
- }
|