#region Disclaimer / License // Copyright (C) 2009, Kenneth Skovhede // http://www.hexad.dk, opensource@hexad.dk // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #endregion using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Data; using System.Windows.Forms; using OSGeo.MapGuide.MaestroAPI; namespace OSGeo.MapGuide.Maestro.ResourceEditors.FeatureSourceExtensions { /// /// Summary description for Extension. /// public class Extension : System.Windows.Forms.UserControl { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox ExtensionName; private System.Windows.Forms.ComboBox ExtensionSchema; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public event FeatureSourceExtension.NameChangedDelegate NameChanged; private EditorInterface m_editor = null; private FeatureSourceTypeExtension m_extension; private bool m_isUpdating = false; private FeatureSourceDescription.FeatureSourceSchema[] m_fsd; public Extension() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); } public void SetItem(FeatureSourceDescription.FeatureSourceSchema[] fsd, FeatureSourceTypeExtension extension) { m_fsd = fsd; m_extension = extension; UpdateDisplay(); } public void UpdateDisplay() { try { m_isUpdating = true; try { ExtensionSchema.BeginUpdate(); ExtensionSchema.Items.Clear(); foreach(FeatureSourceDescription.FeatureSourceSchema fsc in m_fsd) ExtensionSchema.Items.Add(fsc.Fullname); ExtensionSchema.Enabled = true; } catch { ExtensionSchema.Enabled = false; } finally { try { ExtensionSchema.EndUpdate(); } catch {} } ExtensionSchema.SelectedIndex = ExtensionSchema.FindString(m_extension.FeatureClass); ExtensionName.Text = m_extension.Name; } finally { m_isUpdating = false; } } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Component Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Extension)); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.ExtensionName = new System.Windows.Forms.TextBox(); this.ExtensionSchema = new System.Windows.Forms.ComboBox(); this.SuspendLayout(); // // label1 // resources.ApplyResources(this.label1, "label1"); this.label1.Name = "label1"; // // label2 // resources.ApplyResources(this.label2, "label2"); this.label2.Name = "label2"; // // ExtensionName // resources.ApplyResources(this.ExtensionName, "ExtensionName"); this.ExtensionName.Name = "ExtensionName"; this.ExtensionName.TextChanged += new System.EventHandler(this.ExtensionName_TextChanged); // // ExtensionSchema // resources.ApplyResources(this.ExtensionSchema, "ExtensionSchema"); this.ExtensionSchema.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.ExtensionSchema.Name = "ExtensionSchema"; this.ExtensionSchema.SelectedIndexChanged += new System.EventHandler(this.ExtensionSchema_SelectedIndexChanged); // // Extension // this.Controls.Add(this.ExtensionSchema); this.Controls.Add(this.ExtensionName); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Name = "Extension"; resources.ApplyResources(this, "$this"); this.ResumeLayout(false); this.PerformLayout(); } #endregion private void ExtensionSchema_SelectedIndexChanged(object sender, System.EventArgs e) { if (m_extension == null || m_isUpdating) return; m_extension.FeatureClass = ExtensionSchema.Text; if (m_editor != null) m_editor.HasChanged(); } private void ExtensionName_TextChanged(object sender, System.EventArgs e) { if (m_extension == null || m_isUpdating) return; m_extension.Name = ExtensionName.Text; if (NameChanged != null) NameChanged(m_extension, m_extension.Name); if (m_editor != null) m_editor.HasChanged(); } } }