private void tbServerName_LostFocus(object sender, RoutedEventArgs e) { if (this.tbServerName.Text.Length != 0 && this.tbServerURL.Text.Length == 0) { string text = "http://" + this.tbServerName.Text + "/arcgis/services"; string text2 = this.ReplaceSpecialCharacters(this.tbServerName.Text); if (Uri.IsWellFormedUriString(text, UriKind.Absolute)) { this.tbServerURL.Text = text; } this.tbServerName.Text = text2; } try { if (AGSConnection.NameAlreadyExists(this.tbServerName.Text)) { int num = 1; string text3 = this.tbServerName.Text; string text4 = text3; bool flag = true; while (flag && num < 500) { text4 = string.Format("{0}{1}", text3, num); flag = AGSConnection.NameAlreadyExists(text4); num++; } this.tbServerName.Text = text4; } } catch { } }
private void RenameItem(TextBox tb) { try { AGSConnection aGSConnection = this.lbConnections.SelectedItem as AGSConnection; if (!(tb.Name == aGSConnection.Name)) { if (AGSConnection.NameAlreadyExists(tb.Text)) { int num = 1; string text = tb.Text; bool flag = true; string text2 = text; while (flag && num < 500) { text2 = string.Format("{0}{1}", text, num); flag = AGSConnection.NameAlreadyExists(text2); num++; } tb.Text = text2; } aGSConnection.RemoveFile(); aGSConnection.Name = tb.Text; aGSConnection.SaveToFile(); ListBoxItem listBoxItem = this.lbConnections.ItemContainerGenerator.ContainerFromItem(aGSConnection) as ListBoxItem; if (listBoxItem != null) { listBoxItem.ContentTemplate = (base.FindResource("ConnectionTemplate") as DataTemplate); } } } catch { } }