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

Friday, November 26, 2010

Observable collections and photo slide show in Silverlight

Recently I did a  nice photo collection slide show in Silverlight. It is really simple. Use observable collection.

I had a list of thumbnail URLs in a list generated from a web service. The image list had 10 image urls in it.

I created a second list with 3 image urls as an observable collection in the class declaration.

public ObservableCollection<String>  Thumb_list { get; set; }

Then I had XAML for holding 3 images and had a left and right arrow buttons on both sides of the images.

When they were clicked the observable collections image list was again populated with new images offset by one from the original image list. The code is given below.  Of course, you have to make sure that you are not over running the indexes.

  private void Click_Left_Arrow(object sender, RoutedEventArgs e)
{
var thumblistdetails = ((Button)sender).DataContext as client_data;
if (thumblistdetails.image_index > 0)
{
thumblistdetails. Thumb_list[0] = List_silver_data[thumblistdetails.row_index].Thumb_list[thumblistdetails.image_index - 1];
thumblistdetails. Thumb_list[1] = List _silver_data[thumblistdetails.row_index].Thumb_list[thumblistdetails.image_index];
thumblistdetails Thumb_list[2] = List_silver_data[thumblistdetails.row_index]. Thumb_list[thumblistdetails.image_index + 1];
thumblistdetails.image_index--;
}
}



This was a cool application. Shortly I will write a code project article on this.

Saturday, November 20, 2010

JQuery Mobile, JQTouch and CSS: This is not your father’s HTML or CSS!

Like what they would say, this is not your father’s HTML. Things have advanced a lot in HTML and CSS. I am now designing for the mobile phones, concentrating on Windows Phone 7. At the same time I am fascinated with HTML 5 which is available in both Android and Iphone. I am not happy that Microsoft has not provided HTML 5 in Windows Phone 7. I like Silverlight, but you can also do cool things with HTML 5 and CSS.
Button design is also lot of fun with CSS, Icons and HTML! If you want to design seriously for mobile phones you should definitely  look at these sites.

  1. iPhone Book Excellent book by Jonathan Stark on mobile telephone design and development.
  2. JQTouch A plug in for JQuery which works fine for Iphone. Unfortunately Windows Phone 7 ignores most of it because it is still based on IE 7.
  3. JQueryMobile Excellent work, very good again for Iphone and Android but does not render in Windows Phone 7.
  4. Rediscovering the button element Excellent Article by Kevin Hale which is a very good introduction to merging icons with text on buttons.
  5. jQuery Image Strip Very good article about simple tricks in Javascript to create nice results
  6. CSS Image Techniques: Part 1 Excellent series of articles by GuiStuff
  7. Scalable CSS buttons using PNG and background colors
  8. 3d css buttons
  9. 30 Excellent CSS Based Navigation and Buttons Tutorial
  10. Button Collection
  11. icons for mobile apps
  12. Display icons using a single image and CSS “Sprites”
  13. Create superior web buttons and menus in a few clicks! very good software mainly to create prototypes quickly.
  14. Glueit Excellent software to create icon strips
  15. What Are CSS Sprites?
  16. Playing with CSS3 gradients
  17. Playing with CSS3 gradients
  18. Updated: Windows Phone 7 IE Mobile gets webkit-compatible update
     

Sivlerlight Animation

I am looking at Silverlight animation to make interesting user interface designs. Came across a few interesting applications which might be of use to you to.

  1. Fluid Dynamics in Silverlight Excellent animation by Rick Barrazza. You can play with the animation in the article itself.
  2. Silverlight Controls with Effects and Transitions by Nikhile
  3. Effects and Transitions for Silverlight is an excellent article by Nikhil.    samples are in this page http://projects.nikhilk.net/SilverlightFX
  4. Excellent flipping tiles animation by Joel http://joel.neubeck.net/2008/05/silverlight-flipping-tiles-animation/
  5. photogallerywall
  6. How to dispaly HTML/rich text in Silverlight
  7. Silverlight Panorama Viewer but no source code!
  8. Polyhedra Excellent mathematical/ geometry animation by Declan.
  9.  Album Nice album, but in French and the site is slow!
  10. Scroll Viewer List box
  11. Adorners good animation
  12.  Image space 3d Images are organized in a 3D space. Not 3d library is used. It doesn't use Perspective 3D which means it can perform very well.
  13. Image slider control in Silverlight 2 good explanation of the animation.
  14. Silverlight 2 Rolemenu inspired by Microsoft Italy

