Thursday, December 27, 2007

Microsoft's New Year Resolution for Silverlight

This is my list of what what Microsoft's new years resolutions for Silverlight should be, they are however very unlikely but I think its about time Microsoft take initiative and this about this.

Silverlight 2.0 Alpha in January 2008: Now wouldn't that be cool? Developers/Designers could get their hands dirty with new features in Silverlight 2.0 (grid, controls) and start building meaningful applications that would have compatibility with Silverlight 2.0 plug-in.

Microsoft openly sharing Silverlight information: Am I really asking too much with this? I really don't understand why Microsoft have to be so secretive of their projects, weather it be Silverlight (compared to Adobe) or IE8 (compared to Mozilla). Why can't Microsoft be open and share information or be supportive of early adopters or developers?

Microsoft Expression Exchange: In reality this could only exist in my wish list, Microsoft has never been supportive of its developers, but that was thing of the past Microsoft are not dealing with developers alone anymore, after .NET 3.0 /WPF and Silverlight they are dealing with designers community, Okay, I agree there is not much you can share or exchange as a developer but a designer could share almost anything from simple assets to complex codes, they can share vector graphics for Expression Design, video skins for Expression Encoder, and XAML for Expression Blend. Since announcement of grids/controls in Silverlight applications the need for this kind of exchange program could only result in high productivity

Viewing XAML at Runtime: To me and many other like me this is one feature we would really love to see in the next version of Silverlight , it is easy to create dynamic content in Silverlight but its a real problem to check that XAML for any errors or tweaking. As far as implementation is concerned I don't think its really a problem for Microsoft to allow this but the problem is the shortcut to view XAML as there is no right click available in Silverlight due to compatibility issues with other platforms, and view source will show the HTML file holding XAML.

Microsoft accepting OpenGL and implementing it in Silverlight and the only reason they wouldn't is DirectX, they are simply not going to desert their most prized windows feature they are working on for years on end. I have only one suggestion just in case Microsoft is listening, being stubborn when you are developing next generation cross-platform applications would only restrict progress, there is a first time for everything and Silverlight could be the first time you adopt OpenGL because clearly other platforms are never going to adopt DirectX.

Rich Text Box / integrated HTML object: Probabily the only item in my wish list that is most important and something that can actually come true. This is  very important for RIA web page development, Please check my previous post on Rich Text Box makes rich RIA

Wednesday, December 26, 2007

Silverlight 2.0 - Unicode and Full Font Support

In Silverlight 1.1 Alpha Microsoft included only English Language support  for text and there are only 9 fonts available, 8 normal text fonts and a symbol font without any Unicode support.

Additional font support is available as downloader objects, the font not specified by default in Silverlight applications should be downloaded in cache along with other assets.

The reason for this is that Silverlight 1.1 Alpha applications run in a sandbox within a browser, the font directory is a systems directory and the security restrictions restricts the access of the system directory to the application. Microsoft could have included more fonts for the Silverlight plug-in but to reduce the size of Silverlight plug-in, it was restricted to total of 9 fonts.

However, because of this reason, there is no Unicode support for other languages, if a desired Unicode is required the font should be downloaded as downloader object into the project solution. For complex scripts like Chinese, Japanese, Arabic or Hindi the font size could be anywhere between 6 MB to 12 MB, resulting in the client required to download the font again, where it normally is already available at client's system directory.

Microsoft,  although not officially commented to do "something about it" in Silverlight 2.0 beta, as far as I am concerned it is an entirely essential to include the support. But how Microsoft is going to allow access over cross platform to a system directory from a sandbox,  is yet to be seen, this could easily end up catastrophic and could leak security flaws.

My prediction is that Microsoft is going to follow the same path as Silverlight 1.1 Alpha applications that is loading non available fonts as downloader objects, but at the same time they are going to allow Silverlight plug-in to check the systems directory for the availably of the font and if the font is available then make a copy of the font in the working cache directory for easy access, if no Font is found then it can download the font as a downloader object.

This scenario could solve  the problem not just for Unicode support but makes any Open Type (otf) or True Type (ttf) fonts to be available to the user.

I would rate this feature as a must and Microsoft also realised the issue so do expect to see it in Silverlight 2.0 Beta in March 2008.

Apart from that, I would also like to see the Silverlight SDK engine to allow all fonts available at design time, by automatically including the font in the project solution, not as an embedded resource, but as resource asset

Overall, I hope font support in Silverlight 2.0 will get better but how better depends on how serious Microsoft is going to take this issue. So I would rate this font feature expectancy as 5/5

Friday, December 21, 2007

Silverlight - World Map

I have promised in my previous post about XAML World Map, it  is finally here. Boy it took more time than I thought it would, and it was painstakingly boring, well it is finally here and I have a sample application in Silverlight 1.1 alpha (using VB.NET) how to use the world map.

Few Facts about this XAML World Map

  • Map not for Scale

  • More than 150 countries are included.

  • Each country is held by a canvas, and each child of the canvas is a path.

  • Non-populated or relatively small countries are not included.

  • I have tried my best to be accurate with country names, if there are any mistakes I would update it if brought to my notice.

  • Country canvas's are named by ISO 3166 Country Codes standards, but since ("is", "in", "do" are reserved words other codes are used). 

Countries Not Included. (87)

Country Name
ISO
ÅLAND ISLANDS AX
AMERICAN SAMOA AS
ANDORRA AD
ANGUILLA AI
ANTARCTICA AQ
ANTIGUA AND BARBUDA AG
ARUBA AW
BAHAMAS BS
BAHRAIN BH
BARBADOS BB
BERMUDA BM
BOSNIA AND HERZEGOVINA BA
BOUVET ISLAND BV
BRITISH INDIAN OCEAN TERRITORY IO
CAPE VERDE CV
CHRISTMAS ISLAND CX
COCOS (KEELING) ISLANDS CC
COMOROS KM
COOK ISLANDS CK
CROATIA HR
DJIBOUTI DJ
FALKLAND ISLANDS (MALVINAS) FK
FAROE ISLANDS FO
FIJI FJ
FRENCH POLYNESIA PF
FRENCH SOUTHERN TERRITORIES TF
GIBRALTAR GI
GRENADA GD
GUADELOUPE GP
GUAM GU
GUERNSEY GG
HEARD ISLAND AND MCDONALD ISLANDS HM
HOLY SEE (VATICAN CITY STATE) VA
HONG KONG HK
ISLE OF MAN IM
JERSEY JE
KIRIBATI KI
LIECHTENSTEIN LI
MACAO MO
MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF MK
MALDIVES MV
MALTA MT
MARSHALL ISLANDS MH
MARTINIQUE MQ
MAURITIUS MU
MAYOTTE YT
MICRONESIA, FEDERATED STATES OF FM
MONACO MC
MONTENEGRO ME
MONTSERRAT MS
NAURU NR
NETHERLANDS ANTILLES AN
NEW CALEDONIA NC
NIUE NU
NORFOLK ISLAND NF
NORTHERN MARIANA ISLANDS MP
PALAU PW
PALESTINIAN TERRITORY, OCCUPIED PS
PITCAIRN PN
PUERTO RICO PR
RÉUNION RE
SAINT BARTHÉLEMY BL
SAINT HELENA SH
SAINT KITTS AND NEVIS KN
SAINT LUCIA LC
SAINT MARTIN MF
SAINT PIERRE AND MIQUELON PM
SAINT VINCENT AND THE GRENADINES VC
SAMOA WS
SAN MARINO SM
SAO TOME AND PRINCIPE ST
SEYCHELLES SC
SLOVENIA SI
SOLOMON ISLANDS SB
SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS GS
SVALBARD AND JAN MAYEN SJ
TIMOR-LESTE TL
TOKELAU TK
TONGA TO
TRINIDAD AND TOBAGO TT
TURKS AND CAICOS ISLANDS TC
TUVALU TV
UNITED STATES MINOR OUTLYING ISLANDS UM
VANUATU VU
VIRGIN ISLANDS, BRITISH VG
VIRGIN ISLANDS, U.S. VI
WALLIS AND FUTUNA WF

Countries Included (158)

