Welcome to MSDN Blogs Sign in | Join | Help

Whilst developing the MSCUI Patient Journey Demonstrator, we made use of animation in a number of places to show how the user interface is moving and adapting to the user tasks. Animation is a great tool for showing users how the application changes, allowing them to watch how the content changes size and position, without it ‘clunking’ into place and the user losing sight of everything.

I wanted to create an animation system that allowed us to consistently change a controls size and position, with animation, that was very easy and natural to work with in code. Something I wanted to prevent was the need to duplicate storyboard XAML for each and every control that we wanted to animate.

The approach I decided to take was to create a new class that extended Control- called AnimatedControl. The new class would ultimately add 2 public methods to Control:

·         public void AnimateSize(double width, double height)

·         public void AnimatePosition(double x, double y)

...as well as some additional properties that would allow me to change the duration of the animations.

AnimatedControl works by creating a Canvas in the AnimatedControl constructor which contains a Rectangle and 2 storyboards. The Canvas is created using a XAML string and XamlReader.Load(...). The XAML string used is shown below...

<!--

        Canvas containing rectangle for control animation

      -->

      <Canvas xmlns="http://schemas.microsoft.com/client/2007"

                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

        <Canvas.Resources>

         

          <!-- Size animation storyboard -->

          <Storyboard x:Key="sizeStoryboard" BeginTime="00:00:00">

            <!-- Animates the rectangles width -->

            <DoubleAnimationUsingKeyFrames

              Storyboard.TargetName="animatedElement"                            

              Storyboard.TargetProperty="(FrameworkElement.Width)">

              <SplineDoubleKeyFrame Value="0"

                                    KeyTime="00:00:0.5"

                                    KeySpline="0.528,0,0.142,0.847" />

           

            </DoubleAnimationUsingKeyFrames>

           

            <!-- Animates the rectangles height -->

            <DoubleAnimationUsingKeyFrames

              Storyboard.TargetName="animatedElement"                            

              Storyboard.TargetProperty="(FrameworkElement.Height)">

              <SplineDoubleKeyFrame Value="0"

                                    KeyTime="00:00:0.5"

                                    KeySpline="0.528,0,0.142,0.847" />

            </DoubleAnimationUsingKeyFrames>

          </Storyboard>

         

          <!-- Position animation storyboard -->

          <Storyboard x:Key="positionStoryboard" BeginTime="00:00:00">

            <!-- Animates the rectangles X position in a Canvas -->

            <DoubleAnimationUsingKeyFrames

              Storyboard.TargetName="animatedElement"                            

              Storyboard.TargetProperty="(Canvas.Left)">

              <SplineDoubleKeyFrame Value="0"

                                    KeyTime="00:00:0.5"

                                    KeySpline="0.528,0,0.142,0.847" />

            </DoubleAnimationUsingKeyFrames>

            <!-- Animates the rectangles Y position in a Canvas -->

            <DoubleAnimationUsingKeyFrames

              Storyboard.TargetName="animatedElement"                            

              Storyboard.TargetProperty="(Canvas.Top)">

              <SplineDoubleKeyFrame Value="0"

                                    KeyTime="00:00:0.5"

                                    KeySpline="0.528,0,0.142,0.847" />

            </DoubleAnimationUsingKeyFrames>

          </Storyboard>

        </Canvas.Resources>

        <!-- Hidden rectangle -->

        <Rectangle x:Name="animatedElement"

                   Height="0" Width="0"

                   Canvas.Top="0" Canvas.Left="0" />

      </Canvas>

Once the Canvas has been created, the important elements are fished out and stored in private members. The code below shows creating the canvas from the XAML string below, storing a reference to the storyboards and finally hooking up their completed events...

// Create a canvas from the XAML

Canvas animatedElement = XamlReader.Load(animatedElementXaml) as Canvas;

 

// Pull out the rectangle into a memeber

this.animatedElement = animatedElement.Children[0] as Rectangle;

 

// Pull out the storyboards into a member and hook up completed events

this.sizeAnimation = animatedElement.Resources["sizeStoryboard"]

as Storyboard;

this.sizeAnimation.Completed += new EventHandler(sizeAnimation_Completed);

               

this.positionAnimation = animatedElement.Resources["positionStoryboard"]

                        as Storyboard;

this.positionAnimation.Completed += new EventHandler(positionAnimation_Completed);

 

