... all I'm offering is the truth. Nothing more. RSS 2.0
# Wednesday, August 25, 2010

I have basically completed my first app for Windows Phone 7, I am poised to register it on the Marketplace. I am still gathering information about Windows Phone 7 as this is a new platform so there are still bits of critical information that are making its way into the developer community. I thought I would dedicate this post to the stream of information I have found over the last few weeks.

I also caught this video on Channel 9, and I started to feel a little guilty that I have never paid much attention to UI design or even UX over my career (I have left behind some cringe worth apps). I am really trying to assimilate the whole Metro theme (replicated in Xbox, Media Center, Zune and Media Room) and ensure my apps are balanced with the overall design concept. Happy design and coding!

Get Microsoft Silverlight

Wednesday, August 25, 2010 9:01:16 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [2] - Trackback
Phones | Silverlight
# Saturday, August 21, 2010

This post is really just a design addendum to my previous post, an opportunity to revisit and redress the solution I presented for the problem of converting GPS data directly into US based Zip Code and while technically correct, I really did spend much time discussing or considering the the nature and architecture of the Windows Phone. In fact part of my solution would lead directly to poor phone performance, and so I wanted to take a couple of moments and discuss one of the fundamental differences in the approach of using and consuming services for WP7.

Lets consider the archetypal example where a button calls a service and that service returns some simple result. There are several ways to accomplish this using the WP7, however, you are guided toward a “pit of success” by being subtlety pushed toward the event driven model. In the traditional service call model you make a call and literally wait for the service to return some kind of result.

Waiting for the service to return the result with a potentially unreliable internet connection could lead to long wait times which in turn could produce a very inconsistent and unresponsive UI experience. Also note that this version of WP is a single threaded environment (it may change in the future) so we cannot offload this work to some background thread. What we can do is some simple event driven programming (you remember “call backs” from back in the day single proc PC days, same concept) which would look like this:

private void StartLocationButton_Click(object sender, RoutedEventArgs e)
{
  // The watcher variable was previously declared as type GeoCoordinateWatcher. 
  if (watcher == null)
  {
    watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); // Use high accuracy.
    watcher.MovementThreshold = 20; // Plus or Minus 20m, helps ignore noise in the signal.
    watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); //Define delegate
  }
  watcher.Start();
}
void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
{
  Dispatcher.BeginInvoke(() => MyStatusChanged(e)); //Call BeginInvoke as discussed below…
}
void MyStatusChanged(GeoPositionStatusChangedEventArgs e)
{
  if (e.Status == GeoPositionStatus.Ready)
      // Use the Position property of the GeoCoordinateWatcher object to get the current location.
      GeoCoordinate co = watcher.Position.Location;
      LatitudeTextBlock.Text = e.Position.Location.Latitude.ToString("0.000");
      LongitudeTextBlock.Text = e.Position.Location.Longitude.ToString("0.000");
      //Stop the Location Service to conserve battery power.
      watcher.Stop();
  }
}

For those of us coming from the Web world there is a subtle “hoop” that is easily forgotten that is critical to Windows GUI programming i.e. only the thread that created a control can subsequently access and/or modify its contents (there are a couple of exceptions). Any attempts to update controls from other threads will result in unpredictable behavior and downright weird UI results. Whenever you need to update a control from a thread that did not initially create it, you need to wrap the call within a BeginInvoke call as show above (see Line 14).

 

Related Posts:

Saturday, August 21, 2010 12:26:11 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
C# | Phones
# Wednesday, August 18, 2010

I am currently working on a Windows Phone 7 (WP7) app and I essentially needed to get two pieces of information for the idea to get off the ground. First I need a way to get the the current GPS coordinates from the phone and secondarily I needed to be able to translate that GPS coordinate into a zip code.

As of this writing there are very few physical WP7 devices available to test with, and while Microsoft have done a great job in sending these phones to the press and the big players in the smart phone industry that does not help people like me. I am aware that the Visual Studio Express tool contains a good Emulator, however, it does not provide you access to the GPS backbone, as a result I will wait to offer suggestions on the code.

Get Zip Code (Postal Code) information from the longitude and latitude

Once we have the GPS data from the phone we can pull the zip code information from GPS (reverse geocode) using the Bing Maps API, specifically the Geocode Service. In order to access this service you will need to sign up at the Bing Maps Account Center (requires a Live ID), and subsequently get a Bing Maps key for authentication (review the terms of use carefully).

private void MakeReverseGeocodeRequest(double latitude, double longitude)
{
	string Results = "";
	try
	{

		// Set up you Bing Maps key here...
	        string key = "....."; 

                GeocodeService.ReverseGeocodeRequest reverseGeocodeRequest = new GeocodeService.ReverseGeocodeRequest();
                reverseGeocodeRequest.Credentials = new GeocodeService.Credentials();
                reverseGeocodeRequest.Credentials.ApplicationId = key; //apply the key

                // Set the long and lat
                GeocodeService.Location point = new GeocodeService.Location();
       	        point.Latitude = latitude;
                point.Longitude = longitude;

                reverseGeocodeRequest.Location = point;

                // Make the reverse geocode request
                GeocodeService.GeocodeServiceClient geocodeService =
                	new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
                GeocodeService.GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest);
	                
		//Postal Code is one of the properties of the Address
		Results = geocodeResponse.Results[0].Address.PostalCode;
	}
      	catch (Exception ex)
	{
		Results = "An exception occurred: " + ex.Message;
	}
}

