public AlphabetButton(uint width, uint height, AlphabetChars letter) { this.SetSize (width, height); this.letter = letter; Initialise (); }
public AlphabetButton(uint width, uint height, AlphabetChars letter) { this.SetSize(width, height); this.letter = letter; Initialise(); }
protected void InvokeLetterClicked(AlphabetChars letter) { if (LetterClicked != null) { LetterClicked(this, new AlphabetEventArgs(letter)); } }
protected void InvokeLetterClicked(AlphabetChars letter) { if (LetterClicked!=null) LetterClicked (this, new AlphabetEventArgs (letter)); }
public AlphabetButton this[AlphabetChars index] { get { return buttons[index]; } }
public AlphabetEventArgs(AlphabetChars letter) : base() { this.letter = letter; }
public override byte[] Encode(object data) { string strVal = data as string; if (string.IsNullOrEmpty(strVal)) { return(null); } int alphabetCount = AlphabetChars.Length; // 8.2.2 if (alphabetCount < 2 || alphabetCount > FIConsts.TWO_POWER_TWENTY) { throw new LtFastInfosetException( "Failed to write FastInfoset. Invalid Restricted Alphabet. Alphabet must contain between 2 and 2^20 characters."); } // see how many bits we need per char int bits = 2; while ((1 << bits) <= alphabetCount) { bits++; } // populate memory buffer withe encoded bytes MemoryStream buffer = new MemoryStream(); int len = strVal.Length; if (bits == 8) { // easy 1 to 1 mapping int n = 0; while (n < len) { char c = strVal[n++]; int pos = AlphabetChars.IndexOf(c); if (pos == -1) { throw new LtFastInfosetException( "Failed to write FastInfoset. Character not found in Restricted Alphabet [" + c + "]."); } buffer.WriteByte((byte)AlphabetChars[pos]); } } else if (bits == 4) { // semi-easy 2 to 1 mapping int n = 0; while (n < len) { char c = strVal[n++]; int pos = AlphabetChars.IndexOf(c); if (pos == -1) { throw new LtFastInfosetException( "Failed to write FastInfoset. Character not found in Restricted Alphabet [" + c + "]."); } if (n == len) { // fill last 4 bits with terminator value 1111 buffer.WriteByte((byte)((AlphabetChars[pos] << 4) | 0xF)); } else { char c2 = strVal[n++]; int pos2 = AlphabetChars.IndexOf(c2); if (pos2 == -1) { throw new LtFastInfosetException( "Failed to write FastInfoset. Character not found in Restricted Alphabet [" + c2 + "]."); } buffer.WriteByte((byte)((AlphabetChars[pos] << 4) | AlphabetChars[pos2])); } } } else { // tricky arbitry mapping throw new LtFastInfosetException( "Failed to write FastInfoset. Unsupported Feature in FIRestrictedAlphabet Encode."); } return(buffer.ToArray()); }
public AlphabetButton this [AlphabetChars index] { get { return(buttons[index]); } }