One obvious thing in modern symbian mobiles, is how to detect orientation.
I am currently porting some Silverlight 1.0 samples like GrandPiano to Silverlight for Symbian and I was wondering
how can I detect the phone orientation. Well I just analysed the Bing demo and find out that is kind of simple.
What you need is something like this:
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register("Orientation", typeof(Orientation), typeof(Page),
new PropertyMetadata((Orientation)0, new PropertyChangedCallback(OrientationPropertyChanged)));
private static void OrientationPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
(sender as GrandPiano).UpdateOrientation();
}
private void UpdateOrientation()
{
base.Width = (this.Orientation == Orientation.Vertical) ? DeviceVerticalSize.Width : DeviceVerticalSize.Height;
base.Height = (this.Orientation == Orientation.Vertical) ? DeviceVerticalSize.Height : DeviceVerticalSize.Width;
base.Clip = new RectangleGeometry { Rect = new Rect(new Point(), new Size(base.Width, base.Height)) };
}
// Properties
public Orientation Orientation
{
get
{
return (Orientation)base.GetValue(OrientationProperty);
}
set
{
base.SetValue(OrientationProperty, value);
}
}