HTC Update for Windows Phone

February 17, 2012 Leave a comment

Yesterday (16/02/2012) I received a notification on my HTC 7 Trophy that there was an update for my phone.

When connected to Zune on my computer the update ws stated as “HTC Update for Windows Phone” with no other detail.

The feature this update adds seem to be “Internet Sharing” (Tethering) and now there is a New Zealand contact number on the devices About page (but not freephone, unless you are somewhere in the north island)

I am not sure what else has changed. If you know please post comments and I will update the post.

Subscribe to Podcasts on WP7 in Music Hub

As I was lucky enought to get a new Windows Phone 7 (HTC 7 Trophy) from my Wife for Christmas I have been looking at a few of the features.

One thing I found was I could not subscribe to new Podcasts directly on the device form the Music Hub.

I know what you are thinking, the title of this post says you can subscribe to podcasts from the device, and he is now telling me you can’t. I will get to how to do this in a minute.

The way i have found to do this (at least in New Zealand) is to connect the phone to your computer and open Zune.

You will need to have subscribed to podcasts in zune.

I’m sure this sounds familliar to most other tutorials on how to load podcasts onto you phone, but this is where this post changes.

drag and drop one episode of the podcasts you would like to subscibe to on your WP7 onto the device icon at the bottom of Zune.

Once they are synced to the phone disconnect the phone from the computer.

Then go into the Music & Video Hub and go into Podcasts.

Here you will see the podcasts that you have synced an episoed of.

Select one of these podcasts and at the bottom of the page you will see a “Subscribe” button.

Click this and define your preferences for the podcast, and click “Confirm”

By default your podcasts will automaticlly download when your phone is charging and over WIFI (you can change this setting but I did not as i do not have a mobile data plan.)

I found that the podcasts then synced over WIFI without being connected to power (i think the battery just needs to be above half-way)

The advantage of this method over suggestions on other blogs (installing third party podcast apps) is that you can have your podcast play in the background.

I hope this helps people get more from the great Windows Phone 7 (7.5)

Categories: Podcasts, Windows Phone 7

Bing Maps WPF Beta Control refresh display

As people who have used Microsoft’s new WPF Bing Maps Control Beta may have found, when you add points to plolygons/polylines after the map has loaded, i.e. when the user clicks, the item will not display/update until you move the map, or remove and readd the object form the map.

I have found a workaround for this issue based on the need to move the map to refresh it.

The solution is to “jiggle” the map in code when a polygon/ployline is updated (new poitns added / points removed).

I have a project when want to allow the user to draw ploygons around regions on a map by clicking the points that will make up the polygon.

Without the workaround after each point added the user would have to drag the map around to see the current state of the polygon, if they dont and they get distacted with another task and come back to the application then they may forget where they wer up to or end up readding the points they already have which would lead to excess data stored and potentionaly undesirable appearance of the polygons.

Now I have added the code below after the user clicks and i have added the point to the polygon and the polygon now is shown when the user clicks, no need to drag the map.

Here is the code that makes it possible along with a sample setup (see the JiggleMap method):

This Sample is adapted from a same i created for a replay to this issue on the Bing Maps Development Forum: http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/23b44d8e-5532-4cef-95fe-8a50a59747f8

Steps:

  1. Create a new WPF project
  2. Add a reference to the WPF Bing Maps Cotrol Beta DLL
  3. Replace the MainWindow.xaml and MainWindow.xaml. vb witht eh code below
  4. Press F5 to run

MainWindow.xaml

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
        <m:Map x:Name="MyMap" />
    </Grid>
</Window>

MainWindow.xaml.vb


Class MainWindow

    Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded

		' Build a ployline and add random coordinates to it every 2 seconds

        Dim pl As New Microsoft.Maps.MapControl.WPF.MapPolyline()
        pl.Stroke = New SolidColorBrush(Colors.Black)
        pl.StrokeThickness = 5
        pl.StrokeLineJoin = PenLineJoin.Round
        pl.Locations = New Microsoft.Maps.MapControl.WPF.LocationCollection()

        MyMap.Children.Add(pl)

        Randomize()

        Dim rnd As New Random()

        Dim t As New Timers.Timer(2000)

        AddHandler t.Elapsed, Sub()
            Dispatcher.BeginInvoke(Sub()
					' Add random point
					pl.Locations.Add(New Microsoft.Maps.MapControl.WPF.Location(
						rnd.Next(-180, 180), rnd.Next(-180, 180)))

					' One workaround, Remove and re-add polyline, we wont use this anymore
					'MyMap.Children.Remove(pl)
					'MyMap.Children.Add(pl)

					' better method, use JiggleMap
					JiggleMap()
				End Sub)
			End Sub

        t.Start()

    End Sub