Country Name 
ISO
AFGHANISTAN AF
ALBANIA AL
ALGERIA DZ
ANGOLA AO
ARGENTINA AR
ARMENIA AM
AUSTRALIA AU
AUSTRIA AT
AZERBAIJAN AZ
BANGLADESH BD
BELARUS BY
BELGIUM BE
BELIZE BZ
BENIN BJ
BHUTAN BT
BOLIVIA BO
BOTSWANA BW
BRAZIL BR
BRUNEI DARUSSALAM BN
BULGARIA BG
BURKINA FASO BF
BURUNDI BI
CAMBODIA KH
CAMEROON CM
CANADA CA
CAYMAN ISLANDS KY
CENTRAL AFRICAN REPUBLIC CF
CHAD TD
CHILE CL
CHINA CN
COLOMBIA CO
CONGO CG
CONGO, THE DEMOCRATIC REPUBLIC OF THE CD
COSTA RICA CR
CÔTE D'IVOIRE CI
CUBA CU
CYPRUS CY
CZECH REPUBLIC CZ
DENMARK DK
DOMINICAN REPUBLIC DO*DOM
ECUADOR EC
EGYPT EG
EL SALVADOR SV
EQUATORIAL GUINEA GQ
ERITREA ER
ESTONIA EE
ETHIOPIA ET
FINLAND FI
FRANCE FR
FRENCH GUIANA GF
GABON GA
GAMBIA GM
GEORGIA GE
GERMANY DE
GHANA GH
GREECE GR
GREENLAND GL
GUATEMALA GT
GUINEA GN
GUINEA-BISSAU GW
GUYANA GY
HAITI HT
HONDURAS HN
HUNGARY HU
ICELAND IS* ICE
INDIA IN* IND
INDONESIA ID
IRAN, ISLAMIC REPUBLIC OF IR
IRAQ IQ
IRELAND IE
ISRAEL IL
ITALY IT
JAMAICA JM
JAPAN JP
JORDAN JO
KAZAKHSTAN KZ
KENYA KE
KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF KP
KOREA, REPUBLIC OF KR
KUWAIT KW
KYRGYZSTAN KG
LAO PEOPLE'S DEMOCRATIC REPUBLIC LA
LATVIA LV
LEBANON LB
LESOTHO LS
LIBERIA LR
LIBYAN ARAB JAMAHIRIYA LY
LITHUANIA LT
LUXEMBOURG LU
MADAGASCAR MG
MALAWI MW
MALAYSIA MY
MALI ML
MAURITANIA MR
MEXICO MX
MOLDOVA, REPUBLIC OF MD
MONGOLIA MN
MOROCCO MA
MOZAMBIQUE MZ
MYANMAR MM
NAMIBIA NA
NEPAL NP
NETHERLANDS NL
NEW ZEALAND NZ
NICARAGUA NI
NIGER NE
NIGERIA NG
NORWAY NO
OMAN OM
PAKISTAN PK
PANAMA PA
PAPUA NEW GUINEA PG
PARAGUAY PY
PERU PE
PHILIPPINES PH
POLAND PL
PORTUGAL PT
QATAR QA
ROMANIA RO
RUSSIAN FEDERATION RU
RWANDA RW
SAUDI ARABIA SA
SENEGAL SN
SERBIA RS
SIERRA LEONE SL
SINGAPORE SG
SLOVAKIA SK
SOMALIA SO
SOUTH AFRICA ZA
SPAIN ES
SRI LANKA LK
SUDAN SD
SURINAME SR
SWAZILAND SZ
SWEDEN SE
SWITZERLAND CH
SYRIAN ARAB REPUBLIC SY
TAIWAN, PROVINCE OF CHINA TW
TAJIKISTAN TJ
TANZANIA, UNITED REPUBLIC OF TZ
THAILAND TH
TOGO TG
TUNISIA TN
TURKEY TR
TURKMENISTAN TM
UGANDA UG
UKRAINE UA
UNITED ARAB EMIRATES AE
UNITED KINGDOM GB
UNITED STATES US
URUGUAY UY
UZBEKISTAN UZ
VENEZUELA VE
VIET NAM VN
WESTERN SAHARA EH
YEMEN YE
ZAMBIA ZM
ZIMBABWE ZW

Usage in Silverlight

The supported countries are loaded in an Array to create dynamic events on MouseLeftButtonUp, this is to avoid the long Handles phrase.  You can build your own application using this canvas, I didn't include Zoom/Scroll options because I just wanted to provide XAML and to show how to use the XAML from Silverlight. 

I'll update this source code with more information (e.g., area, country, flag etc.) using LINQ/VB XML functions after Silverlight 2.0 Beta is released.

Download

Creative Commons License
This work is licensed under a Creative Commons Licence.

Source Code (Silverlight 1.1 Alpha) VB.NET - WorldMap.zip 

Not Satisfied?

Not satisfied with my work? Change the source code and please post a link in the comments.

Want to redesign yourself? There is the original Microsoft Expression Design file, use it to change it.

Creative Commons License
This work is licensed under a Creative Commons Licence.

WorldMap.Design

Hope you enjoy,  please leave your comments.

PS:  I would appreciate if anyone can host this for me, please provide me a link if you do. 

Monday, December 17, 2007

