Mr Andersson

Posts Tagged ‘windows mobile

Deploying applications to Windows and Windows Phones which supports dynamic modules

leave a comment »

Many .Net applications being developed today are leveraging the greatness of dependency injection using some sort of inversion of control-container. So do we at RemoteX when we develop the product called RemoteX Applications. The product has two client applications which roughly adresses the same use cases. One is targeting desktop computers and the other one is targeting Windows Phone (you can read more here and here).

As you can tell by the name, the product consists of several applications (or rather modules). Using frameworks like Prism or Caliburn we can, in code, easily manage each part of the product. And the deployment is taken care of using ClickOnce technology using mage.exe (the MAnifest GEnerator).
But that’s for the desktop client targeting WPF.

So the big question is, how are we going mobile with this?

What regards an inversion of control-container we are “almost there”. We have a home-grown container in place which have been around for a while now, even though it lacks some basic features you would expect an ioc container of year MMX to have.
Speaking of deployment to the Windows Phone you probably know you are kind of locked to using CABinet files. If you are using the tools Microsoft brought to us, you probably also use their Device Setup projects in Visual Studio.
They are good, but you must use Visual Studio to choose the contents of and create/build your CAB file.
What this basically means is that we need to use devenv.exe to build each customer’s customized CAB file.
So up til now we have not had per customer customized CAB files.

All I wanted was ClickOnce technology and a manifest generator for the Windows Phone. So what’s the solution on that?
Say hello to the PowerShell script New-CabWizInf.ps1:

.\New-CabWizInf.ps1 -path .\myapp.inf -appName “My Application” -manufacturer “RemoteX” -fromDirectory .\MyApplication\bin\Release

It works like mage.exe with its -fromDirectory switch and creates the necessary .inf-file (like an Visual Studio Device Setup project would). All needed from that point is to call CABWIZ.exe and Set-AuthenticodeSignature in PowerShell to create and sign the CAB file.
The real power is the -fromDirectory switch which allows us to create custom CAB files on the fly.

So here is a peek of what our setup package scripts now looks like:

Setup Package for Windows using ClickOnce
mage -new deployment -tofile MyApp.application -fromdirectory bin\Release -name “My App” -publisher “RemoteX”
mage -sign

Setup Package for Windows Phones using CAB files
.\New-CabWizInf.ps1 -path MyApp.inf -fromDirectory bin\Release -appName “My App” -manufacturer “RemoteX”
cabwiz MyApp.inf /dest .\
Set-AuthenticodeSignature .\MyApp.CAB

So right now I’m a very happy camper since our packaging tools for Windows AND Windows Phone have equal capabilities which allows us to use dependency injection with dynamic module selection.

Next stop, Prism and Silverlight for the Windows Phone?

Written by anderssonjohan

January 20, 2010 at 23:28

Posted in software

Tagged with , , , , ,

A solution for transparent images on Compact Framework

with 14 comments

Recently I worked on the problem of getting full 8-bit image transparency on Windows Forms using the .Net Compact Framework. I have tried to find a nice solution before, but at the time, I didn’t find a solution that gave me the results I wanted.
Yesterday I visited the local Microsoft sub-office here in Stockholm to attend to a Mobility Day event. After the event I sent an e-mail to David Goon (ADC at Microsoft Ltd., UK), the guy who held the talk during the second part of the day. He showed the audience a numerous of cool new things that you can do with the Microsoft Mobile Sample wrapper APIs for GPS integration, message interception using the Messaging API, and a few cool things with the Camera API (but that’s another blog entry :)).
I asked him if he was aware of a solution to my transparency problem what regards Windows Mobile 5+6, and he led me to my previous stop in an attempt to achieve this effect:
With regards to alpha blending, the following blog might give you some clues: http://blogs.msdn.com/chrislorton/archive/2006/04/07/570649.aspx.”

After re-reading Chris’ sample code, I modified it a bit to suite my needs. My example code can be downloaded here.

I created two new classes that uses the imaging features that Chris uses:
AlphaImage – A wrapper class for the IImage interface that can be used like the System.Drawing.Image class (but with alpha support of course).
AlphaImageControl – A form widget that works like the PictureBox that uses an AlphaImage instance. This widget can of course easily be accessed from the toolbox in the IDE.

The image I have used in my example is a 24-bit PNG with white text surrounded by a lot of transparent pixels. The form that the image control is placed on has a solid background color (SystemColors.Control).
Here is a capture from the emulator of the result:


And what you will see in the IDE designer is:

Thanks Chris for an excellent piece of code (this is your code, I just wrapped it all together).
Thanks David for pointing me back in the right direction!

According to my tests, this works just fine in the PocketPC emulator (see attached image) using Windows Mobile 5 as well as on a HTC TyTn II device, which operates on Windows Mobile 6 Professional Edition. However, I can not guarantee that this will work as expected on any Windows Mobile device.
This posting is provided “AS IS” with no warranties.

AlphaImageExample.zip

Written by anderssonjohan

October 12, 2007 at 23:08

Posted in programming

Tagged with , ,