Parsing Json using C# dynamic

I had an application where I had to get data from  a web service. Get some name data from that service and then get relevant images from another web service. I was wondering how to do that because my application is MVC2 with Javascript and JQuery.
My first approach was to try to get the results  from first web service in the view page,  manipulate the result with JQuery, extract the information and then make the second web service call. However, I thought it was clumsy.
Then I came across JavascriptSerializer. But it required that I declare a complete class for the Javascript object which I was reluctant to do. Then I looked at Json.NET. Elegant solution but I thought was an overkill for what I wanted to do.
Then I came across C# 4.0, Dynamic Programming and JSON  by Nikhil which is also great, but again for my application was an overkill.
Finally I hit pay dirt when I saw this great article  Using C# 4.0 and dynamic to parse JSON by Shawn which is wonderful. Excellent piece of code to extract what I wanted. Almost like working with Javascript in C#. I had to do the minor  bug correction by Drew mentioned in serialize JSON into C# dynamic object?.
I used the code and I was able to scan through the objects like I would do in Javascript notation.
Excellent tool to have in your arsenal when you want to work with web services which returen JSON in MVC.

Monday, October 4, 2010

Azure error SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used

When you start Visual studio azure project using development storage if you get the following error

SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used

go to webrole.cs and modify OnStart code to

public override bool OnStart()
{
DiagnosticMonitor.Start("DiagnosticsConnectionString");

// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
// RoleEnvironment.Changing += RoleEnvironmentChanging;
#region Setup CloudStorageAccount Configuration Setting Publisher

// This code sets up a handler to update CloudStorageAccount instances when their corresponding
// configuration settings change in the service configuration file.
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
{
// Provide the configSetter with the initial value
configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));

RoleEnvironment.Changed += (sender, arg) =>
{
if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
.Any((change) => (change.ConfigurationSettingName == configName)))
{
// The corresponding configuration setting has changed, propagate the value
if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
{
// In this case, the change to the storage account credentials in the
// service configuration is significant enough that the role needs to be
// recycled in order to use the latest settings. (for example, the
// endpoint has changed)
RoleEnvironment.RequestRecycle();
}
}
};
});
#endregion

return base.OnStart();
}

This should work!

Saturday, October 2, 2010

Azure Linq Queries

Interesting links for Linq queries

  1. http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx
  2. http://msdn.microsoft.com/en-us/library/bb397676.aspx
  3. http://convective.wordpress.com/2010/02/06/queries-in-azure-tables/
  4. http://msdn.microsoft.com/en-us/library/dd894039.aspx

For some reason Linq queries with directly selecting the required entity using select new { test1, test2} does not seem to work.

Using Linq to select all entities and then use another linq query to filter data does not work.

Using Linq to select all entities and then use foreach to filter the entities required seem to work

Azure Development storage loses all properties

Interesting problem with Azure storage which loses all properties.

couple of interesting fixes for this.

http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/020d9146-f374-453a-bc1b-f656306b766c

http://devstoragesync.codeplex.com/

used insert dummy row to fix this.

Convert XML files to class files in Visual studio

