Windows Phone 7 development

Posts tagged ‘Microsoft Silverlight’

Simple center zoom

To add simple pinch zoom (that I used in my Spirit Level) use the Silverlight Toolkit for WP7 and add the pinch GetureListener to a grid

<toolkit:GestureService.GestureListener>
  <toolkit:GestureListener PinchDelta="GestureListener_PinchDelta" />
 </toolkit:GestureService.GestureListener>

and code in event

 private void GestureListener_PinchDelta(object sender, PinchGestureEventArgs e)
 {
    if (e.DistanceRatio < 1.0 || e.DistanceRatio > 1.4)
    {
      return;
    }
 // Create the animation for pinch
   Storyboard storyboard = new Storyboard();
   DoubleAnimation pinchXAnimation = new DoubleAnimation();
   pinchXAnimation.To = e.DistanceRatio;
   pinchXAnimation.Duration = TimeSpan.FromSeconds(0.3);
   storyboard.Children.Add(pinchXAnimation);
   Storyboard.SetTargetProperty(pinchXAnimation, new PropertyPath("GridScaling.ScaleX"));
   Storyboard.SetTarget(pinchXAnimation, GridScaling);

   DoubleAnimation pinchYAnimation = new DoubleAnimation();
   pinchYAnimation.To = e.DistanceRatio;
   pinchYAnimation.Duration = TimeSpan.FromSeconds(0.3);
   storyboard.Children.Add(pinchYAnimation);
   Storyboard.SetTargetProperty(pinchYAnimation, new PropertyPath("GridScaling.ScaleY"));
   Storyboard.SetTarget(pinchYAnimation, GridScaling);

   storyboard.Begin();

}

What does not WP7 have.

WP7 missing

  1. Copy and paste text.
  2. Preview of back button stack.
  3. Socekts.
  4. Battery api.
  5. Camera – movie api.
  6. Silverlight integration with XNA.
  7. Exposed MAC address of WIFI.
  8. Tile tap and hold option to unintall the app.

There are rumors that Copy and paste will be fixed on February. Will see.

Free ebook!

Charles Petzold has released ebook about Windows Phone 7 for free!

http://www.charlespetzold.com/phone/

Thanks a lot!

Tips about WP7

A few tips that make your life easer.

General

  1. Run your Visual Studio as an administrator (Right-click -> run as administrator) to get better FPS.
  2. Do not place IsTrial() in a loop. It take 60ms or more to return.
  3. Code generation in the compact framework is not the same asĀ  Windows’ code. Jitter is optimized to run fast, not to produce the fastest code.
  4. Property is just a function for .Net CF.

Emulator

  1. To input text into emulator press Page-up (while editing a texbox f.e.) and then use your keybord to enter some text.
  2. Use F9 and F10 to change the volume

Marketplace

  1. To see app on marketplace if you are not from the country that has own marketplace go to Control Panel -> Location and change it to United States.
  2. Do not use transparent images at all!
  3. http://stackoverflow.com/questions/4141186/tips-for-a-successful-windows-phone-7-marketplace-submission

Silverlight

  1. Take as much as you can from Compositor Thread (for callback animations use BitmapCache).
  2. Use Canvas or custom popup instead of default one (Popup class) – lack of hardware acceleration.
  3. If your app loads very fast get rid off the spash screen.

XNA

  1. Use DXT format for textures and pack them into 1 file (faster loading and fewer GPU texture switches).
  2. For things like game stats avoid using strings( immutable). SpriteBatch.DrawString can take a StringBuilder directly for drawing text.
  3. Avoid using/abusing LINQ and foreach (it may causes garbage).
  4. Use Jagged arrays( arrays of arrays) instead of 2d arrays.

More info

%d bloggers like this: