123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using Comal.Classes;
- using InABox.Configuration;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.Wpf;
- namespace PRSDesktop
- {
-
- public class ReadyToGoGlobalSettings : BaseObject, IGlobalConfigurationSettings
- {
- public int PageSize { get; set; } = 5000;
- }
-
- /// <summary>
- /// Interaction logic for ItemsPanel.xaml
- /// </summary>
- public partial class ReadyToGoPanel : UserControl, IPanel<DeliveryItem>
- {
- private ReadyToGoGlobalSettings _globalSettings = new();
-
- public ReadyToGoPanel()
- {
- _globalSettings = new GlobalConfiguration<ReadyToGoGlobalSettings>().Load();
- InitializeComponent();
- }
- public bool IsReady { get; set; }
- public event DataModelUpdateEvent? OnUpdateDataModel;
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]>(); // { { typeof(DeliveryItem).EntityName(), Items.SelectedRows } };
- }
- public void Setup()
- {
- Items.Reconfigure();
- Items.Refresh(true, false);
- }
- private void Items_OnReconfigure(DynamicGridOptions options)
- {
- options.PageSize = _globalSettings.PageSize;
- }
- public void Shutdown(CancelEventArgs? cancel)
- {
- Items.Shutdown();
- }
- public void CreateToolbarButtons(IPanelHost host)
- {
- host.CreateSetupAction(new PanelAction() { Caption = "Delivered On Site Settings", Image = PRSDesktop.Resources.product, OnExecute =
- (obj) =>
- {
- var grid = new DynamicItemsListGrid<ReadyToGoGlobalSettings>();
- if (grid.EditItems(new ReadyToGoGlobalSettings[] { _globalSettings }))
- {
- new GlobalConfiguration<ReadyToGoGlobalSettings>().Save(_globalSettings);
- Items.Reconfigure();
- Refresh();
- }
-
- }
- });
- }
- public void Refresh()
- {
- Items.Refresh(false, true);
- }
- public string SectionName => "Ready To Go";
- public DataModel DataModel(Selection selection)
- {
- var ids = Items.ExtractValues(x => x.ID, selection).ToArray();
- return new DeliveryItemDataModel(new Filter<DeliveryItem>(x => x.ID).InList(ids));
- }
- public void Heartbeat(TimeSpan time)
- {
- }
- public Type DataType()
- {
- return typeof(DeliveryItem);
- }
- private void SearchBox_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- Items.Search = SearchBox.Text;
- Items.Refresh(false, true);
- }
- }
- private void ClearSearchButton_Click(object sender, RoutedEventArgs e)
- {
- Items.Search = "";
- Items.Refresh(false, true);
- }
- }
- }
|