public static bool TryGetUriString(IWin32Window owner, out string uri) { using (UriStringInputForm form = new UriStringInputForm()) { if (form.ShowDialog(owner) == DialogResult.OK) { uri = form.uriStringTextBox.Text; return(true); } } uri = ""; return(false); }
private void NewUrlButton_Click(object sender, EventArgs e) { string text; if (!UriStringInputForm.TryGetUriString(this, out text)) { return; } int index = text.IndexOf('#'); if (index < 0) { fragmentTextBox2.Text = ""; } else { fragmentTextBox2.Text = text.Substring(index); text = text.Substring(0, index); } index = text.IndexOf('?'); if (index < 0) { queryTextBox.Text = ""; } else { queryTextBox.Text = text.Substring(index); text = text.Substring(0, index); } Uri uri; if (Uri.TryCreate(text, UriKind.RelativeOrAbsolute, out uri)) { if (uri.IsAbsoluteUri) { UriBuilder ub = new UriBuilder(uri); } } }