Private Sub JiggleMap()

	' I find is best to run this in a background thread so as to avoid
	' locking up the UI
	Dim bw As New ComponentModel.BackgroundWorker()

    AddHandler bw.DoWork, Sub(sender As Object, e As ComponentModel.DoWorkEventArgs)
			' Retrieve current centre from arguments
			Dim centre As Microsoft.Maps.MapControl.WPF.Location = e.Argument

			' Create new centre which is only slightly differnet to current
			Dim newcentre As New Microsoft.Maps.MapControl.WPF.Location(
					centre.Latitude + 0.00000000001, centre.Longitude)

			' Since we are in a BackgroundWorker we need to call back to the
			' UI thread using the Dispatcher
			Dispatcher.Invoke(Sub()
					' Chage the map centre to the new centre
					MyMap.Center = newcentre
				End Sub)

			' Setup a timer so we can reset the centre after a short break
			' otherwise the change may not register before it is reset
			Dim t As New Timers.Timer(125)
			t.AutoReset = False

			AddHandler t.Elapsed, Sub()
					' Since we are in a BackgroundWorker we need to call back
					' to the UI thread using the Dispatcher
					Dispatcher.Invoke(Sub()
							MyMap.Center = centre
						End Sub)
				End Sub

			t.Start()
		End Sub

	' Pass in the current centre point of the map
    bw.RunWorkerAsync(MyMap.Center)

End Sub

End Class

I hope this will help others, until such time as the WPF control can do this for us.

Happy Mapping

Categories: .NET, Bing Maps, Mapping, Tutorial, WPF

Silverlight 5 RTW 3D

December 13, 2011 Leave a comment

As many of you will know Microsoft released Silverlgiht 5 RTW over the weekend.

Read about the release over at Pete Brown’s blog http://10rem.net/blog/2011/12/09/announcing-the-release-of-silverlight-5

Get the ‘Bits’ from http://www.silverlight.net/downloads

I have updated the 3D Campus map test application I developed with the SL5 Beta and RC tools (http://drmcg.wordpress.com/2011/09/05/imap-3d-campus-map-in-3d-thanks-to-silverlight-5/) to RTW which did not require any changes to the code….

Until I tried to run it.

I then stuck the issue with graphics locked down for “Security”

luckily I was able to find som information about this in the documentation and http://www.sharpgis.net/post/2011/12/10/Why-Silverlight-5%E2%80%99s-3D-is-(almost)-useless.aspx and http://blogs.msdn.com/b/eternalcoding/archive/2011/12/10/silverlight-5-is-out.aspx

I have now added a block of code to check if 3D can be run (this could easily be refactored into something smaller)

 System.Windows.Controls.ChildWindow cw = new System.Windows.Controls.ChildWindow();

        bool messageShown;

        void TestRenderMode()
        {
            if (GraphicsDeviceManager.Current.RenderMode != RenderMode.Hardware)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                TextBlock tb = new TextBlock();
                switch (GraphicsDeviceManager.Current.RenderModeReason)
                {
                    case RenderModeReason.GPUAccelerationDisabled:

                    case RenderModeReason.SecurityBlocked:
                        sb.AppendLine("1. Right click on your Silverlight plug-in.");
                        sb.AppendLine("2. Click the 'Silverlight' option.");
                        sb.AppendLine("3. Go to the permissions tab.");
                        sb.AppendLine("4. Find the domain '" + Application.Current.Host.Source.AbsoluteUri.Substring(0, Application.Current.Host.Source.AbsoluteUri.IndexOf(Application.Current.Host.Source.LocalPath)) + "'");
                        sb.AppendLine("5. When you find the entry, select the item below it '3D Graphics: use blocked display drivers'.");
                        sb.AppendLine("6. Click 'Allow'");
                        sb.AppendLine("7. Click 'Ok'");
                        sb.AppendLine("8. Refresh Page");

                        tb.TextWrapping = TextWrapping.Wrap;
                        tb.Text = sb.ToString();

                        cw.Width = 500;
                        cw.HasCloseButton = false;

                        cw.Content = tb;
                        cw.Title = "Cannot Load 3D. Please Follow instructions below";

                        if (!messageShown)
                        {
                            messageShown = true;
                            cw.Show();
                        }

                        return;
                    case RenderModeReason.Not3DCapable:
                        sb.AppendLine("Your Graphics card does not support 3D");

                        tb.TextWrapping = TextWrapping.Wrap;
                        tb.Text = sb.ToString();

                        cw.Width = 500;
                        cw.HasCloseButton = false;

                        cw.Content = tb;
                        cw.Title = "Cannot Load 3D.";

                        if (!messageShown)
                        {
                            messageShown = true;
                            cw.Show();
                        }

                        return;
                    case RenderModeReason.TemporarilyUnavailable:
                        sb.AppendLine("1. Right click on your Silverlight plug-in.");
                        sb.AppendLine("2. Click the 'Silverlight' option.");
                        sb.AppendLine("3. Go to the permissions tab.");
                        sb.AppendLine("4. Find the domain '" + Application.Current.Host.Source.AbsoluteUri.Substring(0, Application.Current.Host.Source.AbsoluteUri.IndexOf(Application.Current.Host.Source.LocalPath)) + "'");
                        sb.AppendLine("5. When you find the entry, select the item below it '3D Graphics: use blocked display drivers'.");
                        sb.AppendLine("6. Click 'Allow'");
                        sb.AppendLine("7. Click 'Ok'");

                        tb.TextWrapping = TextWrapping.Wrap;
                        tb.Text = sb.ToString();

                        cw.Width = 500;
                        cw.HasCloseButton = false;

                        cw.Content = tb;
                        cw.Title = "Cannot Load 3D. Please Follow instructions below";

                        if (!messageShown)
                        {
                            messageShown = true;
                            cw.Show();
                        }

                        return;
                }
            }

            cw.Close();

            LoadScene();
        }
        

