Orientation Aware Control

Orientation aware control for windows mobile device( windows mobile 5.0) is an outcome from patterns and practice group at microsoft.  now adays mobile deivces support different resoultion and orientation. (i ll refer to Windows mobile 5.0 device simply as devices from now on). the available resolution are 240*320, 640*480, 240*240, 480*480 with portrati and landscape orientation . as with .net compact framework, we can build application to target different devices with with same code base , the problem lies where there are different resolution and orientation  .this was quite cumbersome ,until the orientation aware control was released by Paterrens and practice group as part of mobile client software factory.

u can derive all ur  controls from the orientation aware control ,orientation hooks up with the windows mobile api to get notified when orientation changes,it makes use of Resource localization feature , and creates different custom resource culture for different res /orientation and applying them accordingly.

as most of u people know that VS2005/vs2003 expects certian files to be in certain physcial folder hierarchy . here u can find these naming convention. the generated resources name follow these convention.

so what if ur source code hirerachy is a bit different then expected by VS ,as we have in our current application. Since OAC make heavy use of resources and those resource are getting named as per defualt rules, the OAC does not seem to work properly.:(.

the solution, was to some how instruct the VS to generate the proper name, or to revise the source code herirachy. later was not appropriate since we were going to handover the build to the testing dept after 3 days and this may lead to havoc. so i researched on the first option ,trying to instruct VS , i dwelled within msbuild csproj files, and target files , to get to know how these are generated. and found out that these are generated via task GenerateManifestResourceName. One solution that readily poped up at the moment was to override the task and implement the new behaviour, but that would result in the maintaining a complete custom copy of microsoft msbuild default target files, which may lead to unknow behaviour in case of some updates,
next option was to introduce new Include Type (embeded resource,compile ,content are existing one), i.e. include the new resources as say OACResx , and  write a task to process , and inject the task using BeforeResGen task. that sound quite better, and definitly i was going to implement that but i found  an easeir solution. that is if u want to name ur resource ur way then just insert a tag <LogicalName>ur name goes here </LogicalName> in the Embeded resource node. this wil generate ur desired name, i made heavy use of this feature in my application.

so now OAC is performing great.Althoug i have to edit the  csproj file after creating new control, but thats just one time thing not of much pain. OAC designer should support this kind of thing, i m reviewing their source code for possible changes. will let u know if found something interesting.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s