When AnimateSize or AnimatePosition is called on the control, the corresponding storyboard is kicked off in the Canvas, changing the properties of the rectangle. At the same time, a DispatcherTimer is started that ticks ‘as quickly as possible’ to update the controls size and position to match that of the rectangles, as shown below...

void timer_Tick(object sender, EventArgs e)

{

// If the size is animating, update the controls size

if (this.sizeAnimating)

{

this.Width = this.animatedElement.Width;

this.Height = this.animatedElement.Height;

}

 

// If the position is animating, update the control position

if (this.positionAnimating)

{

Canvas.SetLeft(this, Canvas.GetLeft(this.animatedElement));

Canvas.SetTop(this, Canvas.GetTop(this.animatedElement));

}

}

Now with each tick of the timer, the controls size and position will animate. When the size and position animations have both completed, the timer will stop ticking.

There are some requirements and limitations with my AnimatedControl that I have listed here, but I have suggested some additions too...

·         The Position animation only changes the Canvas.Left and Canvas.Top properties. So, if you control is not in a Canvas (or a panel that derives Canvas), it won’t move. AnimatedControl could indeed be extended however, to animate the controls render transform to move it if it is not in a Canvas...

·         AnimatedControl currently extends Control, so if you wanted an AnimatedControl that extends ContentControl, or UserControl, you would need to copy the code over to a new class - updating then becomes a pain.

·         AnimatedControl only supports one KeyFrame at the moment. Again, this could be updated by adding and removing key frames in the AnimateSize / AnimatePosition methods.

·         You can of course extend AnimatedControl to animate more properties such as Opacity, ScaleTransform, Background color etc.

I have attached a project here that very simply, shows AnimatedControl working on some basic controls (just rectangles really!).

Please enjoy and feedback any additions, bugs etc.

Thanks,

Martin

We have upgraded the Microsoft Health Common User Interface Patient Journey Demonstrator to Beta 2! With the runtime upgrade, we have also made a few fixes and added a feature or two! Here are the highlights...

·         You can now find a video walkthrough and script for the demonstrator on the launch page.

·         We have fixed many of the browser resizing related defects.

·         We have uplifted the design of the Primary Care GP Patient Record page...

·         The chart thumbnails in the patient chart area also include a contrast slider for controlling the opacity of the charts...

 Please stop by www.mscui.net, check it out and share any feedback!

Martin

Big photo zoomy thing 

Jesse Liberty notes the great use of deep zoom to show pictures from this weekend's One Big Weekend Festival from the BBC in the 'One Big Zoomy Photo Thing'. I listened to much of the event on the radio, and saw bits on the telly, and its now great to see the Beeb taking their media one step further. There are lots of little easter eggs to find too, here's one I found earlier...

easter egg

Be warned though, you are likely to spend far too much time just browsing through the collection looking at random crowd members and the beads of sweat on Madonna's forehead!

Check it out here.

I have been fairly quiet for the last few months, and one of the reasons is that I have been working on a Silverlight 2 application, showcasing some future thinking for rich UI in the healthcare space.

The Microsoft Health Common User Interface: Patient Journey Demonstrator is the result of work from a very small team based here in the UK, and we think, is a great example of a Rich Internet Application demonstrating an LOB scenario, but using the power of Silverlight to provide beautiful, meaningful ways of representing incredibly complex data.

PJD

The blurb from the site...

The Microsoft Health Common User Interface (MSCUI) Patient Journey Demonstrator is a vehicle for Microsoft thought leadership in state-of-the-art User Experience for Healthcare applications. It provides exemplar implementations of Microsoft Common User Interface guidance on a Microsoft platform.

It is our showcase for new ideas, experimentation and an artefact for learning and thinking about future developments of the MSCUI program.

 

The demonstrator is actually broken up into 3 separate applications, describing the ‘day-in-the-life’ of a patient from the perspective of a primary care administrator, a GP, and a registrar in a hospital. The UI is completely interactive and you are able to explore, manipulate, layer and scale the patient’s data to create rich visualisations.

Over the next couple of months, I want to blog about some of the things we have built here, how we did it, share snippets of code, and talk more about how we are developing it further.

Some of the cool things in Silverlight 2 that we are already using include (but are not limited to J)...

·         Deep zoom to view complex ECG (electrocardiogram) data

·         Intelligent, scaling layout

·         Data-binding everywhere

·         Animation and media

·         Vector graphics enabling real time manipulation of chart data

A video covering some of this is in the pipeline, so watch this space!

Big thanks to the team invloved in building this...