xsd.exe gtest1.xsd  /cThese are the steps to convert xml files to class files in Visual Studio.

  1. Open the XML file in Visual Studio.
  2. Create Schema in the XML option.
  3. Run the Visual Studio command prompt from programs.
  4. Cd to the relevant file:
    1. cd C:\test1\test2\\xml_files
  5. To convert file
    1. xsd.exe test1.xsd  /c
  6. to convert multiple files
    1. xsd.exe test1.xsd test2.xsd  /c
  7. when converted individually lot of duplicate names had to be commented out.
  8. Easier approach use the XSD files create constructor for each item.

Tuesday, September 28, 2010

Links to various US recreation sites

  1. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllActivities
  2. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllElements
  3. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllFacilities
  4. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllFacilityActivities
  5. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllFacilityAddresses
  6. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllFacilityElementsForOrgID
  7. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllFacilityEvents
  8. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllOrganizations
  9. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllOrgFacilities
  10. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllOrgRecAreas
  11. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllRecAreaActivities
  12. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllRecAreaAddresses
  13. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllRecAreaAdvisories
  14. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllRecAreaElementsForOrgID
  15. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllRecAreaEvents
  16. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllRecAreaFacilities
  17. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllRecAreas
  18. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllRecAreasForOrgID
  19. http://recdata.gov/RIDBWebService/RIDBService.jws/getAllRecElementsForOrgID
  20. http://recdata.gov/RIDBWebService/RIDBService.jws/getRecGovFacilities

Friday, July 23, 2010

Winphone XNA deployment in Toshiba Satellite L305-S5944

Finally I think that I have the XNA game studio working in my Toshiba laptop. It did not have the 10.1 directx capability. Hence I did the following:

  1. Downloaded Intel® Graphics Driver for Windows 7* and Windows Vista* (exe) from Intel site. Ran it with lot of trepidation because I was worried the screen is going to become blank! It failed. Ran it again! It updated the driver.
  2. Compiled a Windows Phone application and it failed.
  3. Ran dxdiag which showed that I had 10.1 installed.
  4. Downloaded and installed DXSDK_June10.exe. This is not required, but I did it to get the DirectX Caps Viewer Tool mentioned in the Release notes.
  5. Ran the C:\Program Files\Microsoft DirectX SDK (June 2010)\Utilities\bin\x86\DXCapsViewer.exe and checked the results. It looked OK. I expanded the Direct3D 10.1 folder and saw entries for  D3D10_FEATURE_LEVEL_10_0 or D3D10_FEATURE_LEVEL_10_1. Direct3D_11 folder also had similar entries for D3D_FEATURE_LEVEL_10_0.
  6. Tried to install the following and it said not applicable to my system!
    1. Update for Windows Vista (KB971512)
    2. Update for Windows Vista (KB971513)
    3. Update for Windows Vista (KB971514)
    4. Update for Windows Vista (KB960362)
  7. Tried to deploy the Winphone application. Same error.
  8. Became bold and adventurous!  followed this instruction:
    1. It is possible to bypass this capabilities check in XNA Game Studio by setting the following registry setting: HKEY_LOCAL_MACHINE\Software\Microsoft\XDE XNAEnableGPU = 1 (REG_DWORD)Caution: If you override this registry key, the project will attempt to deploy but only a black screen will be displayed in the emulator if the required graphics card capabilities are not available.
  9. Voila! I was able to deploy. This is an empty application. Will check with the Hello world and update this post again!
  10. Update: Unfortunately this does not work. Posted in the Windows Phone forum.WDDM 1.1 driver, The current display adapter does not meet the emulator requirements to run XNA
  11. Will be updating laptop to windows 7. Let us see whether this solves the problem!
  12. Windows 7 resolved it!

Wednesday, July 21, 2010

MVC Widgets, RenderAction, partial views, sub controllers and RenderPartialRequests part 2

