/// <summary> /// Returns whether the given value object is valid for this type. /// Empty strings are allowed, since they will map to null. /// </summary> /// <param name="context"></param> /// <param name="value"></param> /// <returns></returns> public override bool IsValid(System.ComponentModel.ITypeDescriptorContext context, object value) { string s = value as string; JID j; if (s != null) { if (s == "") return true; try { j = new JID(s); } catch (JIDFormatException) { return false; } return true; } j = value as JID; return (j != null); }
private void txtJID_Leave(object sender, EventArgs e) { if (!txtJID.Text.Contains("@") && (m_domain != null)) { txtJID.Text = txtJID.Text + "@" + m_domain; } if (txtNickname.Text == "") { JID jid = new JID(txtJID.Text); txtNickname.Text = jid.User; } }
private void m_pres_OnPrimarySessionChange(object sender, JID bare) { Presence pres = m_pres[bare]; LinkedList nodelist = (LinkedList) m_items[bare.ToString()]; if (nodelist == null) return; foreach (ItemNode n in nodelist) { n.ChangePresence(pres); } }
private void btnAdd_Click(object sender, System.EventArgs e) { this.Cursor = Cursors.WaitCursor; try { JID jid = new JID(txtEntry.Text); lstJID.Items.Add(jid); txtEntry.Clear(); error.SetError(txtEntry, null); } catch { error.SetError(txtEntry, "Invalid JID"); } this.Cursor = Cursors.Default; }
private void btnRemove_Click(object sender, System.EventArgs e) { this.Cursor = Cursors.WaitCursor; try { JID jid = new JID(txtEntry.Text); int i = 0; foreach (object o in lstJID.Items) { if (jid.Equals(o)) { lstJID.Items.RemoveAt(i); txtEntry.Clear(); error.SetError(txtEntry, null); break; } i++; } } catch (Exception ex) { error.SetError(txtEntry, "Invalid JID: " + ex.ToString()); } this.Cursor = Cursors.Default; }
private void jid_Validating(object sender, CancelEventArgs e) { TextBox jtxt = (TextBox) sender; if (jtxt.Text == "") return; try { JID j = new JID(jtxt.Text); } catch { e.Cancel = true; m_form.error.SetError(jtxt, "Invalid JID"); } }