using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Sarand.PatientMgr.Win.Forms.Base; using Sarand.PatientMgr.Core.Bus; using Sarand.Core.Base; using Sarand.PatientMgr.Win.Forms.Panels; using Sarand.Win.Forms.UpdateLog; using Sarand.Win.Forms.Controls; using Sarand.PatientMgr.Win.Forms.Maint; using Sarand.PatientMgr.Core.App; using Sarand.Core.Bus; using Sarand.Win.Forms.Utils; namespace Sarand.PatientMgr.Win.Forms.TabPages { //======================================================================= public partial class SpmTabPage_Facility : SpmTabPage { //------------------------------------------------------------------- // Configuration. public enum PanelType { Unknown = 0, Updates, } public new class Config : SpmTabPage.Config { /// Facility form hosting the tab control. public SpmForm_Facility FacilityForm { get; set; } = null; /// Panels to display on this tab page. public List PanelTypes { get; } = new List(); /// Number of panels on this tab page. public override int PanelCount { get { return PanelTypes.Count; } } } //------------------------------------------------------------------- // Data members. private Config config = new Config(); private SaPanel_UpdateLog panelUpdates = null; //------------------------------------------------------------------- // Construction. public SpmTabPage_Facility(Config config) : base(config) { this.config = config; InitializeComponent(); } protected override void Dispose(bool disposing) { if (disposing) { if (components != null) components.Dispose(); } base.Dispose(disposing); } //------------------------------------------------------------------- // Properties. /// Panels to display on this tab page. public List PanelTypes { get { return config.PanelTypes; } } //------------------------------------------------------------------- // Initialisation. protected override void OnCreateControl() { base.OnCreateControl(); if (this.IsDesignerHosted()) return; // Configure page. // Initial panels. List panels = new List(); foreach (var panelType in config.PanelTypes) { SacsPanel panel = null; switch (panelType) { case PanelType.Updates: { SaPanel_UpdateLog.Config configUpdateLog = new SaPanel_UpdateLog.Config(); configUpdateLog.UpdateLogConsole = UpdateLogConsole; panelUpdates = new SaPanel_UpdateLog(); panelUpdates.SetConfig(configUpdateLog); panel = panelUpdates; panel.SizeChanged += Panel_Resize; break; } } if (panel != null) panels.Add(panel); else Logger.Warn(GetType().Name + ".OnCreateControl Panel type not supported: " + panelType.ToString()); } AddPanelsToPage(panels); // Complete panel initialisation. SetControlsReadOnly(); SetControlActivity(); } //------------------------------------------------------------------- // P a g e I n t e r f a c e //------------------------------------------------------------------- //------------------------------------------------------------------- // P o p u l a t i o n //------------------------------------------------------------------- public void PopulateToControls(SpmFacility.Data data) { if (panelUpdates != null) panelUpdates.ItemId = new ItemId((short)Spm.DataItemType.Facility, data.Id); } public bool IsDataValid(SpmFacility.Data data) { return true; } public void PopulateFromControls(SpmFacility.Data data) { } public bool UpdateAssociatedData(SpmFacility.Data data) { return true; } //------------------------------------------------------------------- // C o n t r o l A c t i v i t y //------------------------------------------------------------------- protected void SetControlActivity() { if (panelUpdates != null) panelUpdates.Enabled = Enabled; } public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col) { return false; } protected void SetControlsReadOnly() { return; } //------------------------------------------------------------------- // P a n e l E v e n t s //------------------------------------------------------------------- private void panel_ItemCreated(object sender, SpmPanel_Items.ItemModifiedEventArgs e) { InvokeItemCreatedEvent((short)e.ItemType, e.ItemId); } private void panel_ItemUpdated(object sender, SpmPanel_Items.ItemModifiedEventArgs e) { InvokeItemUpdatedEvent((short)e.ItemType, e.ItemId); } private void panel_ItemDeleted(object sender, SpmPanel_Items.ItemModifiedEventArgs e) { InvokeItemDeletedEvent((short)e.ItemType, e.ItemId); } //------------------------------------------------------------------- // P a n e l S i z e a n d P o s i t i o n //------------------------------------------------------------------- protected override void PositionControls() { base.PositionControls(); Rectangle clientRect = ClientRectangle; } //------------------------------------------------------------------- } //======================================================================= }