This has become a long post, so I am continuing with the links

  1. ASP.NET MVC Preview 4: ComponentController Is Now RenderAction by Rob Conery
  2. ASP.NET MVC Namespaces in Web.config instead of Views - ASP.NET MVC Best Practices  by David Hayden
  3. Quick Tips About ASP.NET MVC – WebPart Framework by Nunos
  4. Developing Web 2.0 Portal Using Asp.Net MVC, Microsoft Ajax Client Templates And JQuery With Drag And Drop Widget Personalization – Part 1 by Lakkakula
  5. Renderpartial conditionally on masterpage in asp.net mvc in Stack Overflow
  6. RenderPartial vs RenderAction by Derik Whittaker
  7. Dynamic Views in ASP.NET MVC 2 by Greg Shakles
  8. ASP.NET MVC 2.0 Using Multiple Actions by Brian Mains
  9. Web 2.0 AJAX Portal using jQuery, ASP.NET 3.5, Silverlight, Linq to SQL, WF and Unity by Omar Al Zabir
  10. Dropthings

MVC Widgets, RenderAction, partial views, sub controllers and RenderPartialRequests – Part 1

Have been spending some time on MVC. It is a fascinating technology with very little documentation! Did lot of web search to find the following interesting topics:

  1. Partial Requests in ASP.NET MVC by Steve Sanderson
  2. Html.RenderAction and Html.Action by Phil Haack
  3. ASP.NET MVC Tip #50 – Create View Models by Stephen Walther
  4. ASP.NET MVC Partial Views and Strongly Typed Custom ViewModels by Mike Brind
  5. ASP.NET MVC and the templated partial view (death to ASCX)  by Jeffery Palermo
  6. Web Parts in ASP.NET 2.0 by Damon Armstrong
  7. SubControllers in ASP.NET MVC by Matt Hinze
  8. Quick Tips About ASP.NET MVC – WebPart Framework by Nunos
  9. MVC Contrib Portable areas download
  10. MVC Widgets with RenderAction  by Steve Michelotti
  11. Creating a Stock Widget in ASP.NET MVC Application by Azam Sharp
  12. Creating an MVC based website with reusable widgets by Geert van der Cruijsen

Tuesday, June 29, 2010

SVS technology web site has a new look

Upgraded SVS Technology site with the following features:

  1. ASP.net MVC 2.0
  2. Microsoft Server 2008
  3. .net 4.0
  4. Discountasp is a very good host. The upgrade and web deploy from Visual Studio 2010 went very smoothly.
  5. Had to  set System.Web.MVC  reference properties copy local to true to make it work.
  6. Added a redirect to Prizewheel demo so that it will work with the new controller/ view architecture of the site so that old links will not break

Json Data Visualizer (for Google, Yahoo, Bing and Twitter) using JQuery, JavaScript, Asp.net MVC 2.0

I have been working for the past few weeks on the code project article

Json Data Visualizer (for Google, Yahoo, Bing and Twitter) using JQuery, JavaScript, Asp.net MVC 2.0

this was fun and I had to use following references

  1. “prettyPrint” for JavaScript by James Podesly for table data visualization
  2. Javascript unpacker and beautifier by Einar Lielmanis for Beautify format.
  3. Show Object Properties by Matt Holthe for understanding recursive scanning of Javascript objects.
  4. http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search for Twitter search.
  5. http://developer.yahoo.com/common/json.html#overview about Yahoo Json
  6. http://developer.yahoo.com/search/local/V3/localSearch.html for yahoo search
  7. http://msdn.microsoft.com/en-us/library/dd251056.aspx about bing
  8. http://code.google.com/apis/ajaxfeeds/documentation/ for google.

Thursday, June 10, 2010

Rest, Web services, Javascript, JQuery

Read interesting articles on REST and web services.

  1. A Brief Introduction to REST by Stefan Tilkov Very informative article. I enjoyed not only the technical content but also the prose. He talks in this about Roy Fielding (given in links below) inventor of REST.
  2. Roy T. Fielding inventor of REST.
  3. Architectural Styles and the Design of Network-based Software Architectures Html version of Roy’s Thesis on REST.
  4. Architectural Styles and the Design of Network-based Software Architectures PDF version of Roy’s Thesis on REST.

