Paul Olsen's experiences developing for the Compact Framework
| | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 29 | 30 | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 10 | 11 | 12 | | 13 | 14 | 15 | 16 | 17 | 18 | 19 | | 20 | 21 | 22 | 23 | 24 | 25 | 26 | | 27 | 28 | 29 | 30 | 31 | 1 | 2 | | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Search
Navigation
Categories
Blogroll
|

Tuesday, May 22, 2007
Using Assembly Resources
In the Pocket PC Controls.com Color Picker control their is an embedded bitmap called 'palette.bmp' used for the drop down color selector. Due to the source code being available to clients, it was not acceptable to hard wire the name of the resource which would include the namespace as the source code may be inserted into projects with namespaces other than PPCC.

palette.bmp
The palette.bmp was added to the project inside a project folder called 'resources' and the build action for that file set as 'Embedded Resource'. When compiled, this resource is embedded into the assembly saving the need for adiditional external files.
Rather than using the fully qualified name for the image ie: 'PPCC.resources.palette.bmp', I have simply searched through all available resources to find the 'palette' bitmap.
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
string[] s = asm.GetManifestResourceNames(); // extract names of all embedded resources
for (int i = 0; i <= s.GetUpperBound(0); i++) // wind through all available resources
if (s[i].IndexOf("palette") > 0) // if we find the one we want
_ColorBitmap = new Bitmap(asm.GetManifestResourceStream(s[i])); // assign that resource for use into a local variable
If you are happy to hard wire the resource name, you could always use ILDASM.exe after compilation to find the fully qualified name of the embedded resource, simply double click on the MANIFEST entry. ILDASM.exe is installed with Visual Studio (C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin) and is an excellent tool to have a look at what is going on inside your compiled IL assemblies, it has been a great tool for me over the years.
Tuesday, May 22, 2007 9:33:40 AM UTC
Technical

Sunday, May 20, 2007
ColorButton Control v1.7
It was brought to my attention that the ColorButton control had no way of determining that it had focus!!!
We stuck with the standard button behavior of thickening the border of the button when focused.
The DrawColorButton method looks like this now:
private void DrawColorButton()
{
CollectColors();
// draw the button to the screen
switch (_ButtonShape)
{
case ButtonShape.Ellipse :
if (_ShowGradient)
Draw.Gradient(_Graphics, this.Bounds, _BackDownColor, BackColor, (int)_GradientDirection, (int)_ButtonShape);
else
_Graphics.FillEllipse(_Brush, 0, 0, Width-1, Height-1);
_Graphics.DrawEllipse(_Pen, 0, 0, Width-1, Height-1);
if (base.Focused)
_Graphics.DrawEllipse(_Pen, 1, 1, Width - 3, Height - 3);
break;
case ButtonShape.Rectangle :
if (_ShowGradient)
Draw.Gradient(_Graphics, this.Bounds, _BackDownColor, BackColor, (int)_GradientDirection, (int)_ButtonShape);
else
_Graphics.FillRectangle(_Brush, 0, 0, Width, Height);
_Graphics.DrawRectangle(_Pen, 0, 0, Width-1, Height-1);
if(base.Focused)
_Graphics.DrawRectangle(_Pen, 1, 1, Width - 3, Height - 3);
break;
}
DrawStringToButton();
DrawIconToButton();
}
Those of you who purchased the control in the last 6 months would like the update please send me an email.
There is still no way of determining if the ColorButton has focus when using images and we will add this functionality in the near future. If there are any of you who would like to see a new image property added to cater for the focused state, please let me know and we can push that along.
You can see here that colorButton2 has focus:
Sunday, May 20, 2007 6:32:03 AM UTC
Technical | Color Button
MEDC 2007 Sydney Australia
I attended my first MEDC this week.
There were a few streams that you could take... as it happens, I have been into RDA (Remote Data Access) for a while and thought it would be good to see what the experts had to say, I would have loved to hear some one talk at me about security for an hour or so but as it happens there was not
that much time, so there was quite a bit of glossing over subjects. Probably should have taken the Business stream which talked about the interaction between Windows Mobile and Exchange Server to learn something new. Oh well, it was a good day out and I got to speak to quite a few interesting people and I got a nice back pack and jacket. Will try the Tech Ed next year I think.
Sunday, May 20, 2007 5:55:11 AM UTC
Events

Saturday, May 19, 2007
New to blogging
We have had PocketPC Controls.com up and running since January 2004 and have loved every minute of creating the controls for the site as well as the interaction from developers who come from all over the world.
Over the years, we have had interaction with some fantastic developers from large corporations to one man operations and have enjoyed dealing with every one of them.
Since the offset, we have relied on the internet (as a well as a few books) for information on how to create and expand the controls that we create. Often I have wanted to share some of the things that I have learnt (and sometimes it takes some doing) with other developers. It is difficult to know where to post as there are so many sites available for development information these days. This is my answer, a very relaxed blog, which I hope will become useful for others with a similar passion for Mobile Device software development.
Saturday, May 19, 2007 12:59:36 PM UTC
Events