In the mean time, head over to the site and please share any feedback / ideas either here or on our CodePlex discussion board here.

Martin

 

NOTE FOR USERS OUTSIDE OF THE UK:-

A few users outside of the UK are experience a bug with the Primary Care and Secondary Care demonstrators. The symptom is when they try to launch the either of these demonstrators, they see our default error dialogue stating: "This application has encountered a problem and needs to close. Please, try restarting it. Sorry for any inconvenience."

We have identified that the problem is due to current 'Regional and Language' settings. The reason is because we do various things with the formatting of dates, but have only extensively tested with the UK date format. We have now logged the issue and are aiming to release the demonstrator with the fix when Silverlight 2 Beta 2 ships.

There is a workaround though in the meantime. You can access the second parts of the demonstrator by changing you current language format to 'English (United Kingdom)'. You can access this in Windows Vista via...

Control Panel -> Regional and Langauge Options -> Formats (tab) and selecting 'English (United Kingdom)' from the drop-down.

Many thanks again, and please keep the feedback coming.

 

 

 

Video on channel 9

The latest installment of the Real World WPF series! This time round, Nick Page (DPE), Paul Tallet (MS Developer) and I shoot the breeze about how developers and designers work together in practice. We talk through some of our own experiences and demonstrate some techniques in VS2005 and Blend.

See it here on Channel 9.

content presenter website 

Hi all, whilst I continue to work on Real World WPF videos, including some recent work on WPF/e (!!), take a look at these videos provided by Content Presenter.

 

Very nice.

 Blend box cover

The RC has landed.

Get it here...

 

Since creating the first set of RWWPF (Real World WPF) videos, we had had loads of great suggestions on what else we could be showing. One of the re-occuring themes is about using Blend & WPF for LOB (Line of Business) applications - such as customer account systems, and internal tools.

So, I am adding the post to gather some feedback about what people are specifically interested in seeing. Are folk after 'How to make a data grid?' or 'How do I design and LOB for WPF?' or 'Why would I chose WPF for an LOB app?' or even 'I have an app, how do I make it look cool?'.

Whatever your thoughts, please reply to this post and we will try to capture as many suggestions in an LOB video as possible.

Thanks, Martin

Two very exciting announcements for Adventures today... the first - our Real World WPF Videos are now featured on Channel 9 - all of the links below. Secondly - the second in the series is now availble to download too.

The BSF Showcase (Building Schools for the Future) was an exciting look at enriching learning and school administration through multiple platform and device technologies. I was fortuanate enough to work on this project alongside Carrie Longson and Paul Tallett as a WPF Des/Dev. The 2 videos show a walkthrough the solution we developer, and a 'behind the scenes' look at some of the cool features we added.

Check these videos out now at...

Real World WPF Videos: BSF Showcase

Real World WPF Videos: BSF Showcase, Behind the Scenes

And you can find the first videos here...

Real World WPF Videos: Introduction to Blend (Part 1)

Real World WPF Videos: Introduction to Blend (Part 2)

Real World WPF Videos: Introduction to Blend (Part 3)

Real World WPF Videos: Introduction to Blend (Part 4)

Picture of fish eye in action 

Thought I would share a panel that I and one of my dev friends, Paul Tallett created a while back. I also wanted o show you how you can use it in Blend.

A while back, we wanted to create a panel that would scale up its contents depending how close the mouse pointer was - however - we didn't want the panel to take up anymore width - tricky. This neat effect is similar to the Fish Eye effect, similar to the list of words on 10x10.org. The only difference was, we actually scale down the items furthest away from the mouse, ensuring the panel doesn't require any extra width.