Silverlight - as desktop application.

Silverlight, the Microsoft's weapon in RIA wars, it is the revolutionary technology determined to change the web trend. Microsoft coins the term "for the web" when referring to Silverlight applications,

"Deliver media experiences and rich interactive applications for the Web that incorporate video, animation, interactivity, and stunning user interfaces."

- Microsoft Silverlight

It is clear every since the announcement of Silverlight at MIX'07. Opening the key note at MIX07 Ray Ozzie Chief Software Architect at Microsoft emphases the need for creating web application that provide the power of desktop computing on the Internet, and Silverlight is clearly the best approach.

Microsoft already had the .NET infrastructure in place for ASP.NET applications and Windows Forms and the introduction of .NET 3.0/WinFX (WPF/WCF/WF)  was the final nail in bring the best of the Internet services to the desktop computing.

With Silverlight, Microsoft is clearly targeting the best of desktop experience with Internet services. Many developers have been asking about running Silverlight applications standalone, from a drive or folder,as platform independent desktop application. This however beats the idea of Silverlight,  Silverlight is developed to provide desktop applications on the web. But because of  its architecture, Silverlight can also be run from a local location, (in Silverlight 2.0 can also access any web services). Microsoft have market leadership in desktop platform about 85% - 90%, and its only fair on developers to expect cross platform compatibility for the tools they develop, but Microsoft ignored them - till now.

Microsoft have always had monopoly when it came to platform, they would go out of their way to make sure that Microsoft desktop application are platform dependent (i.e., Windows) but rapid expansion of web applications is making "the web" another platform which is totally independent, and Silverlight is the solution for this scenario and as Ray Ozzie said "Silverlight bring the best of desktop applications and the best of web services - together".  It is be true the other way around.

Microsoft is penetrating deep in Adobe's territory, and Adobe is trying to gets its share from Microsoft's territory with Adobe AIR, Adobe hopes that it would gain a share of the market from Microsoft, I am not being critical of Adobe, I genuinely think Adobe AIR is a brilliant idea, but Adobe had this brain wave at the very wrong time, if you happens to know history being in the right time and right place is very important, you won't disagree with me if you have a look at Java and its history.

Adobe AIR can't compete with WPF applications, but if cross-platform compatibility is concerned, watch out Silverlight 2.0 is coming and Mozilla got a trick up its sleeve to help Silverlight archive it.

Mozilla the makers of FireFox, who already have cross platform browsers, came up with an idea, split web applications out if their browser and run them as desktop. They call it Prism, its a very simple idea provide a software that ideally is a web browser (FireFox), modify registry to save shortcuts on desktop/start menu/quick launch to launch the Prism instance and point to one web page/local html file.

"Unlike Adobe AIR and Microsoft Silverlight, we’re not building a proprietary platform to replace the web. We think the web is a powerful and open platform for this sort of innovation, so our goal is to identify and facilitate the development of enhancements that bring the advantages of desktop apps to the web platform."

Whatever be their intentions for creating Prism, to me it is nail in Adobe's coffin, and Microsoft is going to cash on it big time,  this provides development of one application in Silverlight host it on the web or tweak the same application to install and  run as a desktop application.

This people, is history in the making and I am glad to witness it and be part of it.

Sunday, December 16, 2007

XAML World Map

A friend of mine send me this world map in Adobe Illustrator format and I converted it to XAML using Microsoft Design and I have giving few finishing touches in Blend, the paths are there but I wanted to convert the paths into canvas and give country names so there is a little work to be done, but instead of just publishing the XAML I decided to make a sample application on Silverlight 1.1 alpha.

I'll post the source code of the world map application typically showing you how to use the world map, along with the XAML. There is some work to be done and I'll try to finish it as soon as possible.

So please stay tuned but here is a sneak preview of the world map for you. Hope you enjoy.

RichTextBox makes Rich RIA

Rich Text Box, probability the one feature that could change the face of Internet applications for good, that would take Silverlight platform to the extreme, both in terms of usability and adoption, this might give Adobe nightmare, and one that every HTML developer looking forward to.

If RichTextBox is made available in Silverlight 2.0, with binding capability with XML, many developers might pay their last respects to HTML and CSS, and server pages (PHP, ASPX, JSP) will be used to generate dynamic XAML instead of HTML. AJAX would be replaced with Silverlight, giving developers easy to manage extensions UI.

The framework for RichTextBox adoption is already in place, developers argue that this type of adoption will restrict the search bolts to search for data inside a Silverlight control, but RSS and ATOM feeds might come to rescue.

