TechDays Canada 2009 Sample Source Code#

In our recent session at TechDays Canada 2009 (Taking Your Application on the Road with Windows Mobile® Software) I promised to make some links and the source code available so here it is

See my post on FITC Mobile 2009 for more links.

Here is the .NET sample source code for Windows Mobile for the demos shown.

If you have questions just ping me via my blog or twitter.


Thursday, October 01, 2009 11:21:29 AM (Eastern Daylight Time, UTC-04:00) #    Comments [0]  | 

 

FITC Mobile 2009 – Wrap Up#

A few weeks ago I did a three presentations and one workshop at FITC Mobile 2009. Unfortunately I did not get to stick around to talk to attendees or go to the second day because I had to fly out to Vancouver for a TechDays session the next day.

I did promise a link to the demo code and various other links to help attendees get up to speed on developing for Windows Mobile so here they are.

  1. Windows Mobile Consumer Solution Accelerator
  2. MSDN UI Framework
  3. Gestures API Managed Wrapper
  4. Windows Mobile Blog
  5. Windows Mobile Developer Site
  6. Porting the Amplitude application to Windows Mobile

Sample Source Code Includes:

And here is a link to the FITC Mobile 2009 Windows Mobile sample source code.

If you have questions just ping me via my blog or twitter.  Also, if you are looking at implementing a mobile solution and don’t know where to start, contact me and I’m sure RedBit can help out!


Thursday, October 01, 2009 10:28:09 AM (Eastern Daylight Time, UTC-04:00) #    Comments [0]  | 

 

Glass Effect On Windows Mobile using Compact Framework#

There has been a lot of talk about how the Windows Mobile user interface is just not up to par with mobile devices such as the iPhone.  As developers we cannot change the Windows Mobile user interface but we do have the opportunity to differentiate our applications from the competition or to just add a little "eye candy" to improve our applications user experience. 

So how do we get this done on Windows Mobile?

Well not being a graphics expert I decided to search the web. First thing I did is figure out how to implement a 'glass effect' using Paint.Net and found this post on how to make 'glass buttons'.  Now that I had the knowledge on how to create a glass button using a graphics program I could try and implement in code.

Before I did that I searched for any existing code on the desktop.  I found an article on Code Project which uses GDI+ on the desktop to create a glass button and works great.  Using the knowledge form Alex Feinman's article on Using GDI+ on Windows Mobile I was able to port the desktop code to Windows Mobile.

The glass button sample accompanying this post just draws on the main form and uses a panel for the bounds of the 'button' and checkboxes to set different states for the button.

In the interest of time, I did not implement a full glass button control and I'll leave it up to you to implement a control possibly using the gradient button for Windows Mobile available on MSDN as a starting point.  Now that you have the knowledge (and code) on how to paint a 'glass effect' on Windows Mobile this should be straight forward.

The code results in the following:

Glass Button with Enabled State
GlassButton1 

Glass Button With Hovered State (or Focused)
GlassButton2 

Glass Button with MouseDown State
GlassButton3 

Although this will add some eye candy to your Windows Mobile application, there are a few caveats:

  1. The glass button sample code doesn't really create a button control but just draws and blits to the screen
  2. GDI+ is only support on Windows Mobile 5+ with touch screens which means this code will not work on SmartPhone (or non-touch screens :) )
  3. GDI+ on Windows Mobile is too slow IMO but caching the bitmaps should help.

So there you have it, glass effect on Windows Mobile.  I'll be following up with some more posts on some techniques I've used in the past to give Windows Mobile applications a nice UI instead of the standard 'grey controls'.


Tuesday, October 14, 2008 10:42:17 PM (Eastern Daylight Time, UTC-04:00) #    Comments [0]  | 

 

NumericUpDown Control and Selecting Text (Revisited)#

Back in Jan '06 I wrote an post on selecting the text of a NumericUpDown control.  Peter Morris pinged me the other day to let me know that he has updated the code provided and added support for Validation events.  It's great to see code being used by others and even greater to see when people like Peter share their changes back with the community.  Check out his updates here.

If you have used any code I've released via my blog, our Open Source products or any code from OpenNETCF partners either in production or just for a hobby project let me know and I can share your story!


Wednesday, July 23, 2008 11:53:37 PM (Eastern Daylight Time, UTC-04:00) #    Comments [0]  | 

 

Using Extension Methods in .NET CF 2.0#

Extension methods are a great addition to the C# 3.0 Language Specification as it allows you to extend a class by adding new methods and extend the class with features you desire.  For the .NET Compact Framework developer this is available in Visual Studio 2008 and .NET Compact Framework 3.5

At OpenNETCF we have a few developer products but are still using .NETCF 2.0.  Even a lot of our consulting jobs still use .NETCF 2.0 (and sometimes 1.0) but more customers are now wanting CF3.5.

Getting used to extension methods and then not being able to use them in pre .NETCF3.5 projects is not fun.  After doing a little search I found this were Daniel explains using extension methods in .NET 2.0 and how the compiler "figures things out". Basically the same thing applies for .NETCF 2.0.  You do require Visual Studio 2008 for this to work.

Basically what you have to do is add the following to your project:

namespace System.Runtime.CompilerServices
{
    public class ExtensionAttribute : Attribute
    {
    }
}

With that you can share extension methods you have written for .NETCF3.5 projects with .NETCF2.0 projects.

For example, I do a lot of custom drawing for controls on Windows Mobile and draw images with transparency.  Pre extension methods I would use something like this in .NETCF 2.0:

protected override void OnPaint(PaintEventArgs e)
{
    Bitmap image = new Bitmap(m_imagePath);
    ImageAttributes imageAtt = new ImageAttributes();
    Color transparentColor = image.GetPixel(0, 0);
    imageAtt.SetColorKey(transparentColor, transparentColor);
    e.Graphics.DrawImage(image, 
        new Rectangle(0,0,image.Width,image.Height), 
        0, 0, 
        image.Width, image.Height, 
        GraphicsUnit.Pixel, imageAtt);
    image.Dispose();
}

With the Attribute workaround above we create an extension method as follows:

public static void DrawImageTransparent(this Graphics graphics, 
    Bitmap image, 
    Rectangle destinationRect)
{
    ImageAttributes imageAtt = new ImageAttributes();
    Color transparentColor = image.GetPixel(0, 0);
    imageAtt.SetColorKey(transparentColor, transparentColor);
    graphics.DrawImage(image, 
        destinationRect, 0, 0, 
        image.Width, image.Height, 
        GraphicsUnit.Pixel, imageAtt);
}

And we can call it from our OnPaint method as follows:

using (Bitmap image = new Bitmap(m_imagePath))
    e.Graphics.DrawImageTransparent(image, new Rectangle(0, 0, image.Width, image.Height));

In the end we get a lot cleaner code and the extension method is portable to .NETCF3.5 and 2.0.


Wednesday, July 23, 2008 11:18:32 AM (Eastern Daylight Time, UTC-04:00) #    Comments [0]  | 

 

All content © 2010, Mark Arteaga
Related Sites
Archives
Sitemap
Disclaimer

Powered by: newtelligence dasBlog 1.9.7174.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts