Wednesday, January 30, 2008
Anatomy of a Silverlight Animation
Storyboards like other elements in Xaml are defined with tags. The Storyboard element then can be a resource or in a trigger. We can also point a Storyboard at a specific element where each animation can target a different property and we can also target each specific animation at a given element and property separately. Let us start with a Storyboard then like this example:
<Storyboard x:Name="MyFirstStoryBoard"></Storyboard>
From this Storyboard we will build out our animations. The individual animations go in the story board. There are several kinds of animations such as color, point, key frame and key spline animations but we will start with point and color animations. Now look at this simple double animation.
<DoubleAnimation Storyboard.TargetName="PolygonElement"
Storyboard.TargetProperty="(Canvas.Left)"
To="48" Duration="0:0:3" />
This is a DoubleAnimation that, when the Storyboard is triggers changes one property value to another over the course of the duration. In this case the animation is targeted on the PolygonElement at the Left value. This animation does not have a ‘From’ setting so the property goes from whatever value it at to the ‘To’ setting and then over the duration of the ‘Duration’ setting in this case 3 seconds. We could also set a ‘BeginTime’ using the same time format as that of the Duration like this code sample:
<DoubleAnimation Storyboard.TargetName="PolygonElement"
Storyboard.TargetProperty="(Canvas.Left)" From="5"
To="48" Duration="0:0:3" BeginTime="00:00:02" />
This animation then targets the Canvas.Left property of the element named ‘PolygonElement’. At 2 seconds past the trigger of the animation it will change the left value from 5 to 48 over the course of 3 seconds. This was a double animation and you can have any number of these in a given story board. You can also use color animations in the same way with double animations. Take this code example:
<ColorAnimation
Storyboard.TargetName="PolygonElement"
Storyboard.TargetProperty="(Fill).(Color)"
From="#3c5f0c" To="#728f4a" Duration="0:0:5" />
Like the double animation earlier this ‘ColorAnimation’ is targeted at the same element but on a different property namely one that is a color ‘Fill.Color’. When this animation is triggered the ‘Fill.Color starts at one color and transforms to the other over the course of 5 seconds.
Tuesday, January 29, 2008
Silverlight Applications Taking All the Available Realestate
/* hide from ie on mac \*/
html
{
height: 100%;
overflow: hidden;
}
.silverlightHost
{
height: 100%;
width: 100%;
}
/* end hide */
body
{
height: 100%;
margin-left: 1px;
margin-top: 1px;
margin-right: 0px;
margin-bottom: 0px;
padding: 0;
}
Now there are other ways todo this such as from the HTML body onload event and also the resize event on the window together or other programatic ways but this is just nice and simple and I say keep it simple unless you have to.
Lunch at MIX
Wednesday, January 23, 2008
Drinking the Kolaide
We do not in fact come and sit in a circle, hold hands, sing songs and drink coolaide while having stories read to us.
Silverlight and Volta
http://labs.live.com/volta/blog/Volta+Secrets+Part+5++Silverlight.aspx
Its on a public site so I guess I can blog about it. They idea is simple, you write your application all in C# like a win form and this thing generates it as part web page part serverside script in now using Silverlight. I'm sure I'll talk about this more after I play with it some more.
Tuesday, January 22, 2008
Silverlight Browser Windows Communcation
Hi DavidThanks for your posting on SilverLight. It helps me a lot.Now I have a challenge technical problem:I have a HTML page as parent window that plays some video clip. Also people can click a link from that page to create some popup windows (child windows). In the child windows, the same video clip from the parent window should be played (content sync).I can do this using a common XAML file that shared among these windows.Now the challenge for me is: the parent window has video control buttons (like play, pause, stop, ...). How to sync the action controls? For example, if the video is stopped in the parent window, the stop should also apply to all child windows. In other words, how to achieve the action sync?I am thinking if it is possible to change the XAML by the parent window on the fly so that child windows can be updated accordingly. I am not sure if this is possible in Silverlight since it seems to me the XAML is a static object. Can you think of a way to accomplish that or shed some light on the issue?
Thanks! Jay
my response:
you would need hold a reference to the child window and call into it from script so basically when you click a button in the parent it would also go call out to script and the child window. For doing this in IE MSDN has a good reference on working with the IE object model to do this. Start by finding window.open and how to keep a reference and make calls. This however I don't think is very cross browser...
Video Brush in 5 minutes or less
The Video brush is a great way to do some cool special effects. To make a video brush work on you have to have a named media element that you can bind to. That has a bound source. In the sample below we have a source. We have set the element to be muted but play and its opacity is 0 so no one sees it on screen. Then we add some text in a text block app and add a foreground element with a ‘video’ brush. The video brush element is bound to the media element by using the media element name. Using a video brush you can basically make just about anything play video.
<MediaElement Name="MediaElementElement" Source="ImenSample.2.wmv" Canvas.Left="20" Canvas.Top="20" Width="100" Height="100" IsMuted="True" AutoPlay="True" Opacity="0" />
<TextBlock Name="Sample Text" FontSize="20" FontFamily="Verdana" FontWeight="Bold" Canvas.Left="10" Canvas.Top="50" Opacity="1" >PAINT WITH VIDEO <TextBlock.Foreground> <VideoBrush SourceName="MediaElementElement" /> </TextBlock.Foreground> </TextBlock>
When this Xaml is rendered we get the text ‘Paint with video’ that is actually playing the video in the background of the text.
Saturday, January 19, 2008
Uploading/Hosting Encoder Output and other Silverlight Apps into Silverlight Streaming
Now combine this into a zip at the root of the zip and not in a directory. Once you do that log into the Silverlight streaming site and click ‘Manage Application’ and then click ‘Upload a Silverlight Application’.
Give the application and name and browse to your zip. If anything is missing such as a manifest.xml or you have left the html file or something in the file you will get an error.
This window gives you all the information you need to actually link to your uploaded Silverlight Streaming hosted application.
Wednesday, January 16, 2008
Microsoft® Media Encoder™ in 5 minutes or less
From the initial screen we need to import our media file. Go to the file menu and select import, navigate to the video file you want and selection ‘open’. Next we need to select a template which you can do by selecting output and then under the section ‘Job Output’ select one of the templates. You should see a shot from your video in the main area.
Now just click the button in the middle on the bottom and Encoder will go to town. Now this is all good and Media encoder has a bunch of other features around setting up markers and the like but the really key thing is that it gets video content into a nice format that Silverlight can consume.
http://www.microsoft.com/expression/products/overview.aspx?key=media
Silverlight Streaming in 5 minutes or less
A couple of key points of the streaming media service is to enable rapid application development, to be able to deliver quickly streaming media solutions and to be able to provide unlimited scaling should the need arise of your streaming content. The provide admin tools, a REST API, documentation and other tools online for your application development. Currently there are issues with Silverlight all living in the same domain so your bits out on Silverlight streaming need to be ‘all’ your bits but you can embed them in an iframe or separate window and pass in query string values etc. You can check out the service at :
http://silverlight.live.com/ or
http://www.microsoft.com/silverlight/streaming.aspx#1_4
So let us set up an account, starting from Silverligth.live.com.
Next we click on ‘get it free’. At some point a paid service will be available. But for now it is not.
Click the ‘click here’ link to go onto creating our streaming account.
If you don’t have a live id you will have to go through the registration process if you do then you can just login to create your account. In this case I do have such an id and I login and created my Streaming account and then the screen should look like this after logging in.
So when you click ‘I Accept, Create Account’ you then have your account.
This screen show your public account id and account key. You will want to know these later when we upload some content using the Microsoft Media Encoder. You can learn more about Silverlight Streaming at:
http://dev.live.com/silverlight/
So From here we are ready to for my next post on media encoder.
Tuesday, January 15, 2008
Childrens Book...
http://gizmodo.com/photogallery/microserveces08/1000446145
I would love to turn this into a online 'silverlight' app.
Monday, January 14, 2008
Sidebar Gadgets and Email
FILE QUARANTINED
[COMPANY NAME HERE] has removed App.Gadget->App.Gadget.html.js since ithas been found to match the FILE FILTER= unnamed:
I find if I change the file extention to something like .virus then you can get through email filters much better...
Thursday, January 10, 2008
Silverlight Firestarter on MIX Silverlight University
http://www.visitmix.com/University/silverlight/firestarter/
I'm setting in the front row and a couple times you can see the top/back of my head for a second in at least in some of the videos. :) Gotta love Laurence's shameless plug for his book. :)
Vista Sidebar Gadgets, Silverlight and JSON
That being said, there are a number of ways doing old fashioned xml posting to get what you need and you can just parse and do the old fashioned xml thing and if your extra Industrious or need to write out something and the JSON eval thing solves some problems for you (namely less work) then add some begin and end tags and a nice CDATA section and your good...
But if you find a pratical way todo this let me know (JSON, sidebar gadget, vista, silverlight...), I'd love to see a code sample.
Why You Need An Architect
http://blogs.msdn.com/dseven/archive/2008/01/09/why-you-need-an-architect.aspx
Wednesday, January 9, 2008
Silverlight Related Videos
http://video.msn.com/video.aspx/?mkt=en-us&fg=rss&vid=e75f8529-b835-4282-81dc-37e0fa9da251&from=im_default&wa=wsignin1.0
also here is a video of Dan Fernandez talking about Popfly.
http://www.youtube.com/watch?v=xW-EXufLoJg&feature=related
Tuesday, January 8, 2008
Silverlight Propaganda Video...
http://www.youtube.com/watch?v=L-CVlA_-Ogk&NR=1
Tools and the Silverlight Tool-ability Story
I have built some cool things in tools like flash, and by all means this is cool stuff. One of my favorite things about flash in particular is that it runs anywhere on any reasonable browser even my current old fashion PPC phone or my friends Mac or my other friends Linux box. It’s just cool what you can do. But have done my share of action script it really reminds me of a comparison between ‘classic’ ASP and ASP.NET. It is a fundamental shift. Take the Emmy site we did at IdentityMine, this web app had to mix and match video, allow users to play producer suck up numerous feeds running off of Linux box’s using Perl scripts to build out UI elements in Xaml and do drag and drop different kinds of video scrubbing depending on the state of the application and the mode it was in and really provide a rich Web 2.0 experience and by all means there are some things that flash does that Silverlight doesn’t but building this complicated system in 8 days would have been just impossible at least for any dev team I have dealt with in Flash. The tools just are not there.
Granted I probably would not even considered doing it and it really was laughable when first presented to me but hey the money was in line with what it would take to give up 8 days of my life and we had a reputation for doing the impossible so what the heck we would try to do it. And 8 agonizing days later I’ve changed religions as it were and now I’m writing a book and live a breath Silverlight.
Getting back to this tool ability story around Silverlight when I first went to collage I studied photography and computer science for a year and a half. In high school I loved computers but having been music and art I loved beautiful things. I would spend hours rearranging this at my apartment to the point that they would look out of a magazine and I would make my own deco to get the right look and would obsess of design. Photography as opposed to other art allowed me to get to the level or precision in my art that I loved. I’m not Michelangelo so hand drawings and the like I could never get to the level of perfection that my OCD (obsessive compulsive disorder) needed to not send me into some kind of break down.
So in photography I found a home, I loved the idea of lines of composition and building form and contrast and the like but when it came to deciding I felt that my best path was to focus on one, namely computer science and programming in particular. In this case my code became my art but I kept this obsession for perfection in design and when my designer friends got me hooked on using Expression blend on one side and Visual Studio on the other… I was hooked. Truly Zen has been achieved in a superior design tool and Visual Studio at the same time. What more could I want from a toolability story.
Monday, January 7, 2008
Dr. WPF and Silverlight
http://drwpf.com/blog/Home/tabid/36/EntryID/15/Default.aspx
Hacking Jackass Site
http://tkhere.blogspot.com/2007/12/howto-be-real-jackass-and-download.html
Don't get my wrong I still find the 'content' offesive but this is the reason companies have to make things hard for people... case in point now NO ONE with firefox got to see the movie after Movielink found out and good for Movielink for stoping this hack.
Silverlight Golden Globes and Entertainment Tonight
http://www.etonline.com/silverlight/globes65/
Even girls will like it :)
Expression Blend in 5 minutes or less
On the very left hand side is our drawing toolbar for manipulating or creating design in Xaml. When you select an item it will open with a drop-down like menu that you select and then you can do something with it or, like the two arrows at the top, you just select it and go. If you hover over the tool a tool tip word bubble will tell you what it is. Also note for most things, the key board short cuts are the same in Blend as other popular designer environments. You also can select the ‘properties’ tab on the right hand side and you can then see exactly what you can do with Expression Blend. Blend also does a lot of cool stuff that we will talk about later.
And thats pretty much it. :) Oh you can also do animations too but that will be another post.
Friday, January 4, 2008
Silverlight 2.0 Asset Enumeration
So first I created some private properties in the base class:
private Downloader _DL = new Downloader();
private string _AssetEnumerationPath = "http://localhost:58377/TestSite/Assets.zip";
private AssetItem[] _AssetSourceEnum = null;
private string _Errors = string.Empty;
private Canvas _Item1 = null;
public Downloader AssetEnum = null;
So also instead of being industries and using JSON the index file is a CSV in the sample. So bascially I put a CSV file and three bits of xaml for the test project. Then in Page_Loaded we use a downloader, associate a few events and fire off the event at our zip file like this:
_DL.Open("GET", new Uri(_AssetEnumerationPath));
_DL.Completed += new EventHandler(_DL_Completed);
_DL.DownloadFailed += new ErrorEventHandler(_DL_DownloadFailed);
_DL.Send();
in our _DL_Completed then we pull out the index and we know what todo with whats in the file. In this case we save it at the root so it can be used or bound to things and we also can muck around with it in this case we pull out all the Xaml source and put it into an array. Anyway the entire mess can be downloaded as one zip and we don't have to muck with it. Each control we build can go grab what it needs out of the zip or out of some other array we cached at the root.
try
{
Downloader TempDL = sender as Downloader;
string[] NameArray = TempDL.GetResponseText("Assets/index.csv").Split(',');
_AssetSourceEnum = new AssetItem[NameArray.Length];
for (int x = 0; x < NameArray.Length; x++)
{
_AssetSourceEnum[x] = new AssetItem();
_AssetSourceEnum[x].Name = NameArray[x];
_AssetSourceEnum[x].Xaml = TempDL.GetResponseText("Assets/" + NameArray[x].ToString());
}
AssetEnum = TempDL;
}
catch (Exception E)
{
_Errors = E.Message;
}
Thursday, January 3, 2008
Silverlight on the iPhone
I was surprised to see that the phone for the first 3 minutes of the test was doing well with well over 163 concurrent users at a time on the site but at 16971 hits it melted...
http://www.hackingsilverlight.net/samples/iPhone/iphone.JPG
http://www.hackingsilverlight.net/samples/iPhone/IPhoneWebServer.jpg
http://www.hackingsilverlight.net/samples/iPhone/MVI_8003.AVI
http://www.hackingsilverlight.net/samples/iPhone/Site.jpg
as cool as this is Devin did manage to get his iphone recovered but it took some doing. currently though apache is dead and Devin is trying to get it running again...
Wednesday, January 2, 2008
64bit Vista Sidebar Gadget Video Screen Capture Technology...
let me caviate this with the fact that I needed this now to show some one that animation in the side bar of a running gadget using Silverlight.
Camtasia didn't work and shows always always what is underneath and its like the sidebar is not even there...
and yes I googled it but I didn't have more then 10 minutes to make this work.
But since it is sooo funny I thought I would post this...
http://www.HackingSilverlight.net/img/001.JPG
I figure if all else fails and I don't have time, brute force is always good...
:)