Announcing: Silverlight "Power Seminar"

Kings Hill Conference & Training Centre (location)
Friday November 28th, 2008 (10am-1pm)

I am presenting this seminar in Kings Hill on November 28th – should be a good overview and I will be drilling into some depth with the demo’s later on. Hope you can make it.

Marketing info and content below ;-)

 

Don't miss this opportunity for your company to get a great insight into this exciting technology and how it can affect your business

Special Offer
  • Silverlight Power Seminar only £98+vat
  • Muffins and Danish pastries included!
  • Book by Friday 14th November and bring a colleague for half price: £49+vat
  • Free CD packed with resources for every delegate PACKED with resources for every delegate

9:30 Registration, Danish Pastries, Muffins, Coffee and Tea

10:00 - 11:00  Executive Overview.

  • What is Silverlight?
  • Key drivers and barriers
  • Market placement and competing technologies (e.g. Flash, Ajax)
  • What it takes to build Silverlight applications
  • How will it affect my business?
  • Silverlight strategic futures (the Microsoft Client: Desktop, Web and Mobile), Alexandria.

11:00 - 11:10  Break (tea and coffee)

11:10 - 12:00 Silverlight for Designers

  • What can you do with Silverlight?
  • What can't you do with Silverlight?
  • What is Xaml?
  • Silverlight design tools (Expression suite, export from other tools such as Illustrator)
  • How you can work more closely with Developers

12:00 - 12:10  Break (tea and coffee)

12:10 - 13:00 Silverlight for Developers

  • Silverlight managed code development in Visual Studio
  • Understanding how Silverlight fits into a n-tier development
  • Working with Data
  • Understanding the HtmlBridge
  • Other Silverlight features (threading, isolated storage...)

Book Now!

Technorati Tags:

Silverlight 2 vs. Asp.Net Ajax

Shameless plug for my new blog:  silverlightforbusiness.net

And the latest article:  Silverlight 2 vs. Asp.Net Ajax

Cheers

Ian

Technorati Tags: ,

VS2010 – two screenshots to warm the hearts of TDD fans

When you are doing TDD you want more more than the Generate Method Stub functionality in VS2008 – you want to be able to generate stubs for anything!

Well VS 2010 comes to the rescue (as it should since it states they are targeting TDD as mainstream for this release)

image

And if you click Generate Other:

image

Nice one!

Technorati Tags: ,

Cheers

Ian

New SilverlightForBusiness.net Blog

Most developers and managers are impressed with Silverlight when they first see it, and most are keen see what it can do.  Most see the immediate benefits for rich web based UI, and often there is a comparison drawn with Flash (“Is Silverlight a Flash Killer?”).  However the business case is not always clear to them.

I believe Silverlight offers a tremendous platform for Business Applications

It’s not just the richness of the UI and the wide reach and lower maintenance of the web deployment, but the fact that it is built in managed .net code, with a rich framework that makes many powerful capabilities much easier (threading, isolated storage, wcf services, data binding, linq to name a few)

So I have started a new blog over on silverlightforbusiness.net - this blog will be an exploration of using Silverlight for Enterprise/Business applications. 

Some of the topics I will be exploring (in no particular order)

  • User productivity  - can a well design UI improve productivity for the user?
  • Silverlight competitors/alternatives  – Ajax, Flash Java FX etc..
  • n-tier architecture with Silverlight UI
  • Working with data (moving, shaping, binding, validating, paging)
  • Services
  • Html Interaction
  • Where to put your business logic
  • Security
  • Future directions

To kick things of, take a look at this video from Jamie Cool from the recent PDC – it introduces many of the topics above and also a sneak peak of the next version of Silverlight (code name Alexandria) which provides a richer Business Logic Framework:

image

http://channel9.msdn.com/pdc2008/PC11/

Cheers

Ian

Creating Reusable Animations in Silverlight 2

I answered a post on the Silverlight forums recently about creating reusable animations for an Image, and thought that it was worth a blog entry to expand on it a little.

I am looking here at two common approaches to creating reusable animations within a single project:

  1. Create the animation in xaml (using Blend) on one element and then change the target in code.  This is easier to do but means you can only play one animation at a time (because only one animation actually exists)

  2. Create the animation purely in code.  This means you can create as many as you want and have them all playing at the same time, and writing the code gives you more control over changing the animation conditionally at run time.

Of course you can also have a combination of the two (so you could create the animation in blend, then create a copy of it in code and manipulate it)

Using the Xaml Approach

