Friday, December 31, 2010

Windows Phone Connect Tool without Zune from Visual Studio

You need Zune to connect from Visual Studio 2010 to Windows Phone 7 Device to deploy applications from Visual Studio. This connection mode does not let you allow to debug with Media Library.

You can connect to Windows Phone 7 from Visual Studio 2010 using the Windows Phone 7 Connect Tool.

The following link from  Sebastian Sch├╝tze’s blog is   helpful:

Debug with Windows Phone without using Zune

Get the following tool

Windows Phone Developer Tools October 2010 Update.

Use the following link to use the Connect Tool

How to: Use the Windows Phone Connect Tool

I have given  below excerpts from this web site

To use the Windows Phone Connect Tool
  1. Open a command prompt and navigate to the directory containing the Windows Phone Connect Tool (WPConnect.exe). The location of this file will be %ProgramFiles%\Microsoft SDKs\Windows Phone\v7.0\Tools\WPConnect for 32-bit installations. For 64-bit installations it will be located at %ProgramFiles (x86)%\Microsoft SDKs\Windows Phone\v7.0\Tools\WPConnect.

  2. Connect your Windows Phone to your computer and ensure that it is detected by the Zune software.

  3. Close the Zune software after your Windows Phone is connected.

  4. At the command prompt, enter the command WPConnect.exe.

    NoteNote:

    You will receive confirmation that your device is now connected. Also, you do not need to disconnect from this tool. At any time, you can re-establish connectivity with the Zune software by launching the Zune software. However, after reestablishing connectivity with the Zune software, you must repeat the preceding steps if you want to debug an application with media APIs.

You should now be able to debug your application without the Zune software running.

Saturday, December 18, 2010

Windows Phone 7 XNA Assets

Some times, I start with the examples given by Microsoft or other bloggers and modify them to my requirements. This works fine. The trouble starts when you want to combine some of the snippets from one of these projects with new projects. You start running into configuration problems.

I got the errors in model loading in XNA and images. One of the errors is given below.

I got this error Cannot find type Microsoft.Xna.Framework.Content.Pipeline.Graphics.NodeContent when I tried to run a Windows XNA project with models.

I also had errors about not finding images.

I had to  move all the models and images to content. In addition I had to make sure in the properties of the model, we have the following:

  1. Build Action Compile
  2. Content Importer X File – XNA framework
  3. Content Processor – Model-XNA framework

For images

I have the following for both Content Importer and Content Processor Texture- XNA Framework

Friday, December 17, 2010

XNA 3d translation, rotation and scaling, Windows Phone 7

I had a several cubes in a Windows Phone 7 XNA application. I wanted to animate the cubes by rotating them on their axis. Let us say the cube is at Vector3 (-offsetx, –offsety,0f) position.

I used the following code to spin it on its own axis it   worked fine. 

 rotAxis = new Vector3(-offsetx, -offsety, 0f);
rotAxis.Normalize();
worldlist[iworld] = Matrix.CreateFromAxisAngle(rotAxis, angle) * rectangleTransform;



The rectangle transform brought it to where I wanted it. However I ran into problems when I wanted to spin it any other axis using rotaxis for example



 rotAxis = new Vector3(1.0f, 0f, 0f);


Then I saw this nice article   Rotations and translations  by Riemer. By the way if you want to do something in XNA you have to read the great tutorials in this site. His XNA book is also great.



So I did the following code where I translated the cube to move it  to center. Then I can spin the cube  on any axis!



 rotAxis = new Vector3(1.0f, 0f, 0f);
rotAxis.Normalize();
worldlist[Selectcount] = Matrix.CreateTranslation(new Vector3(-offsetx, -offsety, 0f ))
*Matrix.CreateFromAxisAngle(rotAxis, angle)*rectangleTransform ;

Wednesday, December 15, 2010

Create Games for Windows Phone 7, Recipes

Went to user group meeting on Windows phone 7 in Mountain View. Kenny Spade, Microsoft Evangelist showed us an excellent Microsoft site.

This is more like a Windows Phone 7 code samples or recipes site. Excellent and very useful. This will save you weeks of research of your own in any topic. All of this is under Microsoft

Go to Create Games for Windows Phone 7

Click on the Education/ Education Catalog 

which takes you to

Education Catalog

All of this under

Microsoft Permissive License (Ms-PL) 

Enjoy!!!

Windows Phone 7 XImporters, TextureImporters error

I wanted to run some of my old XNA projects which gave me a cryptic error message XImporters or TextureImporters missing. When I looked in my references these assemblies where there and properly referenced.

Then I came across this blog Assembly references in XNA Game Studio 4.0 beta projects need to be updated after installing the final release by Aaron Stebner.

As per Aaron’s recommendation I removed all references to the Microsoft.Xna.Framework.Content.Pipeline assemblies and added them again. It worked.

The assemblies are in the following folder: C:\Program Files\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\

The offending assemblies in my project were:

Microsoft.Xna.Framework.Content.Pipeline.AudioImporters
Microsoft.Xna.Framework.Content.Pipeline.EffectImporters
Microsoft.Xna.Framework.Content.Pipeline.FBXImporters
Microsoft.Xna.Framework.Content.Pipeline.TextureImporters
Microsoft.Xna.Framework.Content.Pipeline.VideoImporters
Microsoft.Xna.Framework.Content.Pipeline.XImporters

