From 09fe0bdf4fc3baa257ae5f4e382b8ad9faecf80a Mon Sep 17 00:00:00 2001 From: James Friel Date: Tue, 21 Jan 2025 13:55:23 +0000 Subject: [PATCH] smarter binding --- .../MainFormUITabs/CatalogueUI.Designer.cs | 4 +- Rdmp.UI/MainFormUITabs/CatalogueUI.cs | 84 +++++++++++++++---- 2 files changed, 69 insertions(+), 19 deletions(-) diff --git a/Rdmp.UI/MainFormUITabs/CatalogueUI.Designer.cs b/Rdmp.UI/MainFormUITabs/CatalogueUI.Designer.cs index d73ef69d67..e9f4d19ebb 100644 --- a/Rdmp.UI/MainFormUITabs/CatalogueUI.Designer.cs +++ b/Rdmp.UI/MainFormUITabs/CatalogueUI.Designer.cs @@ -1,4 +1,5 @@ -using System.Windows.Forms; +using System; +using System.Windows.Forms; using Rdmp.UI.LocationsMenu.Ticketing; namespace Rdmp.UI.MainFormUITabs @@ -194,6 +195,7 @@ private void InitializeComponent() tabControl1.SelectedIndex = 0; tabControl1.Size = new System.Drawing.Size(881, 923); tabControl1.TabIndex = 0; + tabControl1.SelectedIndexChanged += tabControl1_SelectedIndexChanged; // // tabPage1 // diff --git a/Rdmp.UI/MainFormUITabs/CatalogueUI.cs b/Rdmp.UI/MainFormUITabs/CatalogueUI.cs index e4154a6e1f..415cd6adfa 100644 --- a/Rdmp.UI/MainFormUITabs/CatalogueUI.cs +++ b/Rdmp.UI/MainFormUITabs/CatalogueUI.cs @@ -5,10 +5,12 @@ // You should have received a copy of the GNU General Public License along with RDMP. If not, see . using System; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Windows.Forms; +using NPOI.HSSF.Record.Chart; using Rdmp.Core; using Rdmp.Core.Curation.Data; using Rdmp.Core.Icons.IconProvision; @@ -148,30 +150,15 @@ public override void SetDatabaseObject(IActivateItems activator, Catalogue datab this.editableFolder.Title = "Folder"; this.editableFolder.Icon = CatalogueIcons.CatalogueFolder.ImageToBitmap(); RefreshUIFromDatabase(); + } protected override void SetBindings(BinderWithErrorProviderFactory rules, Catalogue databaseObject) { base.SetBindings(rules, databaseObject); + tabControl1_SelectedIndexChanged(this.tabControl1, null); - - Bind(tbAbstract, "Text", "ShortDescription", c => c.ShortDescription); - Bind(tbDescription, "Text", "Description", c => c.Description); - Bind(tbKeywords, "Text", "Search_keywords", c => c.Search_keywords); - Bind(tbDataSource,"Text","DataSource", c => c.DataSource); - Bind(tbDataSourceSetting, "Text", "DataSourceSetting", c => c.DataSourceSetting); - Bind(tbGeoCoverage, "Text", "Geographical_coverage", c => c.Geographical_coverage); - //Bind(dtpStart, "Value", "StartDate", c => c.StartDate); - //Bind(dtpEndDate, "Value", "EndDate", c => c.EndDate); - Bind(tbAccessContact, "Text", "Administrative_contact_email", c => c.Administrative_contact_email); - Bind(tbDataController, "Text", "DataController", c => c.DataController); - Bind(tbDataProcessor, "Text", "DataProcessor", c => c.DataProcessor); - Bind(tbJuristiction, "Text", "Juristiction", c => c.Juristiction); - Bind(tbPeople, "Text", "AssociatedPeople", c => c.AssociatedPeople); - Bind(tbDOI, "Text", "Doi", c => c.Doi); - Bind(tbInitialReleaseDate, "Text", "DatasetReleaseDate", c => c.DatasetReleaseDate); - Bind(tbUpdateLag, "Text", "UpdateLag", c => c.UpdateLag); - + //-------------------------------- //Bind(tbAcronym, "Text", "Acronym", c => c.Acronym); //Bind(tbName, "Text", "Name", c => c.Name); //Bind(c_tbID, "Text", "ID", c => c.ID); @@ -308,6 +295,67 @@ private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e) { } + + private List setTabBindings = new(); + + private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) + { + var tabControl = (TabControl)sender; + var selectedIndex = tabControl.SelectedIndex; + if (setTabBindings.Contains(selectedIndex)) return; + switch (selectedIndex) + { + case 0: + Bind(tbAbstract, "Text", "ShortDescription", c => c.ShortDescription); + Bind(tbDescription, "Text", "Description", c => c.Description); + break; + case 1: + Bind(tbKeywords, "Text", "Search_keywords", c => c.Search_keywords); + Bind(tbDataSource, "Text", "DataSource", c => c.DataSource); + Bind(tbDataSourceSetting, "Text", "DataSourceSetting", c => c.DataSourceSetting); + break; + case 2: + Bind(tbGeoCoverage, "Text", "Geographical_coverage", c => c.Geographical_coverage); + //Bind(dtpStart, "Value", "StartDate", c => c.StartDate); + //Bind(dtpEndDate, "Value", "EndDate", c => c.EndDate); + break; + case 3: + Bind(tbAccessContact, "Text", "Administrative_contact_email", c => c.Administrative_contact_email); + Bind(tbDataController, "Text", "DataController", c => c.DataController); + Bind(tbDataProcessor, "Text", "DataProcessor", c => c.DataProcessor); + Bind(tbJuristiction, "Text", "Juristiction", c => c.Juristiction); + break; + case 4: + Bind(tbPeople, "Text", "AssociatedPeople", c => c.AssociatedPeople); + Bind(tbDOI, "Text", "Doi", c => c.Doi); + break; + case 5: + Bind(tbInitialReleaseDate, "Text", "DatasetReleaseDate", c => c.DatasetReleaseDate); + Bind(tbUpdateLag, "Text", "UpdateLag", c => c.UpdateLag); + break; + default: + break; + } + setTabBindings.Add(selectedIndex); + + //Bind(tbAbstract, "Text", "ShortDescription", c => c.ShortDescription); + //Bind(tbDescription, "Text", "Description", c => c.Description); + //Bind(tbKeywords, "Text", "Search_keywords", c => c.Search_keywords); + //Bind(tbDataSource, "Text", "DataSource", c => c.DataSource); + //Bind(tbDataSourceSetting, "Text", "DataSourceSetting", c => c.DataSourceSetting); + //Bind(tbGeoCoverage, "Text", "Geographical_coverage", c => c.Geographical_coverage); + ////Bind(dtpStart, "Value", "StartDate", c => c.StartDate); + ////Bind(dtpEndDate, "Value", "EndDate", c => c.EndDate); + //Bind(tbAccessContact, "Text", "Administrative_contact_email", c => c.Administrative_contact_email); + //Bind(tbDataController, "Text", "DataController", c => c.DataController); + //Bind(tbDataProcessor, "Text", "DataProcessor", c => c.DataProcessor); + //Bind(tbJuristiction, "Text", "Juristiction", c => c.Juristiction); + //Bind(tbPeople, "Text", "AssociatedPeople", c => c.AssociatedPeople); + //Bind(tbDOI, "Text", "Doi", c => c.Doi); + //Bind(tbInitialReleaseDate, "Text", "DatasetReleaseDate", c => c.DatasetReleaseDate); + //Bind(tbUpdateLag, "Text", "UpdateLag", c => c.UpdateLag); + } + } [TypeDescriptionProvider(typeof(AbstractControlDescriptionProvider))]