Tag Archives: Windows Phone 7

How to add a Custom Ringtone to your Windows Phone 7 Mango phone

We have all wanted to have custom ringtones in Windows Phone 7 since it was first released but now we can! The Windows Phone 7 Mango release offers users to add and quickly get ringtones on their phones.

Example is the Deep Fried Bytes ringtone on our podcast site here. Download the mp3 to the root of your music folder set up for your Zune Software.

image

Next open Zune Software and you should find the mp3 located in your music collection.

image

Right click on the mp3 inside Zune Software  and choose Edit to change the metadata for the mp3. Set the Genre to “Ringtone”

image

Finally press OK and drag the mp3 to your phone inside Zune Software, allow to sync and you should have the file to be an option for your Windows Phone 7 Mango device. Happy Ringtones!!

image

Post-Thanksgiving Florida Mobility/Windows Phone Speaking Tour

Some of the great people in Central Florida asked me to speak on some Mobility, Data and Windows Phone topics the week after Thanksgiving. Seeing that I live in Michigan and the weather after Thanksgiving starts to get cold and we may even get some lake-effect snow I jumped on to speak to the Florida developers. After a week of chatting with the user groups leaders we have the schedule set and I am looking forward to meeting as many greats Florida devs.

I will be updating this blog with more details about each speaking meeting.

Fixing Windows Azure Training Kit with WP7 Mango Dev Tools

I am working on getting ready for a few weeks of Windows Azure training and going through the hands-on labs provided by the training kit. If you have the  Windows Phone Developer Tools 7.1 Beta (Mango) installed you will get an error in the dependency check for the Windows Phone 7 and The Cloud lab Setup Lab (see below):

SNAGHTML694bebe

When the Configuration Wizard is run to determine if all required software is installed, you will get an error when the wizard attempts to find the Windows Phone 7 Emulator.

SNAGHTML69ae023

The solution for this is to confirm that you have the emulator installed and then open the following file:

<Drive>\WAPTK\Labs\WindowsPhone7AndTheCloud\Source\Setup\Dependencies.dep

and edit the dependency check that calls CheckWp7Emulator.ps1 to be not enabled. Save the file and restart the Windows Phone 7 and The Cloud lab Setup Lab.

SNAGHTML6a46440

This will not perform the check for the Windows Phone 7 Emulator and the Config Wizard will complete and install all needed components.

SNAGHTML6a60e16

How to customize the DataServiceContext model generated from an OData feed

After spending some time recently doing performance improvement on my Windows Phone 7 application Baseball History and also updating the Baseball Stats OData feed to include 2010 season data, I wanted to get back and find ways to improve how I develop on WP7. Since I found that using ViewModels for each Entity already generated in the DataServiceContext model was causing the performance issues, I had to find a way to incorporate the calculations I had in the old ViewModels. After looking at the DataServiceContext class, I saw it was a partial class. I then thought that was the best way to extend and add my baseball calculations to the entity model without the fear of getting my code overwritten the next time the DataServiceContext is generated.

The following at the types of calculations I had to perform since my Baseball Stats OData feed does not have these as entity properties:

  • Batting Average
  • Slugging Percentage
  • On Base Percentage
  • Total bases
  • ERA
  • WHIP

You can add your own partial class to live side by side of your generated DataServiceContext file. Here is an example of my partial classes for my WP7 Baseball History app. Very easy but not really a known feature of the generated code from DataSvcUtil.exe.

