Skip navigation links
Home
Document Center
Blog
Videos
Forum
PhillyXAML.org > Blog

Philly XAML Developer Blog

This blog is run and maintained by John Angelini, Microsoft MVP Client - App Dev. Please feel free to use the commenting functionality provided at the bottom of each post. Post categories are listed on the left as well as some links to other topical Blogs by other MVPs and other independent contributors. You can also subscribe to the RSS Feed for this blog using the provided link.

John Angelini
MVP - Client App Dev

Microsoft MVP - Client App Dev

Silverlight 4 Training Kit as Windows Media Player Playlist
I did something I would like to share and figure this is the best way to do it. I took an email regarding the Silverlight 4 Training Kit and used it to download the local version of the kit. I found out quickly that the links to the videos in the kit still use web-based targets for the video file, so basically the kit wraps everything into one bundle EXCEPT for the actual videos, which are served out by Channel 9.
 
So here is what I did… I took the kit and wrote a small utility that pulled all the video.xml files out of the kit and parsed each one to get the valid URL for the relative video file. I then took that data and dynamically constructed a Windows Media Player WPL Playlist file which is simply a continuously playing list of the video files in the correct order. This way I can start at the beginning and watch it continuously without having to manually navigate to each file as I need it.
 
Anyway, here is the playlist file, for anyone interested. I think this is something people will find highly valuable as I did. The descriptive content in the kit is nice and all, but a little tedious for those who just want to work their way through it. Just thought I would share. This way people can have one item (the playlist) to track, and additionally, the playlist is very easy to distribute and launch by either dropping it in the playlist folder ([%userprofile%]\music\playlists) to be picked up by Windows Media Player or simply double clicked to play it. Also works on Windows Media Player 9 and above, which about 99% of people have by now so it is virtually universal.
 
Content of the playlist file is as follows:
<?wpl version="1.0"?>
<smil>
    <head>
        <meta name="Generator" content="Microsoft Windows Media Player -- 12.0.7600.16415"/>
        <meta name="ItemCount" content="2"/>
        <author/>
        <title>Silverlight 4 Training Kit</title>
    </head>
    <body>
        <seq>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule1-SL4LOB_01_01_Introduction/Silverlight4-SL4BusinessModule1-SL4LOB_01_01_Introduction_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule2-SL4LOB_02_01_RIAServices/Silverlight4-SL4BusinessModule2-SL4LOB_02_01_RIAServices_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule2-SL4LOB_02_02_EditingEntities/Silverlight4-SL4BusinessModule2-SL4LOB_02_02_EditingEntities_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule2-SL4LOB_02_03_ShowingEvents/Silverlight4-SL4BusinessModule2-SL4LOB_02_03_ShowingEvents_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule3-SL4LOB_03_01_Authentication/Silverlight4-SL4BusinessModule3-SL4LOB_03_01_Authentication_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule3-SL4LOB_03_02_MVVM/Silverlight4-SL4BusinessModule3-SL4LOB_03_02_MVVM_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule3-SL4LOB_03_03_Validation/Silverlight4-SL4BusinessModule3-SL4LOB_03_03_Validation_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule3-SL4LOB_03_04_ImplicitStyles/Silverlight4-SL4BusinessModule3-SL4LOB_03_04_ImplicitStyles_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule3-SL4LOB_03_05_RichTextBox/Silverlight4-SL4BusinessModule3-SL4LOB_03_05_RichTextBox_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule4-SL4LOB_04_01_Webcam/Silverlight4-SL4BusinessModule4-SL4LOB_04_01_Webcam_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule4-SL4LOB_04_02_Drop/Silverlight4-SL4BusinessModule4-SL4LOB_04_02_Drop_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule5-SL4LOB_05_01_Grouping/Silverlight4-SL4BusinessModule5-SL4LOB_05_01_Grouping_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule5-SL4LOB_05_02_FluidUI/Silverlight4-SL4BusinessModule5-SL4LOB_05_02_FluidUI_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule5-SL4LOB_05_03_RightMouseClick/Silverlight4-SL4BusinessModule5-SL4LOB_05_03_RightMouseClick_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule6-SL4LOB_06_01_Printing/Silverlight4-SL4BusinessModule6-SL4LOB_06_01_Printing_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule6-SL4LOB_06_02_MultipagePrinting/Silverlight4-SL4BusinessModule6-SL4LOB_06_02_MultipagePrinting_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule7-SL4LOB_07_01_OOB/Silverlight4-SL4BusinessModule7-SL4LOB_07_01_OOB_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule7-SL4LOB_07_02_Toasts/Silverlight4-SL4BusinessModule7-SL4LOB_07_02_Toasts_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule7-SL4LOB_07_03_WindowPlacement/Silverlight4-SL4BusinessModule7-SL4LOB_07_03_WindowPlacement_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule7-SL4LOB_07_04_ElevatedTrust/Silverlight4-SL4BusinessModule7-SL4LOB_07_04_ElevatedTrust_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule8-SL4LOB_08_01_CustomChrome/Silverlight4-SL4BusinessModule8-SL4LOB_08_01_CustomChrome_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule8-SL4LOB_08_02_WindowClosingEvent/Silverlight4-SL4BusinessModule8-SL4LOB_08_02_WindowClosingEvent_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule8-SL4LOB_08_03_OOBSilentInstall/Silverlight4-SL4BusinessModule8-SL4LOB_08_03_OOBSilentInstall_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule8-SL4LOB_08_04_XapSigning/Silverlight4-SL4BusinessModule8-SL4LOB_08_04_XapSigning_kit.wmv"/>
            <media src="http://ecn.channel9.msdn.com/o9/learn/videos/Silverlight4-SL4BusinessModule8-SL4LOB_08_05_MEF/Silverlight4-SL4BusinessModule8-SL4LOB_08_05_MEF_kit.wmv"/>
        </seq>
    </body>