Paul took this spec and created the code for the custom panel (you can read the full development article here) and then handed me a file called FishEyePanel.cs. From here, it was really easy to use in my Blend project. I have attached a .zip file to this post containing an example project and the FishEyePanel.cs file - and so, here are the steps to use a custom panel in your Blend project...

  1. With your Blend project open, go to the Project menu at the top, and click 'Add existing item...'
  2. Now, browse to FishEyePanel.cs, and click 'Open' (you will see in your Project tab that the panel has been added
  3. Go back to the Project menu, and select 'Rebuild Project'
  4. The panel is now ready to use - simply open up the Asset Library from the bottom of the tool box, click on the CustomControls tab and hey presto - you will see the FishEyePanel in there, and ready to use.
  5. Select it and then pop one onto your UI, then put stuff in.

Thing to remember, is that the FishEyePanel is very size aware, and will always scale its contents to fit its space. There are also a couple of properties you can play with found in the Miscellenous properties panel...

FishEye panel properties

AnimationMilliseconds will change the responsiveness of the panel, and magnification will change how large the items scale up by.

Please have a play with the panel, feedback, and let me know if you have created any wack custom panels - would be great to start sharing these with everyone!

Martin

Well, it was a while back that I posted the first Creating a Glass button tutorial. Of course, that was based on the old look of Sparkle, and I have had some feedback recently that the project doesn't run anymore. Also, the completed tutorial never 'made it to press' leaving people with a rather lifeless button.

Well folks - GREAT NEWS - I have finished working on a all new glass button. And what better design to follow than some of the glass buttons in our shiny new OS.

Windows Vista task bar 

The Windows Vista taskbar has some real nice buttons - they are see through and have an internal glow. So, I though I would base my all new complete glass button tutorial on these babies. I also hope there is enough content in the tutorial to help you explore other designs and other controls.

picture of the glass buttons app runing

So, attached to this post are the full instructions for creating the buttons above. I have also attached the finished project if you want to explore what I have done. 

This has been a while coming, so please enjoy!

 

Picture of blend video

Well, it has been a little time since I last posted, and since, there has been a real flurry around WPF - at last, it is shipped! As is Windows Vista and Office 2007.

I have been busy on a number of projects, my learning from which I shall be sharing in the coming weeks. I have also been working with DPE (Developer and Platform Evangelism) to create a series of real world WPF Videos. The videos are focussed on real questions our customers are asking us about WPF and the tools they will need to get into to get the most from the platform.

The first video we shot was a 4 part introduction to using Microsoft Expression Blend (formerly Interactive Designer / Sparkle). Richard Godfrey and I walk through the new look tool and show you how to build a simple, but pretty, data driven application. I have posted the four links for the four parts below, as well as attached the data we used in the sample in case you want to have a crack yourself. It is a pretty simple scenario, so you may want to put your own twist and ideas in the mix.

Enjoy!

Introduction to Blend Part 1: Introduction

Introduction to Blend Part 2: Interface Overview

Introduction to Blend Part 3: 2D Build

Introduction to Blend Part 4: 3D & Effects

 

 

Hi. First off, apologies for the long absence. This was due to some project commitments, however, that is still no excuse. I am happy to say that I am now back, have a heap of cool WPF things to post on - incluiding the final 2 parts to the Button excercise.

In the mean time, I have created a quick sample for you to download and play with. This is thanks to a post provided by Adam Nathan explaining how to get that beautiful glass into a WPF application. Also, check out Tim Sneath's entry on how to extend glass into a WinForms app.

What pleased me most, was how easy it is to do. There is a very simple Helper class that takes in the window, interops with the vista DWM bits and hey presto, you have glass - even better, you can control where the glass appears in the window by playing with margins.

One of the things notes when playing with this in WinForms is that you clicks on the glass fall through, and your window loses focus - not a problem with a WPF app - it catches all clicks!

I have attached the project for you to check out. But it would be great to see some prople really making use of the glass.

Til next time...

Thought I would post up another sample I made a while back - a 3D rotating user interface, similar to that in the Healthcare demo.

In this simple sample, there are two levels of navigation. Moving from level 1 to level 2 will rotate the main user interface away into the background, while the secondary UI appears in the foreground. See below...

As you can see, there was no expense spared in creating a compelling user interface! But this is a very simplified example on how to do this.

Although you should be able to see the technique used in the attached source code, here is basically what is happening... There is a 3D viewport in the background containing a plane mesh. The mesh has a Visual Brush as a diffuse material. When the user navigates to the secondary level of the UI, the main UI's visual is copied onto the meshe's material, the mesh is then rotated into the background. I then move the real main UI, 2000 pixles to the left to get it out of the way. Simple.

Have a play and let me know your thoughts.

Martin

Posted Thursday, June 01, 2006 9:33 AM by Martin Grayson | 4 Comments
Filed under:

Attachment(s): 3DRotate.zip

I came across Harmony yesterday, thanks to a kind e-mail some one sent us. After 5 minutes of using, I am hooked. This is a superb way to look at my music library - its like actually having the CD in my hand!

The creator admits this is similar to Coverflow for OSX, but again, Harmony is a great example of the combination of different media supported by WinFX.

Download now!

Martin

More Posts Next page »
 
Page view tracker