123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.IO;
- using System.Linq;
- using System.Windows.Controls;
- using com.healthmarketscience.jackcess.impl;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Configuration;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.Wpf;
- using Syncfusion.Pdf.Parsing;
- namespace PRSDesktop;
- public class JobRequisitionPanelSettings : IUserConfigurationSettings, ISplitPanelSettings
- {
- public DynamicSplitPanelView ViewType { get; set; } = DynamicSplitPanelView.Combined;
- public double AnchorWidth { get; set; } = 500;
- }
- /// <summary>
- /// Interaction logic for JobMaterialPanel.xaml
- /// </summary>
- public partial class JobRequisitionPanel : UserControl, IPanel<JobMaterial>, IMasterDetailControl<Job>
- {
- private JobRequisitionPanelSettings Settings;
- public JobRequisitionPanel()
- {
- InitializeComponent();
- }
- private void LoadSettings()
- {
- Settings = new UserConfiguration<JobRequisitionPanelSettings>().Load();
- SplitPanel.AnchorWidth = Settings.AnchorWidth;
- SplitPanel.View = Settings.ViewType;
- }
-
- protected void SaveSettings()
- {
- Settings.AnchorWidth = SplitPanel.AnchorWidth;
- Settings.ViewType = SplitPanel.View;
- Settings.SaveUser();
- }
- public Job? Master
- {
- get => Requisitions.Master;
- set => Requisitions.Master = value;
- }
- public bool IsReady { get; set; }
- public event DataModelUpdateEvent? OnUpdateDataModel;
- public void CreateToolbarButtons(IPanelHost host)
- {
- }
- public void Setup()
- {
- LoadSettings();
- Requisitions.Refresh(true, false);
- Items.Refresh(true, false);
- }
- public void Shutdown(CancelEventArgs? cancel)
- {
- }
- public void Refresh()
- {
- if(Settings.ViewType == DynamicSplitPanelView.Detail)
- {
- Items.Master = null;
- Items.Job = Master;
- Items.Refresh(false, true);
- }
- else
- {
- Requisitions.Refresh(false, true);
- }
- }
- public string SectionName => "Job Requisitions";
- public DataModel DataModel(Selection selection)
- {
- var ids = Requisitions.ExtractValues(x => x.ID, selection).ToArray();
- return new AutoDataModel<JobRequisition>(new Filter<JobRequisition>(c => c.ID).InList(ids));
- }
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]>
- {
- { typeof(JobRequisition).EntityName(), Requisitions.SelectedRows }
- };
- }
- public void Heartbeat(TimeSpan time)
- {
- }
- private void Requisitions_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
- {
- Items.Master = e.Rows?.FirstOrDefault()?.ToObject<JobRequisition>();
- Items.Refresh(false, true);
- }
- private void SplitPanel_OnChanged(object sender, DynamicSplitPanelSettings e)
- {
- var changedView = e.View != Settings.ViewType;
- SaveSettings();
- if (changedView)
- {
- Refresh();
- }
- }
- }
|