Pages

Thursday 23 June 2011

How to make dynamically generated tiles in Windows Mobile 7?

This project was inspired by the way how menu in Portal 2 game works. Portal 2 is a first-person puzzle-platform video game developed by Valve Corporation. Really interesting and very well executed. Going back to the subject when I saw Portal 2 menu in action I decided to do something similar in WM7. The whole idea is quite simple:
  1. define your area of interest e.g. a whole screen or a part
  2. make a screenshot
  3. populate WrapPanel with rectangles which contain appropriate parts of the previously created screenshot.
  4. hide your area of interest (yourUIElement)
  5. start animations
  6. perform a transition if needed 

Points 1 and 2

   1:              WriteableBitmap bmp = new WriteableBitmap((int)LayoutRoot.ActualWidth, (int)LayoutRoot.ActualHeight);
   2:              bmp.Render(yourUIElement, null);
   3:              bmp.Invalidate();
   4:              image.Source = bmp;