RichTextBox is already available in WPF application and the adopted in many applications like New York Times Reader, but its availably in Silverlight is still unknown, officially Microsoft hasn't spoken about this feature, and it isn't included in Silverlight 2.0 roadmap, the probability of seeing RichTextBox in Silverlight 2.0 is slim but the probability of such a feature is still there.

Rating:

FEATURE: 4.9/5

EXPECTANCY: 2/5

Saturday, December 15, 2007

CSS in Silverlight? Oh Yeah! Even Better? Hell Yeah!

CSS existence is quite ancient but the true potential of CSS was realised only for parsing XML elements. Ok we already know that and also that XAML is XML based or atleast the inspiration/syntax is, does it mean we can expect CSS type styling in XAML, if it can be used in XAML does it mean we can use it in Silverlight 2.0 applications?

Too many questions but a simple answer, CSS is thing of the past  with many issues like incompatible browsers, hard to retrofit, hard to learn, time consuming, pain staking need I say more? Next generation technology requires next generation style sheet format,  so please welcome XAML Resources.

XAML What?

You heard - XAML resources, providing style sheets in XAML format as simple as that. Wait a minute, does it mean we can design our own custom buttons or controls from a graphic designer in one XAML and use is across the applications?

Yes, how about an example?

<Page.Resources>
<SolidColorBrush x:Key="MyBrush" Color="Gold"/>
<Style TargetType="Border" x:Key="PageBackground">
<Setter Property="Background" Value="Blue"/>
</Style>

...

</Page.Resources>
<StackPanel>
<Border Style="{StaticResource PageBackground}">

...
</Border>

</StackPanel>


Is that it? What? How? When?



Yes that is it, want to learn How? Already in use in WPF applications. Silverlight 2.0 Beta supports it? Not sure ask Microsoft. Can we expect it? Yes we can, I give 4.7/5 for expectancy. 



Please leave your comments.






Friday, December 14, 2007

Issues - Silverlight 2.0 Backward compatibility with Silverlight 1.1 Applications.

I wonder how many times Microsoft is going to disappoint the developers community or early adopters of Silverlight.

When Microsoft first announced the technology I had mixed feelings about Silverlight, and I went on to even say "Silverlight, Why should I bother?" my problem was with Silverlight 1.1 Alpha, this is what I had to say then.

"The point is, yes, ideally Silverlight is a great concept, and it would revolutionise the way web looks, feels and works and it can even compete with Adobe Flash and put Adobe out of business even if you compromise Microsoft's poor graphic designers .If and only if Microsoft can actually finish what they started...

Don't take me wrong, I am totally happy with the work folks at Microsoft are doing and the concept of Silverlight, I just don't see the point of launching alpha version of a software that have a very long way to go and every one know what is missing. In days to come you will see Silverlight applications here and there, mostly in video streaming and few other games but the total power of Silverlight can only come to surface when Silverlight can support import of vector graphics from other formats, full security features (especially SSL), user controls (the basic controls will do), and finally database objects. "

And after seven months, nothing has changed, so I was right, they wanted MIX'07 to be a success and it pushed them to announce Silverlight 1.1. And they left early adopters waiting in anticipation for months on end then came the announcement by ScoutGu about renaming Silverlight 1.1 to Silverlight 2.0 and Beta version in MIX'08, now don't get me wrong but that is almost a year. Microsoft is never supportive of the developers, they tend to keep big secrets many suspected (including myself) that Silverlight 1.1 might take a long time to develop, but I could never have imagined that you will go to MIX'08 to announce Beta. I think Microsoft should atleast release Silverlight 2.0 Alpha by Christmas, they own these early adaptors something. I was hoping they might release Silverlight 2.0 Alpha December Preview, but it shattered with Mono's Moonlight announcement, the latest Moonlight release (1.2.6) supports Silverlight 1.1 applications, if we were getting December preview of Silverlight 2.0 then Moonlight won't have went to the trouble of release a version to support Silverlight 1.1. So that is it, we can't get to see Silverlight 2.0 till after MIX'08.

If you thought that was enough, the worst was yet to come, Silverlight 2.0's backward compatibility with Silverlight 1.1 applications was nagging me ever since Silverlight 2.0 announcement, when Tim Sneath posted Why Can't I "Go Live" with Silverlight 1.1 Alpha? on his blog and mentioned,

Silverlight 1.1 (now known as 2.0) is not ready for "Go Live" usage at this stage, and the EULA explicitly prohibits deployment in production sites.