</smil>
Video: How to Build a Silverlight Media Player That You Can Use in Any Website
This post is the first video post on the site, and covers how to build a Silverlight Media Player that you can use in any web page whether it be static HTML, ASP, ASP.NET, SharePoint, PHP, whatever. More specifically, it shows how I built the media player you will use if you choose to watch this video tutorial!
 
My particular implementation uses SharePoint (MOSS 2007), where I am hosting the script file, master page, CSS stylesheet, and the player .xap file file as well as all of my WMV media files. After all, is this not what SharePoint was designed for? I do however use a third-party Silverlight media player control, provided by ComponentOne, but in a subsequent post I will describe how this can be easily modified to use the Smooth Streaming Media Player from the Silverlight Media Framework. This way, this can be an entirely free solution to create for your own websites.
 
We are really just creating a wrapper for an existing media player control. We are NOT writing any kind of playback functionality, full-screen capabilities, volume control, or even providing any kind of UI, short of our one single third-party control that occupies our entire default grid. After watching the video or downloading the code, it should be pretty easy to modify this shell to fit your particular player needs.
 
So, how does it work? Basically, we are going to use jQuery and some very simple markup to easily add media to blog posts, articles, whatever, wherever, whenever. Our script takes 2 attributes of a div tag we add to our page as a placeholder, and dynamically generates the correct object and param tags for displaying a single Silverlight player file, initialized with whatever Title and WMV file URL we pass it. It then uses jQuery to insert some templated markup right into the DOM as the content of the placeholder div we added.
 
One of the limitations I encountered with my personal solution, was that SharePoint strips out object and param tags from content fields that use the HTML Editor... so no matter what I did, I could not add my player to a page as markup in a content field. From a Content Editor Web Part, I could add the correct tags, but not as content in an HTML field.
 