As Morten on SharpGIS above says, it would be great if the allow/deny model was the same as is implmented for allowing access to the Microphone/Webcam or allowing the application to remain full screen when it looses focus.

Hopefully there with be a GDR update that will add this dialog but in the mean time we will have to add the step-by-step instructions to direct the user to allow 3D to be run, or request the user to run your application with Elevated Privilages.

You can have a look at the live test application at: http://www.propserv.otago.ac.nz/iMap3DTest/

Please let me know in the comments if you think the wording needs improvement, or any comments about the app. Please also note that this is not a final application just an initial test.

You can move round the map by clicking & dragging, or using the keys W S A D, you can also change the altitude of the camera by rolling the mouse wheel. You can click on a builidng or hold down CTRL and click multiple buildings. You can also adjust the Pitch of the camera with the Pitch slider at the top left, or move to ground level to “Walk Around” by clicking “Walk Around Toggle”.

You get great performance with the new XNA based 3D in Silverlight 5, and I look foward to seeing what people can do with it.

Windows 8 on Netbook

September 16, 2011 Leave a comment

Like many people I have downloaded the Developer Preview of Windows 8 from http://dev.windows.com/

Since downloading it I have setup my eMachines 350 netbook with the 64bit version (with developer tools).

The netbook has the following specs:

  • Intel N450 Atom processor 1.66GHz
  • 1GB DDR2 RAM (yes I know 2GB is recommended for 64bit)
  • 10.1″ 1024×600 LCD screen

I followed Scott Hanselman’s guide to setting up a VHD and installing Windows 8 to it so I could run it on the hardware without having to worry about partitioning or replacing Win7.

Scott’s guide to installing Windows 8 to VHD: http://www.hanselman.com/blog/GuideToInstallingAndBootingWindows8DeveloperPreviewOffAVHDVirtualHardDisk.aspx

The great thing about the windows 8 install is that is sets up the graphical bootloader so you can select if you want Windows 8 or your other OS, you can even use your mouse or touchpad to make your selection.

The first-run setup is easy to follow and easily detected the wireless device and allowed me to connect to my wireless network.

You are able to either setup local user account or use your Windows Live login  if you take the second option then your setting will sync to the Cloud and can span across devices (I have not tried this yet myself)

Once you get setup and running on a netbook with native resolution less than 1024×768 you will find the Metro apps (IE, Build, Tweet@rama etc) do not launch, this is because a resolution greater than or equal to 1024×768 is required for the apps.

The initial suggestion from one of the windows twitter accounts was to connect to external monitor.

I found with a bit of searching a solution that requires a modification to the registry to allow resolutions outside the normal range for the system (my existing range was 800×600 and 1024×600)

Please note: Modifying your registry can be dangerous and I will not be held responsible if this breaks your system.

  1. Press Windows key + r to get run dialog
  2. Type in: regedit and click run
  3. accept UAC prompt
  4. Select top node (Computer)
  5. Press Ctrl + F to open find dialog
  6. enter: Display1_DownScalingSupported
  7. change key value from 0 to 1
  8. repeat for all instances
  9. Restart computer
  10. After reboot go to the desktop and right click and select “Screen Resolution”
  11. Change resolution to 1024×768
  12. You should then be able to click Start (by moving mouse cursor to bottom left of screen, or just press the Windows key)
  13. you should now be able to launch the Metro apps

 

I am quite impressed with the Metro inspired interface and I think it would be great on a touch-screen device like the Samsung devices the Build attendees received.

I’m sure there is something I missed so I expect I will probably have more posts.

Categories: Windows, Windows 8

iMap 3D Campus Map in 3D thanks to Silverlight 5

September 5, 2011 1 comment

With the impending release of Silverlgiht 5 and the release of the Beta and RC we have been able to produce with our existing triangulated dataset a 3D campus scene using the power of XNA in Sliverlight 5.

We are able to build up the scene and move the camera through it. This is something I have always looked at that would be quite exciting, and give users a new perspecive of the University and how to navigate it.

The following are small set of screenshots from the trial application which we have developed to test 3D in Silverlgiht 5

Solid shaded 3D campus scene

Wireframe of the above 3D campus scene

We also have the ability to walk through the 3D scene and see our buildings from a whole new perspective.

Categories: 3D, iMap, Silverlight, Silverlight 5

Blog Moved to WordPress

September 5, 2011 Leave a comment

I have decided to move my blog to DRMcG.Wordpress.com to give it a go and it seems to have easy integration of souce code samples into blog posts.

This was probably possible with Blogger but this changed seemed like a good choice.

Thank you for continuing to follow me and I hope to increase the number of posts I make.

Duncan

Categories: Welcome
Follow

Get every new post delivered to your Inbox.