UPDATE: This is not the code I would use in a Windows Phone environment, I would probably perform some form of callback. My next post will explain further.

Wednesday, August 18, 2010 10:46:56 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
C#
# Sunday, August 01, 2010

HGPasswordOne of the most useful and user friendly features of Windows 7 is the HomeGroup feature. HomeGroup takes the burden out of sharing files and printers on a home network. You have the ability to quickly and easily connect two or more PCs running Windows 7, while automatically sharing your music, picture, video, and document libraries with other people in your home.

I have had my wife’s notebook connected via HomeGroup to our main PC for a while, so when I finally got my notebook I was hoping to be able to do the same thing. Unfortunately when I tried to connect to the HomeGroup with the supplied password it failed, I immediately assumed that the password was incorrect and went to the main PC to change the HomeGroup password and it resulted in the error “Windows cannot set up a homegroup on this computer”.

After digging around I noticed that Event Viewer had been throwing an error for a while related to the Peer Name resolution, specifically: “The Peer Name Resolution Protocol cloud did not start because the creation of the default identity failed with error code: 0x30630801”.

After reviewing the services “Peer Networking Group” was stopped which itself is a service that … “Enables multi-party communication using Peer-to-Peer Grouping.  If disabled, some applications, such as HomeGroup, may not function.” Aha!


Unfortunately any attempts to start this service resulted in another error message “Windows could not start the Peer Name Resolution Protocol service Local Computer. Error 0x80630801: 0x8063080”… aaaaaaahhhhhhhh!

My Solution:

  1. First ensure that you have “Show hidden files, folders and drives” folder option enabled.
  2. Open the following folder as an administrator: “C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\PeerNetworking”.
  3. Delete all the contents and restart your PC.
  4. Delete the existing HomeGroup (if you have one).
  5. You should be able to successfully create a new HomeGroup!

Please note, there is no implied warranty for on any solution I provide on this blog … ever. This worked for me on my PC, and I could not find an official solution. If you try this and your PC starts doing crazy things I will not be held responsible in any way shape or form and I am not likely to spend too much time offering help or resolution outside the general comments I provide on this blog.

Sunday, August 01, 2010 10:11:44 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
Windows
# Tuesday, July 27, 2010

Just a quick list of things to do and places to visit within 50 miles of Ohio’s state capital:

  1. Columbus Zoo & Aquarium – Currently ranked the best zoo in the nation, they have recently added a great water park.
  2. Arena District – Sports, Dining and Entertainment.
  3. Alum Creek – Trails, Boating, and Camping.
  4. Franklin Park Conservatory & Botanical Garden – A premier institution showcasing an exotic plant collection and a signature collection of work by glass artist D Chihuly.
  5. The Thurman Café – *The* burger joint as seen on Food Networks Man verses Food.
  6. Hocking Hills – The most popular of all the Hocking areas is Old Man's Cave, located on State Route 664.
  7. Easton Town Center – If you want to shop this is the place for you!
  8. Short North Arts District - The Gallery Hop is the first Saturday of EVERY month. It is a hub for creativity.
  9. Book Loft of German Village – Is a city-block long store, located at 631 South Third Street, less than one mile south of Ohio's Capitol in the center of Columbus.
  10. OSU Stadium “The Horse Shoe” – If you love Football and can get tickets then being in stadium with 100,000 rabid OSU fans would be a thrill!
Tuesday, July 27, 2010 10:44:17 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [1] - Trackback
Places to go
# Tuesday, July 20, 2010
mse2

I am the on call PC expert for my entire family and most of my friends, this works for me most times but dealing with every single version and permutation of all those virus software products leads to an additional layer of discovery which has the unfortunate effect of wasting my time. So once the 6 month trials are up I quickly try to intercept my families attempts to go Best Buy and purchase software and gently nudge them onto a single virus protection source, namely Microsoft Security Essentials (MSE).

I switched to MSE less than a year ago, and that time I was a huge fan of AVG Free, however, I noticed that AVG would make it increasingly difficult to find free version of the software and the pop ups telling you about subsequent updates never pointed to the free version, I grew tired of that constant struggle. Additionally, in terms of performance, my anecdotal assessment of MSE is that it has less of a memory footprint while actually “idol” and also while running “Quick” and “Full” scans.

Today Microsoft announced the beta for the next version of Microsoft Security Essentials. New features in the beta include:

  • Windows Firewall integration – During setup, Microsoft Security Essentials will now ask if you would like to turn the Windows Firewall on or off.
  • Enhanced protection for web-based threats – Microsoft Security Essentials now integrates with Internet Explorer to provide protection against web-based threats.
  • New protection engine – The updated anti-malware engine offers enhanced detection and cleanup capabilities with better performance.
  • Network inspection system – Protection against network-based exploits is now built in to Microsoft Security Essentials.

I probably will not push everyone to the new beta yet, but I will try it out on a couple of PCs and see how it goes. You can download the beta here (you will need a Windows Live ID).



Related Posts:

Tuesday, July 20, 2010 11:37:47 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
Security | Windows
Blogroll
Statistics
Total Posts: 334
This Year: 22
This Month: 0
This Week: 0
Comments: 32
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Mark Downie
Sign In
All Content © 2010, Mark Downie
DasBlog theme 'Business' created by Christoph De Baene (delarou)