Monday, December 06, 2004

I've updated the SIPControl to draw images in place of buttons. It required just minimal changes to the code. I added Image and ImageDown properties to the KeyButton class, and added an new override to the DrawButton method to support image drawing:

private void DrawButton(string text, Graphics gx, Rectangle rc, Color foreColor, Image image)

{

      Brush foreBrush = new SolidBrush(foreColor);

     

      // draw image

      gx.DrawImage(image, rc.Left, rc.Top);

      //Center the text

      SizeF size = gx.MeasureString(text, this.Font);

           

      int X = rc.Left + (int)(rc.Width - size.Width)/2;

      int Y = rc.Top + (int)(rc.Height - size.Height)/2;

                 

      gx.DrawString(text, this.Font, foreBrush, X, Y);

                 

      foreBrush.Dispose();

}

I've also modified the OnPaint method to recognize if the KeyButton has an image assigned. So now, if you'd want to have image to draw a button, the client code would look like that:

ButtonRow row1 = new ButtonRow(new string[]{"q","w","e","r","t","y","u","i","o","p","[","]"}, 5, 20);

row1.Space = 0;

//Assign images

foreach(KeyButton button in row1.Buttons)

{

      button.Image = bitmap;

      button.ImageDown = bitmapDown;

}

And here's the screen shot of the sample:

Download the new version of the SIPControl and a sample here.

SIPTest1.zip (10.05 KB)

12/6/2004 5:51:37 PM (GMT Standard Time, UTC+00:00)  #     | 
 Friday, December 03, 2004

As you probably know that if you would want to implement a full “kiosk” mode on Pocket PC – which means that you need to hide the “Start” and SIP buttons to prevent users getting into underlying system. It’s easy to employ – just remove a MainMenu from a Form, set ControlBox to false and set the WindowState = FormWindowState.Maximized in the form’s Load event. But what if I still need clients to use SIP to enter some text? We could use the SipShowIM API, but this call will make the SIP button to appear again breaking the “kiosk” mode. So, to solve this puzzle I’ve created the SIPControl  - an owner-drawn control that allows creation of any type of SIP’s. Here’s the code snip that shows how to create a full SIP keyboard on your form:

sipFull = new SIPControl();

                 

// Location and size

sipFull.Location = new Point(1, 60);

sipFull.Size =    new Size(240, 90);

     

//Create ButtonRows

ButtonRow row1 = new ButtonRow(new string[]{"Q","W","E","R","T","Y","U","I","O","P"}, 1, 0);

row1.Space = 4;

// Add ButtonRow to the Rows collection

sipFull.Rows.Add(row1);

ButtonRow row2 = new ButtonRow( new string[]{"A","S","D","F","G","H","J","K","L"}, 10, 22);

row2.Space = 4;

sipFull.Rows.Add(row2);

ButtonRow row3 = new ButtonRow( new string[]{"Z","X","C","V","B","N","M"}, 30, 44);

row3.Space = 4;

sipFull.Rows.Add(row3);

ButtonRow row4 = new ButtonRow(  new string[]{"1","2","3","4","5","6","7","8","9","0"}, 1, 66);

row4.Space = 4;

sipFull.Rows.Add(row4);

                 

// Hook up the Click event

sipFull.ButtonClick+=new ButtonClickEventHandler(sipFull_ButtonClick);

this.Controls.Add(sipFull);        

 And here’s how the sample looks:

 

You can download the SIPControl and a sample from here.

SIPTest.zip (7.8 KB)
12/3/2004 4:44:53 PM (GMT Standard Time, UTC+00:00)  #     |