public override void Bind(IEditorService service) { _init = true; _service = service; _fs = (IFeatureSource)_service.GetEditedResource(); cmbMethod.DataSource = (OdbcConnectionMethod[])Enum.GetValues(typeof(OdbcConnectionMethod)); var values = _fs.GetConnectionProperties(); string odbcStr = values["ConnectionString"]; //NOXLATE if (!string.IsNullOrEmpty(odbcStr)) { //See if it is file-basd if (odbcStr.Contains("Dbq=")) //NOXLATE { //Check driver bitness chkUse64Bit.Checked = OdbcDriverNames.Uses64BitDriver(odbcStr); if (odbcStr.Contains("%MG_DATA_FILE_PATH%")) //NOXLATE { cmbMethod.SelectedItem = OdbcConnectionMethod.ManagedFile; } else if (odbcStr.Contains("%MG_DATA_PATH_ALIAS")) //NOXLATE { cmbMethod.SelectedItem = OdbcConnectionMethod.Unmanaged; } else { cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString; } } else //Non-file connection string. Has to be a known driver { cmbMethod.SelectedItem = OdbcConnectionMethod.KnownDriver; } } else if (values["DataSourceName"] != null) //NOXLATE { cmbMethod.SelectedItem = OdbcConnectionMethod.DSN; } else { cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString; } //Fall back to raw connection string if we still can't figure it out if (this.ChildEditor == null) { cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString; } System.Diagnostics.Debug.Assert(this.ChildEditor != null); if (values.Count > 0) { this.ChildEditor.ConnectionProperties = values; } _init = false; }
public override void Bind(IEditorService service) { _init = true; _service = service; _fs = (IFeatureSource)_service.GetEditedResource(); resDataCtrl.Init(service); if (_fs.UsesEmbeddedDataFiles) { var df = _fs.GetEmbeddedDataName(); resDataCtrl.MarkedFile = df; } var values = _fs.GetConnectionProperties(); txtDataSource.Text = values[P_DATASOURCE]; chkReadOnly.Checked = values[P_READONLY] == "TRUE"; //NOXLATE var prov = _service.CurrentConnection.FeatureService.GetFeatureProvider("OSGeo.OGR"); //NOXLATE foreach (var p in prov.ConnectionProperties.Where(p => p.Name != P_DATASOURCE && p.Name != P_READONLY)) { var row = new DataGridViewRow(); var nameCell = new DataGridViewTextBoxCell(); nameCell.Value = p.Name; nameCell.ToolTipText = p.LocalizedName; var currentValue = _fs.GetConnectionProperty(p.Name); DataGridViewCell valueCell = null; if (p.Enumerable) { valueCell = new DataGridViewTextBoxCell(); valueCell.Tag = p; valueCell.Value = currentValue; } else { valueCell = new DataGridViewTextBoxCell(); valueCell.Tag = p; valueCell.Value = currentValue; } if (string.IsNullOrEmpty(currentValue) && !string.IsNullOrEmpty(p.DefaultValue)) { valueCell.Value = p.DefaultValue; _fs.SetConnectionProperty(p.Name, p.DefaultValue); } row.Cells.Add(nameCell); row.Cells.Add(valueCell); if (p.Protected) { pwdCells.Add(valueCell); } grdOtherProperties.Rows.Add(row); } _init = false; }
public override void Bind(IEditorService service) { _init = true; _service = service; _fs = (IFeatureSource)_service.GetEditedResource(); cmbMethod.DataSource = (OdbcConnectionMethod[])Enum.GetValues(typeof(OdbcConnectionMethod)); var values = _fs.GetConnectionProperties(); string odbcStr = values["ConnectionString"]; //NOXLATE if (!string.IsNullOrEmpty(odbcStr)) { //See if it is file-basd if (odbcStr.Contains("Dbq=")) //NOXLATE { //Check driver bitness chkUse64Bit.Checked = OdbcDriverNames.Uses64BitDriver(odbcStr); if (odbcStr.Contains("%MG_DATA_FILE_PATH%")) //NOXLATE { cmbMethod.SelectedItem = OdbcConnectionMethod.ManagedFile; } else if (odbcStr.Contains("%MG_DATA_PATH_ALIAS")) //NOXLATE { cmbMethod.SelectedItem = OdbcConnectionMethod.Unmanaged; } else { cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString; } } else //Non-file connection string. Has to be a known driver { cmbMethod.SelectedItem = OdbcConnectionMethod.KnownDriver; } } else if (values["DataSourceName"] != null) //NOXLATE { cmbMethod.SelectedItem = OdbcConnectionMethod.DSN; } else { cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString; } //Fall back to raw connection string if we still can't figure it out if (this.ChildEditor == null) cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString; System.Diagnostics.Debug.Assert(this.ChildEditor != null); if (values.Count > 0) this.ChildEditor.ConnectionProperties = values; _init = false; }
private void cmbMethod_SelectedIndexChanged(object sender, EventArgs e) { txtConnStr.Text = txtConnectionStatus.Text = string.Empty; OdbcConnectionMethod method = (OdbcConnectionMethod)cmbMethod.SelectedItem; IOdbcSubEditor childEditor = null; switch (method) { case OdbcConnectionMethod.DSN: childEditor = new DSNCtrl(); break; case OdbcConnectionMethod.KnownDriver: childEditor = new KnownDriversCtrl(); break; case OdbcConnectionMethod.ManagedFile: childEditor = new ManagedCtrl(); break; case OdbcConnectionMethod.RawConnectionString: childEditor = new ConnectionStringCtrl(); break; case OdbcConnectionMethod.Unmanaged: childEditor = new UnmanagedCtrl(); break; } if (childEditor != null) { childEditor.Bind(_service); //See if the current connection settings apply try { childEditor.ConnectionProperties = _fs.GetConnectionProperties(); } catch { } childEditor.ConnectionChanged += InternalConnectionChanged; childEditor.RequestDocumentReset += RequestedDocumentReset; pnlMethod.Controls.Clear(); childEditor.Content.Dock = DockStyle.Fill; pnlMethod.Controls.Add(childEditor.Content); } if (this.ChildEditor != null) { this.ChildEditor.ConnectionChanged -= InternalConnectionChanged; this.ChildEditor.RequestDocumentReset -= RequestedDocumentReset; } this.ChildEditor = childEditor; if (this.ChildEditor != null) { if (!_init) { _fs.ApplyConnectionProperties(this.ChildEditor.ConnectionProperties); } btnTest.Enabled = true; } else { btnTest.Enabled = false; } }