/// <summary> /// Initializes a new instance of the <see cref="TFSConnectionEditor"/> class. /// </summary> /// <param name="tfsConectionString">The TFS conection string.</param> /// <param name="isEdit">if set to <c>true</c> [is edit].</param> public TFSConnectionEditor(TFSConnectionString tfsConectionString, bool isEdit = false) : this() { tfsConectionString.Validate(); this.txtServerName.Text = tfsConectionString.ServerName; this.txtPortNumber.Text = tfsConectionString.PortNumber.ToString(CultureInfo.InvariantCulture); this.txtDefaultCollection.Text = tfsConectionString.DefaultCollection; this.rbtHttps.Checked = tfsConectionString.IsHttps; this.rbtHttp.Checked = !tfsConectionString.IsHttps; // Fix: 251237 if (isEdit) { this.txtServerName.ReadOnly = true; } }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void BtnSave_Click(object sender, EventArgs e) { // This ensures proper values for database if (!this.IsValidTFSConfiguration()) { return; } // throw any kind of db error. Don't show here since this is a dialog. try { TFSConnectionString newtfsConnectionString = new TFSConnectionString { IsHttps = this.rbtHttps.Checked, ServerName = this.txtServerName.Text, PortNumber = int.Parse(this.txtPortNumber.Text), DefaultCollection = this.txtDefaultCollection.Text }; newtfsConnectionString.Validate(); newtfsConnectionString.SaveOrUpdateTFSConnectionStringToDB(!this.txtServerName.ReadOnly); this.Close(); } catch (InvalidOperationException ex) { ex.ShowUIException(); } catch (ArgumentException ex) { ex.ShowUIException(); } catch { new DBConcurrencyException("Unable to write changes to database. Unexpected error. Please try again.").ShowUIException(); } }