a

Monday, December 13, 2010

Screen Capture in Windows 7 for demos

I often have to do screen capture for demos. There are 3 different ways you can capture screen images in Windows 7. Two of them come with Windows 7. Third  one needs Microsoft Expression Encoder which is not free.

  1. Using traditional PrintScreen method. Either you can use PrintScreen button which will capture the entire screen or use ALT PrintScreen to capture the active window. Then you have to copy it to a program like Paint. Take a screen capture (print screen)
  2. Using the Snip tool. This is a cool feature. Type snip in the Start programs. You can use the snip in 3 different modes. I use the rectangular mode to capture portion of a screen, for example Windows Phone 7 emulator screens. It automatically produces a JPEG image which you can save. Use Snipping Tool to capture screen shots
  3. Expression Encoder. This is a powerful tool which you can use not only for capturing static images, but also videos of actual demos.Expression Studio

Tuesday, December 7, 2010

RSS feed XML source how to read

I was working with RSS and wanted to look at the source of the feed. Now all browsers have some sort of feed reader so it takes some effort. I normally use Opera to read xml documents. But to read RSS I has to use Internet explorer.

I followed the directions given in the article below.

IE 7 XML Feed Display & RSS Feed Validation

1) Click on the Tools menu,
2) Click on the Internet Options sub-menu,
3) Click on the Content tab,
4) Click on the Settings button of Feed section to bring up Feed Settings dialog box,
5) Un-tick the check-box of Turn On Feed Reading View option.
6) Click OK all the way to close all opened dialog boxes.

Another interesting article.

How To View RSS Feed In XML Format With Firefox

Saturday, December 4, 2010

Update to How to add items to Windows Phone 7 ListPicker

I had this clarified by Delay

ListPicker? I hardly even know 'er! [A detailed overview of the Windows Phone Toolkit's ListPicker control]

Delay clarified

ObservableCollection (via ItemsSource) is definitely the most flexible option for ItemsControl subclasses like ListPicker. However, your first example using Items.Add should work, as well. You don't say what about that didn't work for you, but one thing to remember with all ItemsControl subclasses is that you can't mix Items and ItemsSource - you need to pick one method of providing the items and then use that exclusively or else an exception results.

My reply

Delay,
I got it working.
You are right.
I was making the mistake of mixing up items and ItemSource.
Both the following  scenarios work:
1. When I have a list and add items to the listpicker using foreach.
2. Bind list directly to listpicker  .
I think I was getting into trouble when I mixed up both.
Thanks.
Vijay

JQuery Mobile How to add items and get selected items from menu

The following example is given in JQuery Mobile documentation.

<div data-role="fieldcontain">
<label for="select-choice-1" class="select">Choose shipping method:</label>
<select name="select-choice-1" id="select-choice-1">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
<option value="overnight">Overnight</option>
</select>
</div>


I wanted to do this dynamically by code. and my solution is given below



the array



var shippingarray = [
{ name: "Standard: 7 day", id: "Standard" },
{ name: "Rush: 3 days", id: "Rush" },
{ name: "Express: next day", id: "Express" },
{ name: "Overnight", id: "Overnight" },
{ name: "slow boat", id: "slow" }
]



Loading the menu



function Load_select_shipping() {

var arraytoload = shippingarray;
var optionlist = '';
var i = 0;
// <option value="volvo">Volvo</option>

$.each(arraytoload, function (index,item) {
if (i == 0) {
optionlist += '<option selected="' + item.id + '">' + item.name + '</option>';
}
else {
optionlist += '<option value="' + item.id + '">' + item.name + '</option>';
}
i++;
})
optionlist += '';
$("#select-choice-1").html(optionlist).selectmenu('refresh', true);

// $("#select-choice-1").html(shippingarray2).selectmenu('refresh', true);
}


to get the selected item



function Get_Data() {

$('#content_data_list').empty();
var index = $("#select-choice-1")[0].selectedIndex;

var selected_item = shippingarray[index].id;

shippingselected = "val: " + $("#select-choice-1").val() + " index: " + selected_item;
var listitem = '<li > ' + shippingselected + '</li>';
$('#content_data_list').append(listitem);
$('#content_data_list').listview('refresh');

}



Note the refresh. This has to be done for updating any lists to which add items!



Had interesting posts in JQuery Mobile given below:



Add items and refresh



How to get selected item



Add link buttons and refresh



JQuery Mobile Goto

How to add items to Windows Phone 7 ListPicker

I figured  out how to add list items from code behind. For some one who might have a similar problem, my solution is given below.
I created an observable collection

Code behind

int startyear 2000;
int endyear 2010;
ObservableCollection<string> yearlist = new ObservableCollection<string>();
for (int i = endyear; i >= startyear; i--)
{
yearlist.Add(i.ToString());
}
YearListPicker.ItemsSource = yearlist;



XAML



<toolkit:ListPicker  Margin="4,4,4,4" 
x:Name="YearListPicker" Header="Year" >
</toolkit:ListPicker>



Interesting article on ListPicker



http://blogs.msdn.com/b/delay/archive/2010/11/03/listpicker-i-hardly-even-know-er-a-detailed-overview-of-the-windows-phone-toolkit-s-listpicker-control.aspx