Monday, July 28, 2008

MouseWheel support in Silverlight 2.0 without Javascript code

Yes. Its possible eventhough we are using 'onmousewheel' event of Javascript object Document.

The process is simple.Just Subscribe to the onmousewheel event of document and process according to that.

Here I am going to zoom an image with the help of mouse wheel.

Initially there is an Image in the Page.xaml with a ScaleTransform named 'scale'.
<Grid>
<Image x:Name="img" Source="Hand.jpg" Stretch="None" VerticalAlignment="Top" HorizontalAlignment="Left">
<Image.RenderTransform>
<ScaleTransform x:Name="scale" ScaleX="1" ScaleY="1" />
</Image.RenderTransform>
</Image>
</Grid>

Step1:Subscribe to the onmousewheel event

public Page() {
InitializeComponent();
HtmlPage.Document.AttachEvent("onmousewheel", new EventHandler<HtmlEventArgs>(ondown));
}

Step 2 : Handle the ScaleTransform according to the direction

void ondown(object send,HtmlEventArgs arg)
{
object c= arg.EventObject.GetProperty("wheelDelta");
if (c != null)
{
int delta = int.Parse(c.ToString());
if (delta > 0)
{
scale.ScaleX = scale.ScaleX + .1;
scale.ScaleY = scale.ScaleY + .1;
}
else if(scale.ScaleX >.1)
{
scale.ScaleX = scale.ScaleX - .1;
scale.ScaleY = scale.ScaleY - .1;
}
}
}

Happy coding... :-)


Thursday, June 5, 2008

Crossfader Demo at TechEd

Its my proud to announce that my last project Crossfader which is developed fully in Silverlight 2.0 has been showed at Tech-Ed North america 2008 for developers.
The demo was did by S. Somasegar Senior Vice President, Developer Division from Microsoft.

Here are some links to view the demo
http://www.microsoft.com/techedonline/default.aspx
http://msstudios.vo.llnwd.net/o21/presspass/zune/Silverlight_2_Zune.wmv

Crossfader.com is a site for musicians to explore their works which is developed entirely using silverlight.They can share,collaborate and stage their valuable works.

It was great opportunity for me to start with Silverlight 2.0 with WPF Experience in hand.Learned so many technologies such as WCF,JSON LINQ Etc.

Thanks to Identitymine my company for giving such an opportunity.Another one I would like to express my thanks is David J Kelly ,the architect of the project for his valuable support.He was busy writing his first book but he helped us a lot.And to my team Haridas,Vijay,Roby ,Paul Thomas and Sam for their seamless support.
Hope the crossfader would be live soon in the light of Silver.