Here's an example of the first approach.  This is the Xaml created by recording an animation in Blend against "Image1".   Notice that I have given the two DoubleAnimationUsingKeyFrames elements names (GrowImageScaleXAnimation and GrowImageScaleYAnimation) so that it is easy to change their properties in code later on:

 

<Storyboard x:Name="GrowImage" AutoReverse="True">
            <DoubleAnimationUsingKeyFrames 
                x:Name="GrowImageScaleXAnimation" 
                BeginTime="00:00:00" 
                Storyboard.TargetName="Image1" 
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                <SplineDoubleKeyFrame 
                    KeyTime="00:00:00.5000000" 
                    Value="1.1" 
                    KeySpline="0.24,0.75,0.9,1"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames 
                x:Name="GrowImageScaleYAnimation" 
                BeginTime="00:00:00" 
                Storyboard.TargetName="Image1" 
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                <SplineDoubleKeyFrame 
                    KeyTime="00:00:00.5000000" 
                    Value="1.1" 
                    KeySpline="0.24,0.75,0.9,1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>

So if you have two images like this:

<Image x:Name="Image1" Width="100" Height="100" Source="Images/beta.jpg" 
           MouseLeftButtonUp="Image_MouseLeftButtonUp" RenderTransformOrigin="0.5,0.5"> <Image.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Image.RenderTransform> </Image> <Image x:Name="Image2" Width="100" Height="100" Source="Images/beta.jpg"
           MouseLeftButtonUp="Image_MouseLeftButtonUp" RenderTransformOrigin="0.5,0.5"> <Image.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Image.RenderTransform> </Image>

 

You can write the following code to play the animation on either one:

private void PlayXamlImageAnimation(string ImageName)
{
    GrowImage.Stop();
    Storyboard.SetTargetName(GrowImageScaleXAnimation, ImageName);
    Storyboard.SetTargetName(GrowImageScaleYAnimation, ImageName);
    GrowImage.Begin();
}

Using the Pure Code Approach

For the pure code approach you create the animation in code and attach it to the image.  Here is my code to create the animation:

private Storyboard CreateAnimation(DependencyObject image)
{
    Storyboard board = new Storyboard();
    board.AutoReverse = true;

    DoubleAnimationUsingKeyFrames scaleXAnim = 
           GetAnimation(image, "(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"); DoubleAnimationUsingKeyFrames scaleYAnim =
           GetAnimation(image, "(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"); board.Children.Add(scaleXAnim); board.Children.Add(scaleYAnim); return board; } private DoubleAnimationUsingKeyFrames GetAnimation(DependencyObject image,string propertyPath) { DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames(); animation.BeginTime = TimeSpan.FromSeconds(0); Storyboard.SetTarget(animation, image); Storyboard.SetTargetProperty(animation, new PropertyPath(propertyPath, new object[0])); SplineDoubleKeyFrame spline = new SplineDoubleKeyFrame(); spline.KeyTime = TimeSpan.FromSeconds(0.5); spline.Value = 1.1; KeySpline keySpline = new KeySpline(); keySpline.ControlPoint1 = new Point(0.24, 0.75); keySpline.ControlPoint2 = new Point(0.9, 1); spline.KeySpline = keySpline; animation.KeyFrames.Add(spline); return animation; }

This produces exactly the same animation that was shown in the Xaml above, but is quite a bit more work (in truth I still find it easier to record this in Blend, then manually convert it to code from the Xaml)  The benefit is that we have more control and we can get as many animation instances we want so that we can have them all playing at the same time on different images.  So in this example I create two Storyboards and then instantiate them against my images in the constructor for the page:

 

Storyboard image1Animation;
Storyboard image2Animation;

public Page()
{
    InitializeComponent();
    image1Animation = CreateAnimation(Image1);
    image2Animation =  CreateAnimation(Image2);

}

Then it is simple a matter of playing the animations when needed.

You can download the source from my sky drive:

Cheers

Ian

Technorati Tags: ,,

VB.Net and C# to draw closer together for v4

There are some interesting improvements for C# 4 as detailed here, but I was struck by the following comment in that document.

A secondary theme is co-evolution with Visual Basic. Going forward we will aim to maintain the individual character of each language, but at the same time important new features should be introduced in both languages at the same time. They should be differentiated more by style and feel than by feature set.

I think this will be a surprise for many vb programmers who have seen a gradual move away from their language to c# for many demos and resources, and a growing frustration that they are being left behind.

Of course the IDE needs to have the same theme of co-evolution for this to work well – refactoring for example is painfully missing in VB.Net for VS 2008.

