Developing Vista Sidebar Gadget with Script#
January 19, 2008 on 3:08 pm | In MSBuild, Vista Sidebar Gadget | 2 CommentsC# to JavaScript compiler? What? Jea! I thought the same way. It’s amazing what smart people can invent. My men is Nikhil Kothari with his Script#. What do I need the C# to JavaScript compiler for, you ask. Is IL not enough? Well think of enriching your ASP.NET web sites with JavaScript written in C#. Or using Ajax with scripts written in Visual Studio with Intelisense and refactoring. Or developing the Vista Sidebar Gadgets without writing a single line of code in Javascript!
I instantly lookd at the third possibility. since I have Vista on board I was thinking about writing my own Sidebar Gadget (you know the little programs written in HTML an JavaScript, sticked to the right side of your screen). Of course I wonted it to by at least useful
I thought about writing a small Leasing Calculator. I had my leasing mathematics library ready, but it was written in C#. I didn’t feel like rewriting it in JavaScript – what for? So Script# was a blast for me. I had my Leasing Calculator gadget in view hours.
What do you need to start working with Script#:
1. download the latest binaries from Script# project page
2. install it
3. create new Visual C# -> Script# -> Sidebar Gadget project in Visual Studio
You will get quite useful project template. The inside of Content folder is your gadget. If you compile everything Script# will transform your C# into JavaScript and place it in this folder. The last thing you have to do is to copy this folder into your Vista Gadgets folder (C:\Users\user\AppData\Local\Microsoft\Windows Sidebar\Gadgets\). You will have to do the same every time you will compile. Surely it is something to automate. The easiest way is to use the Post-build event in your project and a small MSBuild script that will copy the needed files to the place they should by.
$(WinDir)\Microsoft.NET\Framework\v2.0.50727\msbuild.exe $(SolutionDir)build.msbuild
And use this script:
<Project DefaultTargets="Deploy" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <DeploymentFolder>YourVistaGadgetFolder.gadget</DeploymentFolder> </PropertyGroup> <ItemGroup> <DeploymentSourceFiles Include="LeasingCalculatorContent***.*" /> </ItemGroup> <Target Name="Deploy"> <RemoveDir Directories="$(DeploymentFolder)" ContinueOnError="false"></RemoveDir> <Copy SourceFiles="@(DeploymentSourceFiles)" DestinationFiles="@(DeploymentSourceFiles-> '$(DeploymentFolder)%(RecursiveDir)%(Filename)%(Extension)')"/> </Target> </Project>
So you are equipped with fully functional development platform for Vista Sidebar Gadgets.
One more thing. I do think that writing a JavaScript in C# is a good idea
but if you are new to Sidebar Gadgets you probably would like to take one step by step tutorial. It would help to understand Gadgets on the low level an d will get you up to speed with Schipr# later.
I’m sure you don’t care…
January 12, 2008 on 10:54 am | In Uncategorized | No Comments
… but I’m very glad so I share
I’ve just became a MCTS – Microsoft Certified Technology Specialist in ASP.NET. I passed the 70-536 and 70-528 (with quite good marks). Now I’m starting to learn to became Professional Developer (exam 70-547). Wish my luck!
Powered by WordPress with Pool theme design by Borja Fernandez.
Text © Marcin Kawalerowicz. Hosting CODEFUSION.