Good tutorials and articles on Javascript, REST and JQuery

  1. Tutorials:Live Examples of jQuery
  2. JQuery Tutorials
  3. Tutorials:jQuery For Designers
  4. W3 Schools Beginner Tutorials on Javascript, JQuery
  5. JSON for the masses
  6. Partial Rendering with ASP.NET MVC and jQuery
  7. Make Yahoo! Web Service REST Calls With C#

Yahoo services, Json, JQuery and Javascript Object browser

Looking at Yahoo web services and working  with Javascript, MVC and JQuery.

Yahoo is making several APIs available

  1. Yahoo Developer Network
  2. Yahoo APIs and Web Services

Yahoo can provide data back as XML or Json. Interesting links for using Yahoo services.

  1. Interesting Link by Matt Holthe on a Javascript Object Browser. Helped me to debug the Yahoo Json data.
    Show Object Properties
  2. How to use  returned XML from Yahoo Services with Silverlight
    Silverlight: Using Returned XML
  3. Interesting article on parsing Json safely
    Safely parsing JSON in JavaScript
  4. Excellent Json validator. Not only validates, nicely formats the stream which comes from Yahoo (Json data) so that you can copy the input to a word document to understand the data structure.
    JSONLint The JSON Validator
  5. Introduction to Json and Javascript JSON in JavaScript
  6. JSON Primer

Thursday, June 3, 2010

Silverlight Buttons

Recently I submitted a Silverlight article on CodeProject. One of the readers commented on my buttons not Silvelight like! I agree with the comment and started looking at good button  designs and came across these:

  1. A Glass Orb Button in Silverlight by Timmy Kokke a very good collection of buttons.
  2. 10 Cool Buttons for Download in Expression Blend & Silverlight by Alan Beasley
  3. Building Better Buttons in Expression Blend & Silverlight by Alan Beasley
  4. Creating a Glass Button: The Complete Tutorial by Martin Grayson
  5. Silverlight Buttons and Pushbutton Discussion by Wynapse

Monday, May 24, 2010

Silverlight Datagrid pager issues and PageCollectionView wrapper

Tried Datagrid pager by

<data:DataPager x:Name="TempDataGridPager"
               Source="{Binding Path=Source,ElementName=DataGrid1}"
                   PageSize="2" >
           </data:DataPager>

and then

DataGrid1.ItemsSource = ListPictures;

It did not work. Then looked at the following article

DataPager Class 

had to use PagedCollectionView, which provides paging functionality .to make it work

PagedCollectionView itemListView = new PagedCollectionView(ListPictures);
            TempDataGridPager.Source = itemListView;
               DataGrid1.ItemsSource = itemListView;

Wednesday, May 19, 2010

Silverlight InitializeError- Invalid or malformed application: Check manifest Changing Namespace

I recently changed the namespace in a Silverlight project and ran into lot of problems! Visual Studio was smart to change the namespace in many files, but I ran into this bug and the page will not render

InitializeError- Invalid or malformed application: Check manifest.

I researched this and came across this forum posting:

InitializeError- Invalid or malformed application: Check manifest

First I learnt an easy way to  look at the XAP file. Just change the extension to .zip and you can unzip it and look in the App.Manifest file. No problem there. Then going through the thread I found the solution as recommended by R. Wiltschek. Quoting him

“In human-readable words, this is what fixed it for me: 1. Open the properties of your project. 2. On the first page, open the drop down list of "Startup object". 3. Select the page your project starts with. In my case, changing the name of the namespace broke the startup object.”

It worked for me!

Dynamic C#, Visual Studio 2010, OData

Attended a talk by Kevin Pilch-Bisson and Ryan Dawson on

Sneak peak at the new language features of .Net 4.0 and VS2010.

Very good demo by Kevin on using the dynamic C# features to interface to Office Word and Excel without going through lot of COM idiosyncrasies, and Javascript interface which enables you to use C# classes.

Ryan talked about IronPython and IronRuby which looks interesting.