Code Snippet
  1. using System;
  2. namespace BaseballStats.Model
  3. {
  4.     public partial class Player : global::System.ComponentModel.INotifyPropertyChanged
  5.     {
  6.         public string nameFull
  7.         {
  8.             get
  9.             {
  10.                 return string.Format("{0}, {1}", this._nameLast, this._nameFirst);
  11.             }
  12.         }
  13.     }
  14.  
  15.     public partial class BattingTotals : global::System.ComponentModel.INotifyPropertyChanged
  16.     {
  17.         public int? TB
  18.         {
  19.             get
  20.             {
  21.                 //(Total hits – 2b -3b – HR) + (2b x 2) + (3b x 3) + (HR x 4).
  22.                 int? hits = this._H;
  23.                 int? dbl = this._Dbl;
  24.                 int? tpl = this._Tpl;
  25.                 int? hr = this._HR;
  26.  
  27.                 return (hits – (dbl + tpl + hr)) + (dbl * 2) + (tpl * 3) + (hr * 4);
  28.             }
  29.         }
  30.  
  31.         public double BA
  32.         {
  33.             get
  34.             {
  35.                 double ba = Convert.ToDouble(this._H) / Convert.ToDouble(this._AB);
  36.                 return Math.Round(ba, 3);
  37.             }
  38.         }
  39.  
  40.         public double SLG
  41.         {
  42.             get
  43.             {
  44.                 double slg = Convert.ToDouble(this.TB) / Convert.ToDouble(this._AB);
  45.                 return Math.Round(slg, 3);
  46.             }
  47.         }
  48.  
  49.         public double OBP
  50.         {
  51.             get
  52.             {
  53.                 //157 hits + 75 BB + 5 HBP / 500 AB + 75 BB + 5 HBP + 4 SF
  54.                 double obp = (Convert.ToDouble((this._H) + Convert.ToDouble(this._BB) + Convert.ToDouble(this._HPB)) / Convert.ToDouble((this._AB) + Convert.ToDouble(this._BB) + Convert.ToDouble(this._HPB) + Convert.ToDouble(this._SF)));
  55.                 return Math.Round(obp, 3);
  56.             }
  57.         }
  58.     }
  59.  
  60.     public partial class PitchingTotals : global::System.ComponentModel.INotifyPropertyChanged
  61.     {
  62.         public double? ERA
  63.         {
  64.             get
  65.             {
  66.                 double era = (Convert.ToDouble(this._ER) * 9) / (Convert.ToDouble(this._IPouts) / 3);
  67.                 return Math.Round(era, 2);
  68.             }
  69.         }
  70.  
  71.         public double? WHIP
  72.         {
  73.             get
  74.             {
  75.                 //WHIP = (Walks + Hits) / Innings Pitched (IP)
  76.                 double whip = (Convert.ToDouble(this._BB) + Convert.ToDouble(this._H)) / (Convert.ToDouble(this._IPouts) / 3);
  77.                 return Math.Round(whip, 2);
  78.             }
  79.         }
  80.     }
  81.  
  82.     public partial class Batting : global::System.ComponentModel.INotifyPropertyChanged
  83.     {
  84.         public int? TB
  85.         {
  86.             get
  87.             {
  88.                 //(Total hits – 2b -3b – HR) + (2b x 2) + (3b x 3) + (HR x 4).
  89.                 short? hits = this._H;
  90.                 short? dbl = this._Dbl;
  91.                 short? tpl = this._Tpl;
  92.                 short? hr = this._HR;
  93.  
  94.                 return (hits – (dbl + tpl + hr)) + (dbl * 2) + (tpl * 3) + (hr * 4);
  95.             }
  96.         }
  97.  
  98.         public double BA
  99.         {
  100.             get
  101.             {
  102.                 double ba = Convert.ToDouble(this._H) / Convert.ToDouble(this._AB);
  103.                 return Math.Round(ba, 3);
  104.             }
  105.         }
  106.  
  107.         public double SLG
  108.         {
  109.             get
  110.             {
  111.                 double slg = Convert.ToDouble(this.TB) / Convert.ToDouble(this._AB);
  112.                 return Math.Round(slg, 3);
  113.             }
  114.         }
  115.  
  116.         public double OBP
  117.         {
  118.             get
  119.             {
  120.                 //157 hits + 75 BB + 5 HBP / 500 AB + 75 BB + 5 HBP + 4 SF
  121.                 double obp = Convert.ToDouble((this._H) + Convert.ToDouble(this._BB) + Convert.ToDouble(this._HBP)) / Convert.ToDouble((this._AB) + Convert.ToDouble(this._BB) + Convert.ToDouble(this._HBP) + Convert.ToDouble(this._SF));
  122.                 return Math.Round(obp, 3);
  123.             }
  124.         }
  125.     }
  126.  
  127.     public partial class Pitching : global::System.ComponentModel.INotifyPropertyChanged
  128.     {
  129.         public double? WHIP
  130.         {
  131.             get
  132.             {
  133.                 //WHIP = (Walks + Hits) / Innings Pitched (IP)
  134.                 double whip = (Convert.ToDouble(this._BB) + Convert.ToDouble(this._H)) / (Convert.ToDouble(this._IPouts) / 3);
  135.                 return Math.Round(whip, 2);
  136.             }
  137.         }
  138.     }
  139.  
  140.     public partial class Team : global::System.ComponentModel.INotifyPropertyChanged
  141.     {
  142.         public int? TB
  143.         {
  144.             get
  145.             {
  146.                 //(Total hits – 2b -3b – HR) + (2b x 2) + (3b x 3) + (HR x 4).
  147.                 short? hits = this._H;
  148.                 short? dbl = this._Dbl;
  149.                 short? tpl = this._Tpl;
  150.                 short? hr = this._HR;
  151.  
  152.                 return (hits – (dbl + tpl + hr)) + (dbl * 2) + (tpl * 3) + (hr * 4);
  153.             }
  154.         }
  155.  
  156.         public double BA
  157.         {
  158.             get
  159.             {
  160.                 double ba = Convert.ToDouble(this._H) / Convert.ToDouble(this._AB);
  161.                 return Math.Round(ba, 3);
  162.             }
  163.         }
  164.  
  165.         public double SLG
  166.         {
  167.             get
  168.             {
  169.                 double slg = Convert.ToDouble(this.TB) / Convert.ToDouble(this._AB);
  170.                 return Math.Round(slg, 3);
  171.             }
  172.         }
  173.  
  174.         public double OBP
  175.         {
  176.             get
  177.             {
  178.                 //157 hits + 75 BB + 5 HBP / 500 AB + 75 BB + 5 HBP + 4 SF
  179.                 double obp = (Convert.ToDouble((this._H) + Convert.ToDouble(this._BB) + Convert.ToDouble(this._HBP)) / Convert.ToDouble((this._AB) + Convert.ToDouble(this._BB) + Convert.ToDouble(this._HBP) + Convert.ToDouble(this._SF)));
  180.                 return Math.Round(obp, 3);
  181.             }
  182.         }
  183.  
  184.         public double? WHIP
  185.         {
  186.             get
  187.             {
  188.                 //WHIP = (Walks + Hits) / Innings Pitched (IP)
  189.                 double whip = (Convert.ToDouble(this._BB) + Convert.ToDouble(this._H)) / (Convert.ToDouble(this._IPouts) / 3);
  190.                 return Math.Round(whip, 2);
  191.             }
  192.         }
  193.     }
  194. }

Examining OData – Windows Phone 7 Development — How to create your URI’s easily with LINQPad

Today the WCF Data Services team released a new update for the OData Client Library for Windows 7 (get a copy of the source here). There are some things that changed. Most notably, the ability to LINQ on the DataServiceContext created with the new version of the code generation tool. This new tool (get source here) creates a set of classes that allow developers to work with the OData feeds.

Now that LINQ’ing is not available what do we do? We will have to work with URI’s for our queries. This is not difficult but is not as easy as writing LINQ statements with Intellisense. One possible solution to to take your LINQ statements that you created for your Windows Phone 7 project and run them through LINQPad to get the URI that is the equivalent. LINQPad is a great learning tool for LINQ and also will give you some added information about your queries as we will see in this post.

Here is a screenshot using the Baseball Stats OData Feed. You can the LINQ statement to get the current active list baseball franchises from the feed.

image

Now you can run the LINQ query and get the results

image

The secret to getting the corresponding URI for the LINQ query is to then select the SQL on the Result toolbar

image

You will then see the URI equivalent for the LINQ statement you wrote above in the Query section.

image

Now you can take that URI and use it when working with the OData Client Library for Windows Phone 7.

Powered by WordPress | Designed by: Email Search