I took the opportunity to ask him about Silverlight 2.0 backward compatibility with Silverlight 1.1  I wasn't really expecting Tim to answer as they are always secretive about future releases, but when Tim replied, the answer wasn't to my liking,

Imran, there are substantial breaking changes between the 1.1 alpha and what will become the final 2.0 release - we don't claim to be backward compatible with 1.1 alpha. However, 2.0 _is_ fully backward-compatible with 1.0 applications.

Now that is devastating, not for Microsoft but for the early adopters of the technology, Microsoft still benefited by the buzz and hype surrounding the Flash Vs Silverlight argument which only early adopters made possible, now if Silverlight 2.0 is going to be so different to Silverlight 1.1 to the extend that they can't even be compatible, then the question is what have the early adaptors of Silverlight 1.1 Alpha archived since Silverlight 1.1 was announced?

It was not about poor implementation or planning for Silverlight on Microsoft's part, every one knew what was missing, everyone know what was required, but still Microsoft went on to announce Silverlight 1.1 in MIX'07 just to create the hype in the developer community and provide the exclusive marketing with the developers.

If it was not for the early adopters of Silverlight 1.1, Silverlight 1.0 community won't have been where it is now and now we .NET developers have to start again in March after MIX'08.

I hope history doesn't repeat itself.

Thursday, December 13, 2007

Moonlight is lit.

Novell and Microsoft have been working on Moonlight project  with interoperability collaboration between Novell and Microsoft and today Mono team announced the final release of Moonlight 1.2.6.

This release will let browsers on Linux platform, FireFox, Opera etc.,  to run Silverlight applications. Moonlight will also include SDK to develop Silverlight 1.1 applications  in GTK#/native Quartz backend.

Moonlight 1.2.6 is available for download

Forward/Rewind in Silverlight