Attended an all day OData event by Douglas Purdy and Jonathan Carter. The presentation was similar to the one in MIX10. Exciting technology, might be useful for XBRL data presentation.

Tuesday, May 11, 2010

Silverlight controls with custom shapes

In Silverlight and WPF you can do  amazing things with the controls. You can make controls take different looking shapes.  Scott Guthrie has an excellent blog Silverlight Tutorial Part 7: Using Control Templates to Customize a Control's Look and Feel describing how this is done. This  is one of the controls he shows. A calendar inside a button!

step115

blah!bLaH!BLOG!! (funny name!) has couple of blogs

  1. WPF: A ControlTemplate for an Analog Clock
  2. WPF: The ItemsPanelTemplate - controlling how ListBox/ComboBox etc. render their children,

The second one shows how to  create an international clock which looks like this. Amazing!

63654627jm7

Jit Ghosh has an excellent blog explaining how to build custom controls.

WPF Control Templates - An Overview.

Jit also mentioned the XAMLPAD editor, which I researched and tracked to Lester’s WPF blog

XamlPadX v2.

Monday, May 10, 2010

Silverlight Animation, Zoom,Perspective Transform, 3D effects

Very interesting effects with Sivlerlight.
Silverlight Sample Browser has excellent examples. Many of them also have source code. I like the following samples from there. Some of the samples require Silverlight 4:

Nikolay Raychev has an excellent demo Perspective 3D in Silverlight 3. The picture of Acanthoscurria_geniculata is awesome!

Silverlight 3's New Perspective Transform by Jeff Prosise is a good introduction to the Perspective Transform.

Mousewheel Zooms in Silverlight 2.0 by Jeff Prosise gives a very good mouse zooming effect animation. This explains the HtmlWindow class! Mouse wheel working with Deep Zoom  is allso a good introduction to HtmlWindow class! Image Effects with Silverlight: Creating the Saturation Light Sample is dramatic!

 Coordinate Systems, Transformations and Units is an excellent reference.

Hardrock Memorabilia is a very good example of Deep Zoom.

Jeff Prosise has an excellent article A Touch of Silverlight which refers to Mycomix which is a very good demo. Click on Thumbnails to see the fun page and then click on any of the Comix icons to get  a new window. Use the mouse to rotate the image and enjoy!

Thursday, May 6, 2010

Silverlight Visual Studio how to add existing Silverlight projects

When you want to use existing Silverlight projects (like demos from Devexpress Silverlight AgGrid) in Visual Studio do the following:

  1. Start a Silverlight Application
  2. Host it in a new web site.
  3. Add the Silverlight Project.
  4. Right click on Web application
  5. Select Properties.
  6. Select Silverlight Applications tab
  7. Press the Add button
  8. Use existing project radio button will be normally selected.
  9. The drop down menu will show you the Silverlight projects available in the solution.
  10. Select add a test page.
  11. Leave the destination folder as ClientBin
  12. Press the Add button.
  13. A test page is added
  14. The XAP file from the silver light project is added to the ClientBin.
  15. Every time you make changes in the silver light project and compile the solution is updated.
  16. Sometime the F5 (Compile and Run) button in Visual Studio does not use the updated file.
  17. You may have to do a compile first and then run it.

Wednesday, May 5, 2010

WCF, Silverlight , Ajax development with Visual Studio

Visual studio offers 2 templates for adding WCF.
The following quote from WCF Visual Studio Templates explains the 2 types:

“AJAX enabled WCF Service Item Template
This template exposes an AJAX control as a WCF service. For more information on AJAX controls, see the AJAX control documentation.

Silverlight-enabled WCF Service Item Template
This template creates a Web service that provides data to a Silverlight client or front-end. The template can be added to a Web site or Web application project to create a WCF service, which includes service code and configuration that support communicating with a Silverlight client. You can then use Add Service Reference to add a client proxy of the service to the client, and exchange data between the Silverlight client and the Silverlight-enabled WCF service.

