| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.Wpf;
- using InABox.Wpf.Dashboard;
- using InABox.Wpf.Dashboard.Editor;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- namespace PRSDesktop.Dashboards;
- public class CustomDashboardGrid : DynamicItemsListGrid<CustomDashboard>
- {
- protected override void DoReconfigure(DynamicGridOptions options)
- {
- base.DoReconfigure(options);
- options.Clear();
- options.AddRows = true;
- options.EditRows = true;
- options.DeleteRows = true;
- }
- public override CustomDashboard CreateItem()
- {
- var item = base.CreateItem();
- item.Name = "New Dashboard";
- item.Group = "Custom";
- item.ID = Guid.NewGuid();
- return item;
- }
- public override bool EditItems(CustomDashboard[] items, Func<Type, CoreTable?>? PageDataHandler = null, bool PreloadPages = false)
- {
- if(items.Length > 1)
- {
- MessageWindow.ShowMessage("Please select only one dashboard to edit.", "Error");
- return false;
- }
- var customDashboard = items[0];
- var dashboard = DynamicDashboardUtils.Deserialize(customDashboard.Layout)
- ?? new();
- var editor = new DynamicDashboardEditor(dashboard);
- editor.DashboardName = customDashboard.Name;
- editor.DashboardGroup = customDashboard.Group;
- var dlg = new DynamicContentDialog(editor)
- {
- Title = "Edit dashboard",
- SizeToContent = SizeToContent.Height,
- CanSave = true
- };
- if(dlg.ShowDialog() == true)
- {
- customDashboard.Layout = DynamicDashboardUtils.Serialize(editor.GetDashboard());
- customDashboard.Name = editor.DashboardName;
- customDashboard.Group = editor.DashboardGroup;
- SaveItem(customDashboard);
- return true;
- }
- else
- {
- return false;
- }
- }
- }
|