With this solution, I can easily add a div tag with valid attributes that wont be stripped out, and when the page loads it takes that info in $(document).ready() and inserts instances of the player pointing to the correct Video URL wherever a div with a certain class is found! Minimal markup, powerful reuse!
 
In my implementation, the script is embedded in my master page and works on all pages in the SharePoint Site that use that master page. Because its only javascript, jQuery, Silverlight and CSS, it will work anywhere where we have the ability to execute the javascript calls!
 
Now, I vaguely remember someone mentioning a video in here somewhere?
Office 2010, Project 2010, Visio 2010 Available Now on TechNet and MSDN
You heard it here first!.... perhaps.
Extending FrameworkElement 4: Saving a Window or Control as an Image

The final article in this series will expand on the previous article on how to save a window or control as an image. Since this is a pretty cool feature to have for screenshots and such, I decided to bake this functionality into the FrameworkElement class itself with a couple of cool overloads.

First we need to add a reference to System.Drawing, and some using statements as follows so it doesnt look like Christmas when we paste our code and everything is lit up in red!

using System.IO;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Win32;

Next, lets add our code to FrameworkElementExtender.cs. We have quite a few overrides here that basically correspond to the possible parameter combinations of resolution, output path and a flag for whether to fail gracefully or raise an exception in the event an error occurs.

        #region SaveImage Extension Methods
        /// <summary>
        /// Save this FrameworkElement as an image in a file specifying 
        /// X and Y resolution independently
        /// </summary>
        /// <param name="fe">The FrameworkElement being extended</param>
        /// <param name="JpegFilepath">Path to save the image file</param>
        /// <param name="DPIX">X Resolution in dots per inch</param>
        /// <param name="DPIY">Y Resolution in dots per inch</param>
        /// <param name="FailGracefully">True to return false when an Exception 
        /// is thrown; False to rethrow the inner Exception for handling from your code</param>
        /// <returns>Return true if save operation succeeds</returns>
        public static bool SaveImage(
            this FrameworkElement FE, 
            string JpegFilepath, 
            double DPIX, 
            double DPIY, 
            bool FailGracefully)
        {
            if (!JpegFilepath.EndsWith(".jpg"))
            {
                if (!FailGracefully)
                {
                    throw new Exception("Filename must end in .jpg");
                }
                else
                {
                    return false;
                }
            }
            try
            {
                int width = (int)FE.ActualWidth;
                int height = (int)FE.ActualHeight;
                VisualBrush vb = new VisualBrush(FE);
                Border bRender = new Border();
                ;

                bRender.Width = width;
                bRender.Height = height;
                bRender.Background = vb;

                RenderTargetBitmap rtb = new RenderTargetBitmap(
                      width,
                      height,
                      DPIX,
                      DPIY,
                      PixelFormats.Pbgra32);
                rtb.Render(bRender);

                JpegBitmapEncoder jbe = new JpegBitmapEncoder();
                jbe.QualityLevel = 100;
                jbe.Frames.Add(BitmapFrame.Create(rtb));
                MemoryStream ms = new MemoryStream();
                jbe.Save(ms);
                System.Drawing.Image proxy = System.Drawing.Image.FromStream(ms);
                proxy.Save(JpegFilepath);
                return true;
            }
            catch (Exception x)
            {
                if (!FailGracefully)
                {
                    throw x;
                }
                else
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Save this FrameworkElement as an image in a file specifying 
        /// X and Y resolution independently
        /// </summary>
        /// <param name="fe">The FrameworkElement being extended</param>
        /// <param name="JpegFilepath">Path to save the image file</param>
        /// <param name="DPIX">X Resolution in dots per inch</param>
        /// <param name="DPIY">Y Resolution in dots per inch</param>
        /// <returns>Return true if save operation succeeds</returns>
        public static bool SaveImage(
            this FrameworkElement FE, 
            string JpegFilepath, 
            double DPIX, 
            double DPIY)
        {
            return SaveImage(FE, JpegFilepath, DPIX, DPIY, true);
        }
        /// <summary>
        /// Save this FrameworkElement as an image in a file using the 
        /// same resolution for both and X and Y
        /// </summary>
        /// <param name="fe">The FrameworkElement being extended</param>
        /// <param name="JpegFilepath">Path to save the image file</param>
        /// <param name="DPIXY">X and Y Resolution in dots per inch</param>
        /// <returns>Return true if save operation succeeds</returns>
        public static bool SaveImage(
            this FrameworkElement FE, 
            string JpegFilepath, 
            double DPIXY)
        {
            return SaveImage(FE, JpegFilepath, DPIXY, DPIXY, true);
        }
        /// <summary>
        /// Save this FrameworkElement as an image in a file using the 
        /// same resolution for both and X and Y
        /// </summary>
        /// <param name="fe">The FrameworkElement being extended</param>
        /// <param name="JpegFilepath">Path to save the image file</param>
        /// <param name="DPIXY">X and Y Resolution in dots per inch</param>
        /// <param name="FailGracefully">True to return false when an Exception 
        /// is thrown; False to rethrow the inner Exception for handling from your code</param>
        /// <returns>Return true if save operation succeeds</returns>
        public static bool SaveImage(
            this FrameworkElement FE, 
            string JpegFilepath, 
            double DPIXY, 
            bool FailGracefully)
        {
            return SaveImage(FE, JpegFilepath, DPIXY, DPIXY, FailGracefully);
        }
        /// <summary>
        /// Save this FrameworkElement as an image in a file with DPIX and DPIY set to 96
        /// </summary>
        /// <param name="fe">The FrameworkElement being extended</param>
        /// <param name="JpegFilepath">Path to save the image file</param>
        /// <returns>Return true if save operation succeeds</returns>
        public static bool SaveImage(
            this FrameworkElement FE, 
            string JpegFilepath)
        {
            return SaveImage(FE, JpegFilepath, 96);
        }
        /// <summary>
        /// Save this FrameworkElement as an image in a file with DPIX and DPIY set to 96
        /// </summary>
        /// <param name="fe">The FrameworkElement being extended</param>
        /// <param name="JpegFilepath">Path to save the image file</param>
        /// <param name="FailGracefully">True to return false when an Exception 
        /// is thrown; False to rethrow the inner Exception for handling from your code</param>
        /// <returns>Return true if save operation succeeds</returns>
        public static bool SaveImage(
            this FrameworkElement FE, 
            string JpegFilepath, 
            bool FailGracefully)
        {
            return SaveImage(FE, JpegFilepath, 96, FailGracefully);
        }
        /// <summary>
        /// Save this FrameworkElement as an image in a file with DPIX and DPIY set to 96
        /// </summary>
        /// <param name="FE">The FrameworkElement being extended</param>
        /// <returns></returns>
        public static bool SaveImage(
            this FrameworkElement FE)
        {
            return SaveImage(FE, true);
        }
        /// <summary>
        /// Save this FrameworkElement as an image in a file with DPIX and DPIY set to 96
        /// </summary>
        /// <param name="FE">The FrameworkElement being extended</param>
        /// <param name="FailGracefully">True to return false when an Exception 
        /// is thrown; False to rethrow the inner Exception for handling from your code</param>
        /// <returns>Return true if save operation succeeds</returns>
        public static bool SaveImage(
            this FrameworkElement FE, 
            bool FailGracefully)
        {
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "JPEG (*.jpg)|*.jpg";
            if ((bool)dlg.ShowDialog())
            {
                return SaveImage(FE, dlg.FileName, FailGracefully);
            }
            return false;
        }
        #endregion

The first method override is our main worker method. The code is covered in the article mentioned above, so will not be covered here. The only additions are around correctly populating our parameters with our extended elements properties. Like the last article in this series, the remainder of the overrides provide recursive wrappers for passing default values eventually to this method.Since we are using this library in a XAML world, we will use 96 as our default dpi as per best practices, since XAML uses 96 Device Independent Units for displaying graphics. This allows for easy conversion.

Since there are a rather large number of overrides, that really only call one another, I will leave it up to you to come up with a way to test these.

Now that this series is complete, the final version of the source code will be available for download from the series landing page. Remember these extension methods apply to all classes that derive from FrameworkElement so you can easily provide screenshot capabilities to any control in your application without having to save the entire window. The parameterless form of the method isintended for just this purpose, and even provides a SaveFileDialog for you when called.

Extending FrameworkElement 3: Animating Fades on User Interface Elements
The third installment of this series will cover creating an overloaded method that will allow us to fade a control to a specific opacity, as well as give us the ability to fade in or out. A scenario for this might be to fade a window out, open a dialog, and after the dialog call, fade the window back in.
 
This is a scenario we see on the Web all the time, and more recently in client applications to indicate synchronous, blocking processing where the application needs to "pause" its UI layer, indicating it is disabled, and more importantly creating focal emphasis on the dialog element. We visit a page, click Login, the window disables and fades, a new window opens, we log in, the login window closes, and the parent window fades back in and its back to business as usual.
 
Another use for this method would be to facilitate some simple animations of UI elements that are displayed dynamically based on application context. An example might be a client application that has a datagrid that appears or disappears depending on whether or not there is data. While still allowing the grid to occupy the same screenspace whether it is hidden or not, we can provide some enhanced interactivity by fading that grid in or out when there is data instead of instantaneously popping it on or off the screen. This creates a more dynamic feel to the application and really works to richen our user experience.
 
We will program the option to fade in or out with several overrides, comprised of combinations of the items below:
  • Fade to a specific opacity
  • Fade over a fixed duration of time
  • Fade based on direction (In, Out)

The first thing we need to do is add a new item to our library. Create an empty code file named Enums.cs and add the following code. We do not need any using statements since this file will only contain an enumerator used for determining fade directionality.

namespace PX.Samples.FrameworkElementExtender
{
    public enum Fade { In, Out };
}

With our enumerator in place, we add the following method overrides to FrameworkElementExtender.cs. The comments for each method indicate the specific combination of the above features the method provides. Also note the string constant fadeDuration, which is used as a default for some of the overrides.

        #region FadeInOut Extension Method
        private const string fadeDuration = "0:0:0.5";
        /// <summary>
        /// Fades the FrameworkElement in or out over a specified duration
        /// </summary>
        /// <param name="elUI">The FrameworkElement being extended</param>
        /// <param name="FadeDirection">Direction to fade, In or Out</param>
        /// <param name="Duration">Valid TimeSpan string in the format 
        /// d.h:m:s.sss where h:m:s is required</param>
        public static void FadeInOut(this UIElement elUI, Fade FadeDirection, string Duration)
        {
            TimeSpan duration;
            if (!TimeSpan.TryParse(Duration, out duration))
            {
                throw new Exception(string.Format("{0} is not a valid value for Duration", Duration));
            }
            if (FadeDirection == Fade.Out)
            {
                FadeInOut(elUI, .03, Duration);
            }
            else
            {
                FadeInOut(elUI, 1, Duration);
            }
        }
        /// <summary>
        /// Fades the FrameworkElement in or out over the default duration
        /// </summary>
        /// <param name="elUI">The FrameworkElement being extended</param>
        /// <param name="FadeDirection">Direction to fade, In or Out</param>
        public static void FadeInOut(this UIElement elUI, Fade FadeDirection)
        {
            FadeInOut(elUI, FadeDirection, fadeDuration);
        }
        /// <summary>
        /// Fades the FrameworkElement to a specific opacity over a specified duration
        /// </summary>
        /// <param name="elUI">The FrameworkElement being extended</param>
        /// <param name="Opacity">The normalized opacity value between 0.0 and 1.0</param>
        /// <param name="Duration">Valid TimeSpan string in the format 
        /// d.h:m:s.sss where h:m:s is required</param>
        public static void FadeInOut(this UIElement elUI, double Opacity, string Duration)
        {
            TimeSpan duration;
            if (!TimeSpan.TryParse(Duration, out duration))
            {
                throw new Exception(string.Format("{0} is not a valid value for Duration", Duration));
            }
            DoubleAnimation da;
            da = new DoubleAnimation(Opacity, duration);
            elUI.BeginAnimation(Window.OpacityProperty, da);
        }
        /// <summary>
        /// Fades the FrameworkElement to a specific opacity over the default duration
        /// </summary>
        /// <param name="elUI">The FrameworkElement being extended</param>
        /// <param name="Opacity">The normalized opacity value between 0.0 and 1.0</param>
        public static void FadeInOut(this UIElement elUI, double Opacity)
        {
            FadeInOut(elUI, Opacity, fadeDuration);
        } 
        #endregion

Worth noting is the usage of the Fade enumerator to provide our logic switch for fading in or out. Additionally, the default fade out value is to an opacity of .03 or 3%. This provides a nice barely visible ghost of our control executing the method. This would the object elUI in the above code.

Lets take a look at the one override that really does all of the work, the override that takes a specific opacity and a specific duration, which is third in our code above. This override creates a DoubleAnimation object, and sets its To value and Duration using the respective constructor overload. We are then calling the BeginAnimation invoker on the extended element, passing in the DependencyProperty we wish to animate (UIElement.OpacityProperty) and the AnimationTimeline object that defines the animation (our DoubleAnimation object).

Also worth noting is that the additional method overrides are really just recursive versions of one another, using the fadeDuration string constant as a default when omitted. This combination of overrides covers all possible combinations of usage, which we will take a look at in just a moment.

First off, lets fix those ugly red errors in our code, by adding a using statement for System.Windows.Media.Animation so we can get to the DoubleAnimation object. Lets build to make sure we have made it this far without any errors. Build Succeeded! My two favorite words!

Now that we have a working library, lets modify our test harness application to use it. First open winMain.xaml in either Visual Studio or Expression Blend and double-click the top button to add an event handler. If you have been following along, the handler should be named btnSample_Click.

We are going to use the rectangle in the middle of our screen to test the different overrides. We are going to create a simple counter based loop so that each time we click the button we can step through the method calls and increment our counter. Add the counter variable indicated below as well.

        private int counter = 0;
        private void btnSample_Click(object sender, RoutedEventArgs e)
        {
            switch (counter)
            {
                case 0:
                    counter++;
                    rectSample.FadeInOut(Fade.Out, "0:0:5");
                    break;
                case 1:
                    counter++;
                    rectSample.FadeInOut(Fade.In, "0:0:2.5"); 
                    break;
                case 2:
                    counter++;
                    rectSample.FadeInOut(Fade.Out);
                    break;
                case 3:
                    counter++;
                    rectSample.FadeInOut(Fade.In);
                    break;
                case 4:
                    counter++;
                    rectSample.FadeInOut(.5, "0:0:5");
                    break;
                case 5:
                    counter++;
                    rectSample.FadeInOut(1, "0:0:5");
                    break;
                case 6:
                    counter++;
                    rectSample.FadeInOut(.25);
                    break;
                case 7:
                    counter = 0;//Reset our counter
                    rectSample.FadeInOut(1);
                    break;
                default:
                    throw new Exception("This should never happen");
            }
        }

Now lets run our application by hitting F5 or Ctrl-F5. Now each time we click the button labeled Test Button 1 we will see each call as we click. We do not have any type of animation flow control in place in this simple sample so be sure to let the animations finish completely to avoid any unintended effect. Pay attention to which calls are being made in terms of fade direction and duration.

1 - 5 Next

 ‭(Hidden)‬ Admin Links