So this is good news for mixed language development teams and for general resource management within the industry but the proof will be in the pudding for VS 2010 – I look forward to seeing it.

Cheers

Ian

Technorati Tags: ,

Understanding Azure (no marketing)

These two videos really brought it home to me:

image


Manuvir Das: Introducing Windows Azure

 

And :

http://channel9.msdn.com/posts/Charles/Steve-Marx-Windows-Azure-for-Developers/

Entry Media

Cheers

Ian

Technorati Tags:

Simple jQuery Asp.net Ajax Example

With the news that Microsoft are going to include jQuery in future asp.net ajax releases I thought I’d have a go at a very simple example to see how it all fits together.

The objective here is to have a wcf ajax service that returns an object and a simple ui that is controlled by jquery code and to illustrate:

  • The two libraries work well together without any immediate conflicts
  • It is simple to set-up and use

First I created a new .net 3.5 Asp.Net web site and added an Ajax-enabled WCF Service to it.  I wanted to return more than a string from the service so I created the following Person class:

[DataContract]
public class Person
{

    [DataMember]
    public int PersonId { get; set; }
    [DataMember]
    public string FirstName { get; set; }
    [DataMember]
    public string LastName { get; set; }
}

Here is the service that I created:

[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service
{
    [OperationContract]
    public Person GetPerson()
    {
        return new Person() { PersonId = 1, FirstName = "Fred", LastName = "Bloggs" };
    }
}

I downloaded JQuery and added it to my project then in my default.aspx web page added a script manager that referenced it and my service:

<asp:ScriptManager ID="ScriptManager1" runat="server">
    <Scripts>
        <asp:ScriptReference Path="~/js/jquery-1.2.6.js" />
    </Scripts>
    <Services>
        <asp:ServiceReference Path="~/Service.svc" />
    </Services>
</asp:ScriptManager>

So far so good.  In terms of UI I wanted only a button and a div to put the results in:

<button id="button1">Get Person</button> 
<div id="results"></div> 

Now to write some client side code.  In this example I have used the pageLoad event that is provided by asp.net ajax to wire up the event handler for the button using some jQuery code.  So when button1 is clicked the GetPerson method is called on the service.  Service.GetPerson is provided by asp.net ajax framework when we referenced the service in the ScriptManager, but the $(“button1”).bind is provided by jQuery.  So far jQuery hasn’t provided much value, so I added a little animation to the result processing.  Simply hiding the div tag, adding some html, then fading it back in over 0.5 second.

<script type="text/javascript">

    function pageLoad() {
        $("#button1").bind('click', function(event) { Service.GetPerson(onSuccess); });
    }

    function onSuccess(result) {
        
        $("#results").hide().html(result.PersonId + ' ' + 
              result.FirstName + ' ' + result.LastName).show(500); } </script>

You can download the full project from here:

UPDATE: Nice series of Ajax and JQuery examples from here

Cheers

Ian

Technorati Tags: ,

Silverlight 2 Enterprise application framework

If you have wondered about how Silverlight 2 will fit into your enterprise application, then Rockford Lhotka has just strengthened the (in my opinion) inevitable case for Silverlight 2 becoming the de-facto standard for web based enterprise apps over the next few years.

He has just ported his popular Windows CLSA.Net framework to Silverlight, and has maintained a coherence between Windows and Silverlight.  As he says:

The commonality between the two framework implementations allows sharing of business object code between .NET and Silverlight, while the differences allow you to exploit the power of the two different platforms.

The CLSA (Component-based Scalable Logical Architecture) is widely used and is a good example of an OO design with “smart objects”; it has many rich features such as support for DataBinding, object status tracking, validation, LINQ support, asynchronous data access and n-level undo.  However the important thing for me is the recognition that Silverlight provides a powerful way to build ui for business applications and is not just a way to add “glitz”.  Even if you do not use CLSA I would recommend taking a look at Rockfords framework to give you an insight into the capabilities of Silverlight 2.

Rockford Lhotka - Overview of CSLA .NET 3.6 for Windows and Silverlight

Cheers

Ian

Technorati Tags: ,

Using the VE Asp.Net Control

If you are interested in using the new Virtual Earth Asp.Net control, then Soul Solutions have created a nice set of examples (with downloadable source) that are well worth exploring.

Having the VE control as well as the JS control (and the Silverlight developments such as Views and the forthcoming managed control) really widens your options for using Virtual Earth. 

This server control is well designed, offers both client and server support and takes advantages of the Extenders model so implementation can be really easy.  Definitely worth a look.

image

Cheers

Ian

Technorati Tags: ,