Silverlight provides a great platform to for Video playback but Expression Media Encoder does not provide any Forward/Rewind options in Silverlight and many developers were asking about it. I thought how hard it could be so I decided to do this, I wanted to do this in VB.NET for about a month now but just kept delaying it, but when I started I finished it in about 15 minutes and I was surprised how easy it is (Now I know why Microsoft didn't bother to invest in it). I think that 15 minutes is a accomplishment so I decided not to change the  XAML or the Code. Well I had to do something to make you understand the code so spend another 10 to write comments.

Here is the XAML (Just to give you an idea, you can design your own.)

<Canvas x:Name="parentCanvas"
xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="Page_Loaded"
x:Class="VideoRewindForward.Page;assembly=ClientBin/VideoRewindForward.dll"
Width="320"
Height="205"
Background="White">
<Canvas.Resources>
<Storyboard x:Name="dummyStoryboard" Duration="0:0:0.5"/>
<Storyboard x:Name="HideMessageCanvas">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="MessageCanvas"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Canvas.Resources>

<MediaElement x:Name="VideoPlayer" Souce="..." .... />
<Canvas x:Name="RewindButton" ... />
<Canvas x:Name="ForwadButton"..../>
<Canvas x:Name="PlayButton".../>
<Canvas x:Name="MessageCanvas" Opacity="0.5" Width="50" Height="18">
<Rectangle Width="50" Height="19" Fill="#FFEAEAEA"/>
<TextBlock x:Name="RewindForwardSpeed" Width="53" Height="18" TextWrapping="Wrap" Foreground="#FF000000"/>
</Canvas>
</Canvas>


And now the VB.NET Code.



Partial Public Class Page
Inherits Canvas

Private videoSpeed As Integer = 1 'Play

Public Sub Page_Loaded(ByVal o As Object, ByVal e As EventArgs)
' Required to initialize variables
InitializeComponent()
MessageCanvas.Opacity = 0
End Sub
''' <summary>
''' Play the Video
''' </summary>
''' <param name="o"></param>
''' <param name="e"></param>
''' <remarks>Calls PlayVideoAtSpeed with Speed Normal (1)</remarks>
Public Sub PlayButtonPressed(ByVal o As Object, ByVal e As EventArgs) _
Handles PlayButton.MouseLeftButtonUp
videoSpeed = 1
playVideoAtSpeed(1)
End Sub

''' <summary>
''' Handles the Event when RewindButton is pressed
''' </summary>
''' <param name="o"></param>
''' <param name="e"></param>
''' <remarks>Calls PlayThisVideo with Direction Rewind (-1)</remarks>
Private Sub RewindButtonPressed(ByVal o As Object, ByVal e As EventArgs) _
Handles RewindButton.MouseLeftButtonUp
If VideoPlayer.DownloadProgress = 1 Then
PlayThisVideo(-1)
End If
End Sub

''' <summary>
''' Handles the Event when ForwardButton is pressed
''' </summary>
''' <param name="o"></param>
''' <param name="e"></param>
''' <remarks>Calls PlayThisVideo with Direction Forward (+1)</remarks>
Private Sub ForwardButtonPressed(ByVal o As Object, ByVal e As EventArgs) _
Handles ForwadButton.MouseLeftButtonUp
If VideoPlayer.DownloadProgress = 1 Then
PlayThisVideo(1)
End If
End Sub

''' <summary>
''' Changes the direction of Forward/Rewind, Calculates new speed Check if the
''' forward/Rewind Position is Valid
''' </summary>
''' <param name="direction">-1 for Rewind, 1 for Forward</param>
''' <remarks></remarks>
Private Sub PlayThisVideo(ByVal direction As Integer)
'Change the direction, Forward/Rewind
If Math.Sign(videoSpeed) <> direction Then
videoSpeed = direction
End If
'Calculates the speed
If videoSpeed < 32 And videoSpeed > -32 Then
videoSpeed *= 2
Else
videoSpeed = 1
End If
'Calculate actual length of the video and current position.
Dim videoLength As Double = VideoPlayer.NaturalDuration.TimeSpan.TotalSeconds
Dim VideoCurrentPosition As Double = VideoPlayer.Position.TotalSeconds
'Show the speed on the canvas
ShowVideoSpeed()
'Check if the current position is not at the end(can't forward) or at the Start (can't rewind)
If VideoCurrentPosition >= 0 And VideoCurrentPosition < videoLength Then
'Play the video at speed.
playVideoAtSpeed(videoSpeed)
End If
End Sub

''' <summary>
''' This function Plays or rewinds or forwards the video, the reason this is a
''' different module and not intregrated in PlayThisVideo(direction) is that,
''' this module is also consumed when Play Button is pressed
''' </summary>
''' <param name="speed">The speed at which to play the video</param>
''' <remarks>When video is played at higher speed than 1 then the funtion pauses the video and begins
''' a dummy animation, which will iterate the forward progress until Play button is pressed.</remarks>
Private Sub playVideoAtSpeed(ByVal speed As Integer)
If speed = 1 Then
videoSpeed = speed
ShowVideoSpeed()
Else
VideoPlayer.Position = TimeSpan.FromSeconds( _
VideoPlayer.Position.TotalSeconds + speed)
VideoPlayer.Pause()
MessageCanvas.Opacity = 0.5
dummyStoryboard.Begin()
End If
End Sub

''' <summary>
''' This Module is use to iterate the froward/Rewind function.
''' </summary>
''' <param name="o"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub dummyTimeline(ByVal o As Object, ByVal e As EventArgs) Handles dummyStoryboard.Completed
playVideoAtSpeed(videoSpeed)
End Sub

''' <summary>
''' ShowVideoSpeed Modules checks and shows the Rewind/Forward Speed,
''' this Module is only to show.
''' </summary>
''' <remarks>When the mode is Play, it will start the animation to hide the bar.
''' The text in this module can be replaced with </remarks>
Private Sub ShowVideoSpeed()
Dim returnString As String = ""
If videoSpeed = 1 OrElse videoSpeed = -1 Then
returnString = "Play"
VideoPlayer.Play()
HideMessageCanvas.Begin()
Else
If videoSpeed < 0 Then
returnString &= "<<" 'Can be changed with XAML or image
Else
returnString &= ">>" 'Can be changed with XAML or image
End If
returnString &= (videoSpeed * Math.Sign(videoSpeed)).ToString
End If
MessageCanvas.Opacity = 0.5
RewindForwardSpeed.Text = returnString
End Sub
End Class



Hope you enjoy. Please leave your comments.







Tuesday, December 11, 2007

Silverlight Deployment - Easy or Fussy?

Structure of Silverlight allows designers and developers to work in different environments and synchronise their work simultaneously, but the same features come back to hound the deployment process.

Deployment of Silverlight applications could have been made easy, Silverlight uses .NET Framework 3.5 for development and System.IO.Packaging Namespace already available in .NET 3.0 could have been used to help deploy Silverlight applications. 

Microsoft uses this same package architecture in XPS document specification, if Silverlight uses the same method not just the deployment will be easy but also the downloading of the Silverlight application inside a browser will be easy using Downloader Object. The application will download faster, firstly because of the compression, and because there will only be a single file to download reducing multiple server requests.  And you can have centralised control of Silverlight objects.

I am really struggling to find the reasons why Silverlight shouldn't implement this option for Silverlight.

I would rate this feature 3.5/5

Saturday, December 8, 2007

Expression Blend 2.0 December Preview disappointment

Today Microsoft released the December Preview for Expression Blend the basic tool for designing Silverlight XAML.

This came after Scott Guthrie's announcement that Silverlight 2.0 and that he will be starting a new Silverlight 2.0 features tutorial series in his blogs.

I was eagerly anticipating the release for December Preview, hoping that we might get a sneak preview of the Silverlight 2.0 features. Instead, I am very disappointed with the preview version. After reviewing the preview version the only feature updated from September Preview is personalising the Blend 2.0 with the features to Silverlight.

Blend 2.0 September Preview has many issues with Silverlight as you can expect from a preview version of undeveloped technology, basic issues like image brush was not included in September preview but could have coded in Visual Studio, December preview didn't even touch these basic issues.

I am disappointed with this release, but with Scott Guthrie's announcement about Silverlight 2.0. We might see another Preview version either January/February.

Wednesday, December 5, 2007

Is Silverlight truly WPF/E (WPF Everywhere)?

Silverlight 2.0 scheduled to be released after Q1 of 2008 has raised the bar for the functionality and to resemble closely to WPF (Windows Presentation Foundation) during its early days it was code named WPF/E for WPF Everywhere but now that a stable version is announced its worth looking does it resemble WPF and possible ubiquity of Silverlight plug-in.

Silverlight Adoption

We already know that Silverlight 2.0 will support Internet Explorer, Safari, FireFox, Opera, Konqueror, SeaMonkey on Windows, Mac and Linux (Moonlight Project),  these three OS constitutes of 99.8% of the total market share for OS accessing Internet applications (Source: Market Share). 

As this date Silverlight doesn't support all web browsers and we don't know anything about Mobile browsers/OS. Statistics show that these non supporting browsers constitutes  of about 1% of the browser market share (source: Market Share). This figure is impressive for possible deployment or adoption of Silverlight applications. But many might argue about these figure, especially who what to implement advertisements using Silverlight. If same figure is put in perspective with the number of web browsers with JavaScript disabled 6% (Source: W3Schools), in this context the possible ubiquity of Silverlight compared to AJAX (required JavaScript) is very wide.

Having said that Silverlight possible ubiquity is about 99%, it is interesting to note that this figure doesn't constitute Mobile browsers/OS. Microsoft showed interest in Mobile market but they haven't made any of their plans for Mobile browsers public. I'll write a follow up blog when Microsoft announce their intentions.

But how good if 99% possible ubiquity? Flash who have ruled this RIA area for more than a decade have Flash ubiquity of 99.1% (Source Adobe), including Flash, and Flash Lite for mobile.

Silverlight, Flash and JavaFX could well wipe the horrible HTML based web pages for good and replace with rich, interactive applications, now that Flash doesn't have a monopoly in RIA development, we could well see a change rich web sites in near future. Flash is already well established share in mobile market, and JavaFX seems to be focusing more in mobile market, its a shame Microsoft hasn't announced anything for Mobile market as yet.

In next part "Is Silverlight truly WPF/E" we will look at how large subset of WPF can we expect in Silverlight 2.0

del.icio.us Tags: ,,,

Monday, December 3, 2007

Silverlight 2.0 What can we expect?

Ok its official Silverlight 1.1 will be Silverlight 2.0, we also know Silverlight 2.0 will have user controls, and WPF UI Framework, WPF Layout management controls and network protocols REST, POX, RSS.

But there is more to it than meets the eye, In the coming weeks I would be assessing with designer/developer point of view what can we expect. I will try to asses some major/minor properties or behaviour that we might expect from Silverlight 2.0.

I will asses one method at a time and would consider the limitations and/or of most basic properties that we should get from Silverlight 2.0

del.icio.us Tags: ,

Saturday, December 1, 2007

Whats in the name anyways?

On Nov. 29 ScuttGu announced Silverlight 1.1 will be changed as Silverlight 2.0.

This came after months of working on Silverlight for .NET and CLR Platform.

I am starting this blog to for the Silverlight Community to blog their ideas about Silverlight 2.0 here, If you are intreasted please contact me and I'll make you an author, so you can start posting Silverlight 2.0 blogs here.