#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; namespace OSGeo.MapGuide.Maestro.ResourceEditors.FeatureSourceEditors.WFS { /// /// Summary description for FeatureSourceEditorWFS. /// public class FeatureSourceEditorWFS : System.Windows.Forms.UserControl, IResourceEditorControl { private System.ComponentModel.IContainer components; private EditorInterface m_editor; private OSGeo.MapGuide.MaestroAPI.FeatureSource m_feature; private System.Windows.Forms.Label label1; private ResourceEditors.FeatureSourceEditors.ODBC.Credentials credentials; private System.Windows.Forms.ToolTip toolTips; private System.Windows.Forms.TextBox Server; private bool m_isUpdating = false; public FeatureSourceEditorWFS() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); } public FeatureSourceEditorWFS(EditorInterface editor, OSGeo.MapGuide.MaestroAPI.FeatureSource feature) : this() { m_editor = editor; m_feature = feature; UpdateDisplay(); } /// /// 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() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FeatureSourceEditorWFS)); this.Server = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.credentials = new OSGeo.MapGuide.Maestro.ResourceEditors.FeatureSourceEditors.ODBC.Credentials(); this.toolTips = new System.Windows.Forms.ToolTip(this.components); this.SuspendLayout(); // // Server // resources.ApplyResources(this.Server, "Server"); this.Server.Name = "Server"; this.Server.TextChanged += new System.EventHandler(this.Server_TextChanged); // // label1 // resources.ApplyResources(this.label1, "label1"); this.label1.Name = "label1"; // // credentials // resources.ApplyResources(this.credentials, "credentials"); this.credentials.Name = "credentials"; this.credentials.CredentialsChanged += new OSGeo.MapGuide.Maestro.ResourceEditors.FeatureSourceEditors.ODBC.Credentials.CredentialsChangedDelegate(this.credentials_CredentialsChanged); // // FeatureSourceEditorWFS // resources.ApplyResources(this, "$this"); this.Controls.Add(this.Server); this.Controls.Add(this.label1); this.Controls.Add(this.credentials); this.Name = "FeatureSourceEditorWFS"; this.ResumeLayout(false); this.PerformLayout(); } #endregion public object Resource { get { return m_feature; } set { m_feature = (OSGeo.MapGuide.MaestroAPI.FeatureSource)value; UpdateDisplay(); } } public string ResourceId { get { return m_feature.ResourceId; } set { m_feature.ResourceId = value; } } public bool Preview() { return false; } public void UpdateDisplay() { try { m_isUpdating = true; if (m_feature == null || m_feature.Parameter == null) return; credentials.SetCredentials(m_feature.Parameter["Username"], m_feature.Parameter["Password"]); Server.Text = m_feature.Parameter["FeatureServer"]; } finally { m_isUpdating = false; } } public bool Save(string savename) { return false; } private void credentials_CredentialsChanged(string username, string password) { if (m_feature == null || m_isUpdating) return; if (m_feature.Parameter == null) m_feature.Parameter = new OSGeo.MapGuide.MaestroAPI.NameValuePairTypeCollection(); m_feature.Parameter["Username"] = username; m_feature.Parameter["Password"] = password; m_editor.HasChanged(); } private void Server_TextChanged(object sender, System.EventArgs e) { if (m_feature == null || m_isUpdating) return; if (m_feature.Parameter == null) m_feature.Parameter = new OSGeo.MapGuide.MaestroAPI.NameValuePairTypeCollection(); m_feature.Parameter["FeatureServer"] = Server.Text; m_editor.HasChanged(); } public bool Profile() { return true; } public bool ValidateResource(bool recurse) { return true; } public bool SupportsPreview { get { return true; } } public bool SupportsValidate { get { return true; } } public bool SupportsProfiling { get { return false; } } } }