@ Dave - Thank you for your detailed response.
I created a small test app, Glide1, with a static class Util, containing the code.
After ensuring that the 4 gif files are 480 x 192, with each button 48 x 48, I modified the code in the CreateKeyboard() method you provided, accordingly, as below.
An exception occurs when the code attempts to load the first gif file.
“An unhandled exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Graphics.dll”
" #### Exception System.Exception - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Bitmap::.ctor [IP: 0000] ####
#### Glide1.Util::CreateKeyboard [IP: 0029] ####
#### Glide1.Program::Main [IP: 0016] ####
A first chance exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Graphics.dll
An unhandled exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Graphics.dll"
I stepped throught the code and noticed that the exception occurs just after the first "new Bitmap)…"
keyboard.BitmapUp = new Bitmap[4]
{
new Bitmap(Resources.GetBytes(Resources.BinaryResources.Keyboard_480x192_Uppercase_large), Bitmap.BitmapImageType.Gif),
Do you perhaps have any further ideas regarding what may be causing this, and how to get past it?
Many thanks.
// modified code
public static Keyboard CreateKeyboard()
{
Keyboard keyboard = new Keyboard(480, 192, 3, 48, 0);
keyboard.BitmapUp = new Bitmap[4]
{
new Bitmap(Resources.GetBytes(Resources.BinaryResources.Keyboard_480x192_Uppercase_large), Bitmap.BitmapImageType.Gif),
new Bitmap(Resources.GetBytes(Resources.BinaryResources.Keyboard_480x192_Lowercase_large), Bitmap.BitmapImageType.Gif),
new Bitmap(Resources.GetBytes(Resources.BinaryResources.Keyboard_480x192_Numbers_large), Bitmap.BitmapImageType.Gif),
new Bitmap(Resources.GetBytes(Resources.BinaryResources.Keyboard_480x192_Symbols_small), Bitmap.BitmapImageType.Gif)
};
// set the default key content.
string[][] keyContent = new string[4][];
// letters
keyContent[0] = new string[10] { "q", "w", "e", "r", "t", "y", "u", "i", "o", "p" };
keyContent[1] = new string[9] { "a", "s", "d", "f", "g", "h", "j", "k", "l" };
keyContent[2] = new string[9] { Keyboard.ActionKey.ToggleCase, "z", "x", "c", "v", "b", "n", "m", Keyboard.ActionKey.Backspace };
keyContent[3] = new string[5] { Keyboard.ActionKey.ToNumbers, ",", Keyboard.ActionKey.Space, ".", Keyboard.ActionKey.Return };
keyboard.SetViewKeyContent(Keyboard.View.Letters, keyContent);
// numbers
keyContent[0] = new string[10] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
keyContent[1] = new string[10] { "@ ", "#", "$", "%", "&", "*", "-", "+", "(", ")" };
keyContent[2] = new string[9] { Keyboard.ActionKey.ToSymbols, "!", "\"", "'", ":", ";", "/", "?", Keyboard.ActionKey.Backspace };
keyContent[3] = new string[5] { Keyboard.ActionKey.ToLetters, ",", Keyboard.ActionKey.Space, ".", Keyboard.ActionKey.Return };
keyboard.SetViewKeyContent(Keyboard.View.Numbers, keyContent);
// symbols
keyContent[0] = new string[10] { "~", "`", "|", "•", "v", "p", "÷", "×", "{", "}" };
keyContent[1] = new string[10] { Keyboard.ActionKey.Tab, "£", "¢", "€", "º", "^", "_", "=", "[", "]" };
keyContent[2] = new string[9] { Keyboard.ActionKey.ToNumbers, "™", "®", "©", "¶", "\\", "<", ">", Keyboard.ActionKey.Backspace };
keyContent[3] = new string[5] { Keyboard.ActionKey.ToLetters, ",", Keyboard.ActionKey.Space, ".", Keyboard.ActionKey.Return };
keyboard.SetViewKeyContent(Keyboard.View.Symbols, keyContent);
// or we could just call this:
// keyboard.DefaultKeyContent();
int[][] keyWidth = new int[4][];
// Each array entry represents a row of keys on the keyboard top-down (0-3)
// Each array within these entries contains the widths of the keys for that row.
// For example: keyWidth[0] = new int[10] { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 }
// represents the first row (0) which contains the keys Q, W, E, R, T, Y, U, I, O, P
// Letters
keyWidth[0] = new int[10] { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 };
keyWidth[1] = new int[9] { 48, 48, 48, 48, 48, 48, 48, 48, 48 };
keyWidth[2] = new int[9] { 72, 48, 48, 48, 48, 48, 48, 48, 72 };
keyWidth[3] = new int[5] { 72, 48, 240, 48, 72 };
keyboard.SetViewKeyWidth(Keyboard.View.Letters, keyWidth);
// Numbers
keyWidth[0] = new int[10] { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 };
keyWidth[1] = new int[10] { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 };
keyWidth[2] = new int[9] { 72, 48, 48, 48, 48, 48, 48, 48, 72 };
keyWidth[3] = new int[5] { 72, 48, 240, 48, 72 };
keyboard.SetViewKeyWidth(Keyboard.View.Numbers, keyWidth);
// Symbols
keyWidth[0] = new int[10] { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 };
keyWidth[1] = new int[10] { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 };
keyWidth[2] = new int[9] { 72, 48, 48, 48, 48, 48, 48, 48, 72 };
keyWidth[3] = new int[5] { 72, 48, 240, 48, 72 };
keyboard.SetViewKeyWidth(Keyboard.View.Symbols, keyWidth);
keyboard.CalculateKeys();
return keyboard;
}