To access this template, right-click a Web site or Web application project in Solution Explorer, click Add a new item, and click Silverlight-enabled WCF Service.

Visual Basic Note: 
The Silverlight-enabled WCF Service exposes a basicHttpBinding endpoint without enabling any security settings. Therefore, information about the service can be obtained by all clients that connect to this service. Messages exchanged between the service and the client are also not signed or encrypted. To secure the endpoint properly, you should use ASP.NET authentication, HTTPS or other mechanisms. “

Schleichermann has an excellent blog on this topic:  .Net: Difference Between WCF Service and Silverlight-Enabled WCF Service

Muhammad Adnan Amanullah also has an interesting article on this topic:  Ajax enabled web service where he describes how to Make Script based web service which could be called by JavaScript.

Tuesday, May 4, 2010

Sivlerlight Colors Lack of ColorTranslator

System.Windows.Media used for colors by Silverlight  does not have ColorTranslator which would be convenient to specify a color using ColorTranslator.FromHtml(“AliceBlue”).

Colors like AliceBlue is  available in XAML but not in code behind where you have to use Color.FromArgb Method or the following code mentioned in Color Structure

String xamlString = "<Canvas xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Background=\"MistyRose\"/>";



Canvas c = (Canvas) System.Windows.Markup.XamlReader.Load(xamlString);



SolidColorBrush mistyRoseBrush = (SolidColorBrush) c.Background;



Color mistyRose = mistyRoseBrush.Color;




Laurent Duveau has an interesting solution to this problem in this blog Silverlight – Get Color from Hex



where he shows how to get ColorTranslator with Hex values!

Monday, May 3, 2010

SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used error in Azure, Visual Studio

I copied one of the Azure solutions Thumbs_E1(which was working)  to Thumbs_E1_SL1 folder  along with the project folders to a new folder. Changed all folder names to correspond with the new extension I had.

Thumbnails_E1_WorkerRole to Thumbnails_E1__SL1_WorkerRole
Thumbnails_E1_WebRole to Thumbnails_E1__SL1_WebRole
Thumbnails_E1 to Thumbnails_E1_SL1

When I opened the solution it complained about the projects not being there. I removed the projects folder icons and added the projects again from the renamed folders.

It compiled fine, but would not run and gave me an error

System.InvalidOperationException: SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used.

I found a solution in the following link

Using the CloudStorageAccount.FromConfigurationSetting

Set the Thumbnails_E1 as the start up project and it worked!

Editing code in Blogger, Blogspot Using Windows Live Writer and Code Snippet Plug in

My blogs refer to code. I found the following post which pointed me to the right direction.
Posting Source Code in Blogger from Please Make A Note
I downloaded
Windows Live Writer which has ways to directly write the for blogger and publish it.
In addition, I downloaded the code snippet plug in
Code Snippet plugin for Windows Live Writer by Leo
It works like a charm. Only problem is it produces extra spaces between lines! XAML code requires that you select the HTML option in Code Snippet plug in. This produces good colored source code output. Please make sure to disable line numbering which will make it easy for someone to cut and paste your code!
You also also add labels which is called as categories in Windows Live Writer.
I wanted to add an image. The Live Writer asked me to go to Picasa. I added the image in the Blogger editor!

Silverlight Datgrid control customization

This is a very good introduction to customization in Silverlight datagrid customization by Martin Mihaylov.
Basic customizations of the DataGrid.
Another interesting article is from Scott Morrison
Defining Silverlight DataGrid Columns at Runtime
The template information is put in the App.XAML file as a resource and then used by the Datagrid as a StaticResource. Example given below will color alternating rows with Bisque and NavajoWhite colors :
in App.Xaml file
<Application.Resources>
<Style x:Key="DataGridStyle"  TargetType="data:DataGrid">
<Setter Property="RowBackground" Value="Bisque" />
<Setter Property="AlternatingRowBackground" Value="NavajoWhite"/>
</Style>
</Application.Resources>
and in the Main.Xaml file
<data:DataGrid x:Name="DataGrid1" AutoGenerateColumns="False" Style="{StaticResource DataGridStyle}" >
Another web site which has an excellent color chart is
Web colors from Wikipedia.
This is a very trivial example but can be extended to various parts of the Datagrid for special effects including animation.
For example this header effect

