Archive for July, 2009

A XAML Moment

Wednesday, July 22nd, 2009

I’ve started digging into Silverlight the last few weeks,and a few days ago I had a light bulb moment.

I’ve realized the awesome power of XAML,here’s how you can see for yourself. Make sure you have MS Visio installed, download and install Visio Export to XAML add-in (read more here). Next, drag any shape(I used the Mainframe shape) onto the design surface. Make sure the shape is selected and click on File> Export to XAML and click on the Export to XAML button.

image

Open the generated file in any xaml viewer and tada! The image is now completely programmable. Check a very silly example here. Click the button and you’ll notice that the lights on the mainframe starts flashing.

The ability to program the image is because of Visio’s Scalable Vector Graphics(SVG) format. The add-in converts the SVG into usable XAML. So in theory, you would be able to convert any SVG file into XAML and have your programmatic way with it.

Pretty cool, isn’t it?

Date and Time Functions in C#

Thursday, July 9th, 2009

A few nice date formats in C#

http://www.daniweb.com/code/snippet184.html

DateTime CurrTime = DateTime.Now;
Console.WriteLine("DateTime display listing specifier and result:\n");
Console.WriteLine("d = {0:d}", CurrTime ); // Short date mm/dd/yyyy
Console.WriteLine("D = {0:D}", CurrTime ); // Long date day, month dd, yyyy
Console.WriteLine("f = {0:f}", CurrTime ); // Full date/short time day, month dd, yyyy hh:mm
Console.WriteLine("F = {0:F}", CurrTime ); // Full date/full time day, month dd, yyyy HH:mm:ss AM/PM
Console.WriteLine("g = {0:g}", CurrTime ); // Short date/short time mm/dd/yyyy HH:mm
Console.WriteLine("G = {0:G}", CurrTime ); // Short date/long time mm/dd/yyyy hh:mm:ss
Console.WriteLine("M = {0:M}", CurrTime ); // Month dd
Console.WriteLine("R = {0:R}", CurrTime ); // ddd Month yyyy hh:mm:ss GMT
Console.WriteLine("s = {0:s}", CurrTime ); // yyyy-mm-dd hh:mm:ss can be sorted!
Console.WriteLine("t = {0:t}", CurrTime ); // Short time hh:mm AM/PM
Console.WriteLine("T = {0:T}", CurrTime ); // Long time hh:mm:ss AM/PM
Console.WriteLine("u = {0:u}", CurrTime ); // yyyy-mm-dd hh:mm:ss universal/sortable
Console.WriteLine("U = {0:U}", CurrTime ); // day, month dd, yyyy hh:mm:ss AM/PM
Console.WriteLine("Y = {0:Y}", CurrTime ); // Month, yyyy
Console.WriteLine();
Console.WriteLine("DateTime.Month = " + CurrTime.Month); // number of month
Console.WriteLine("DateTime.DayOfWeek = " + CurrTime.DayOfWeek); // full name of day
Console.WriteLine("DateTime.TimeOfDay = " + CurrTime.TimeOfDay); // 24 hour time
// number of 100-nanosecond intervals that have elapsed since 1/1/0001, 12:00am
// useful for time-elapsed measurements
Console.WriteLine("DateTime.Ticks = " + CurrTime.Ticks);


Google Analytics integration offered by Wordpress Google Analytics Plugin