private void txtIdFrom_Leave(object sender, EventArgs e) { int TextLength; uint MaxValue; TextBox IdBox; IdBox = sender as TextBox; // calculate the text length and Maximum ID value according // with the Message Type // TextLength = (rdbExtended.Checked) ? 8 : 3; MaxValue = (rdbExtended.Checked) ? (uint)0x1FFFFFFF : (uint)0x7FF; // The Textbox for the ID is represented with 3 characters for // Standard and 8 characters for extended messages. // Therefore if the Length of the text is smaller than TextLength, // we add "0" // while (IdBox.Text.Length != TextLength) { IdBox.Text = ("0" + IdBox.Text); } // Because in this example will be sent only Standard messages // we check that the ID is not bigger than 0x7FF // if (Convert.ToUInt32(IdBox.Text, 16) > MaxValue) { IdBox.Text = string.Format("{0:X" + TextLength.ToString() + "}", MaxValue); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data /// structures like a hash table. /// </returns> /// ------------------------------------------------------------------------------------ public override int GetHashCode() { int code = 23; code = code * 31 + m_startRef.BBCCCVVV.GetHashCode(); code = code * 31 + m_endRef.BBCCCVVV.GetHashCode(); code = code * 31 + Text.GetHashCode(); code = code * 31 + TextStartIndex.GetHashCode(); code = code * 31 + TextLength.GetHashCode(); code = code * 31 + VerseStartIndex.GetHashCode(); code = code * 31 + Para.Hvo.GetHashCode(); return(code); }