will be produced by the code given below.
App.XAML
<Style x:Key="ImageHeaderStyle" TargetType="prim:DataGridColumnHeader" >
<Setter Property="Foreground" Value="Black" />
<Setter Property="Template"  >
<Setter.Value >
<ControlTemplate TargetType="prim:DataGridColumnHeader"   >
<Canvas Width="100" Height="34" Background="BurlyWood">
<Border BorderThickness="5" BorderBrush="Black"
VerticalAlignment="Center"   >
<TextBlock Width="90" Height="24"  
Text="{TemplateBinding Content}" 
FontSize="16"  Foreground="Black" 
TextAlignment="Center
>
 
</TextBlock>
</Border>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

Monday, April 26, 2010

Sivlerlight Carousel and Phot Albums for photo display

I was looking for a way to display pictures in a carousel or a photo album.
Nikhil has an interesting blog which is done in Silverlight 1.0
http://www.nikhilk.net/SilverlightCarousel3.aspx

Terence Tsang has a couple of them in his blog Shinedraw in which he has compared flash with silverlight:
http://www.shinedraw.com/animation-effect/flash-vs-silverlight-image-carousel/
http://www.shinedraw.com/3d-illusion/flash-vs-silverlight-image-advance-carousel/

Vectorform also has an interesting carousel done in silverlight in Javascript

http://www.vectorform.com/silverlight/blog/index.php/2009/01/23/image-carousel-silverlight-20/

Silverlight Slide Show by Vbrocks is a great one but in VB.
http://www.codeproject.com/KB/silverlight/Silverlight3_Slideshow.aspx

Codeplex has a terriffic slideshow based on Silverlight and done in C#
http://slideshow.codeplex.com/

Phluffyphotos has an example which is supposed to work with WindowsAzure.
But I could not make it work.
http://phluffyfotos.codeplex.com/

Tuesday, April 20, 2010

Silverlight WCF and Azure

Azure is the cloud server base technology. WCF services can produce server pages which can be consumed by Silverlight. However this operation can be tricky.
I participated in an interesting thread Silverlight 3 / November Azure CTP / WCF Sample topic:

http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/4722b0bc-65eb-4315-8044-9a8c3e715d1c
Allen Chen came up with an interesting sample for this.
http://cid-2fa13ebc6cc8e80f.skydrive.live.com/self.aspx/Public/SLWCFInSameWebRole.zip?sa=558372906
This gives you the fundamentals required to make it work in Visual Studio.
This will come up with 2 web pages. The click me button works. The other 8080 port shows an error. Instead of http://127.0.0.1:8080/ if you browse to http://127.0.0.1:8080/Service1.svc you will see the web service and the http://127.0.0.1:8080/Service1.svc?wsdl will produce the XML output for the service.
Couple of key points which make this work.
Note the clientaccesspolicy.xml file and the web.config files
also the proxy setting in the mainpage.xaml.cs file
proxy = new SilverlightApplication1.ServiceReference1.Service1Client(new BasicHttpBinding(),

new EndpointAddress(string.Format("http://{0}:{1}/Service1.svc", HtmlPage.Document.DocumentUri.Host, "8080")));


You may also run into a bug: "Fixing the Silverlight Design Time in a Windows Azure Cloud Service issue in Visual Studio 2008" showing as an “Object reference not set to an instance of an object" in XAML editor. Jim Nakashima has given a fix in his blog
http://blogs.msdn.com/jnak/archive/2010/03/23/fixing-the-silverlight-design-time-in-a-windows-azure-cloud-service.aspx