New Update For Article Creating, Encoding and Delivering Silverlight Streaming Screen Capture Videos

January 28, 2008

Silverlight Video

1-28-08:  I have updated the Code Project article Creating, Encoding and Delivering Silverlight Streaming Screen Capture Videos again.

I updated the article download to include profiles with 10 second buffers instead of the default 5 second buffers.  I’m seeing better results with this new buffer setting since the Microsoft Silverlight Streaming service is slow at times.

I also added more references to Silverlight resources.

Hope you enjoy the article and begin making your own killer videos for your blog and articles!

Just a grain of sand on the worlds beaches.


Updated Article Creating, Encoding and Delivering Silverlight Streaming Screen Capture Videos

January 27, 2008

Silverlight Video

I have just updated the Code Project article Creating, Encoding and Delivering Silverlight Streaming Screen Capture Videos.

I added a new section and video on how to use Microsoft Expression Encoder to create screen capture videos.  There is a new article download that has the required profle that Expression Encoder can use to encode screen capture videos that are compatible with the free Microsoft Silverlight Streaming service.

The in-depth article is on the process of creating screen capture videos for your Code Project articles and for your blog.

The article covers creating, encoding, packaging, uploading and consuming screen cast tutorial videos.  The article also provides three high quality tutorial videos on this topic.

Hope you enjoy the article and begin making your own killer videos for your blog and articles!

Just a grain of sand on the worlds beaches.


Mole Now Has Silverlight Videos!

January 26, 2008

Mole

Silverlight Icon

I have just upgraded all the Mole vidoes to the new Silverlight Streaming videos.  The quality of these videos is just plain awesome!

There is also a new video on using Mole with Windows Communication Foundation (WCF) that was recorded using the new screen size of 1024 x768. 

You can view the new videos either at:

If you want to learn how to create you own screen capture videos check out my Code Project article, Creating, Encoding and Delivering Silverlight Streaming Screen Capture Videos. This article provides detailed instructions for creating videos and how to use them in your articles, web pages or blog entries.

Hope you enjoy and use Mole!

Just a grain of sand on the worlds beaches.


Going To Mix08 Las Vegas, 5-7 March 2008

January 25, 2008

Mix08
I received great news today.  I’ll be going to Mix08 in Las Vegas, 5-7 March 2008! 

Really looking forward to this conference.  Finally get to meet many developers and Microsoft folks face to face. 

This will be my first major Microsoft event other than MSDN events, so I’m pretty juiced.

Let me know if you’ll be there so we can hook up.

Mix Web Site: http://visitmix.com/2008/default.aspx

Just a grain of sand on the worlds beaches.


Creating, Encoding and Delivering Silverlight Streaming Screen Capture Videos

January 25, 2008

Silverlight Video

I have just posted the following article on Code Project:

Creating, Encoding and Delivering Silverlight Streaming Screen Capture Videos

This is an in-depth article on the process of creating screen capture videos for your Code Project articles and for your blog.

The article covers creating, encoding, packaging, uploading and consuming screen cast tutorial videos.

The article also provides two high quality tutorial videos on this topic.

Hope you enjoy the article and begin making your own killer videos for your blog and articles!

Just a grain of sand on the worlds beaches.


Now Using New Silverlight Videos

January 24, 2008

Silverlight Video
You must have Silverlight 1.0 installed on your computer. Takes about a minute or so.

I have just updated the following post and Code Project article with new Silverlight videos.  These are MUCH better than the YouTube vidoes.  I will post a very detailed article tonight on Code Project on how you can make these videos and use them in your articles and on your blogs. I will also update all the Mole videos tonight or tomorrow.

Hope you enjoy and like the new videos!

Just a grain of sand on the worlds beaches.


WPF Sample Series – Stretch ToolBar Width Of Window

January 23, 2008

imageone

This is the next sample in the WPF Sample Applications Series. The purpose of the Sample Series is to provide concise code solutions for specific programming tasks. This sample provides a brief description of the problem, the solution and full source code.

I’m working on a WPF application that calls for the ToolBar to stretch across the top of the Window, with the Help button right aligned.  If the form width is less than the width of the ToolBars, the the ToolBars must display the ToolBar buttons using the ToolBar overflow feature.

My co-worker surfed around the web to see how another developer may have done this, but could not find any examples of how to do this.  So we sat down and spent the 10 minutes to lay up the above form and post this sample.

Window XAML Code

Things To Learn From This Code

  • How to use a Grid control to layout a WPF business form.
  • How to have a ToolBar consume the width of the form.
  • How to right align the Help button on the ToolBar.
  • How to capture ToolBar button click events in a single RoutedEventHandler.
<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="Window1"
  Title="ToolBar Full Width Sample" Height="300" Width="300"
  Background="#FFFFFFFF"> 

  <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions> 

    <DockPanel Grid.Row="0" LastChildFill="False"
               HorizontalAlignment="Stretch" Width="Auto"
               Background="#FFF2F2F2">
      <ToolBar x:Name="tbToolBar" DockPanel.Dock="Left"
               Background="{x:Null}"> 

        <Button ToolTip="New">
            <Image Source="New.png"/>
        </Button>
        <Button ToolTip="Save">
            <Image Source="Save.png"/>
        </Button>
        <Button ToolTip="Delete">
            <Image Source="Delete.png"/>
        </Button>                 

      </ToolBar>
      <ToolBar x:Name="tbToolBarHelp" DockPanel.Dock="Right"
               Background="{x:Null}"> 

        <Button ToolTip="Help">
            <Image Source="Help.png"/>
        </Button> 

      </ToolBar>
    </DockPanel>
    <Border Grid.Row="1" Background="#FFE8F9FF"
            Padding="20,0,0,0" BorderBrush="#FF0032AA"
            BorderThickness="0,1,0,0"> 

      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions> 

        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="75"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Column="0" Grid.ColumnSpan="2"
                   Text="New User Form" Margin="0,10,0,10"
                   FontSize="18" FontWeight="Bold"
                   Foreground="#FF0024A6"/> 

        <TextBlock Grid.Column="0" Grid.Row="1"
                   Text="Name"/>
        <TextBlock Grid.Column="0" Grid.Row="2"
                   Text="Email"/>
        <TextBlock Grid.Column="0" Grid.Row="3"
                   Text="Password"/>
        <TextBox Grid.Column="1" Grid.Row="1" Width="150"
                 HorizontalAlignment="Left"/>
        <TextBox Grid.Column="1" Grid.Row="2" Width="150"
                 HorizontalAlignment="Left"
                 Margin="0,5,0,0"/>
        <PasswordBox Grid.Column="1" Grid.Row="3" Width="150"
                     HorizontalAlignment="Left"
                     Margin="0,5,0,0"/>
      </Grid>
    </Border>
    <StatusBar Grid.Row="2">
        <StatusBarItem Content="This is the StatusBar"/>
    </StatusBar>
  </Grid>
</Window>

Use Grid Control To Layout Form

I’ve seen many different layout techniques for docking a ToolBar at the top, form controls in the middle and StatusBar docked at the bottom.  A DockPanel control works great for doing this.  However, if you use a Grid control, you can accomplish the same thing and have a little bit more flexibility.  So for this example, I’ve chosen the Grid control as the Layout root control for the Window.  Three rows, the top and bottom rows have their height set to Auto and the middle row is set to consume the remaining space.

When I comes to the ToolBar layout, I tried 3 or 4 different layouts and like the above one the best.

Using the DockPanel control as the container for the two ToolBar controls makes the most sense here because if I need to add a third ToolBar later, I can just position it and dock it according to my layout requirements.

Take notice of the LastChildFill property on the DockPanel.  You must set it to False, otherwise the last ToolBar added to the DockPanel would consume the available space and the ToolBar would not look correct.

By placing the DockPanel.Dock attached property on the two child ToolBars, we can control which side of the DockPanel each of the ToolBars will be docked to.

Another nice feature of laying the ToolBars out like this is, if the container Window width is smaller than the ToolBar width, the ToolBar will automatically go into its overflow button display mode and the user can click on the black down arrow graphic at on the right side of the ToolBar to display the hidden ToolBar buttons.

Narrow Window – Right Toolbar Collapsed

imagetwo

Notice how the form has been reduced to a very small width.  The right ToolBar has been collapsed and the black down arrow graphic is visible.  I have click the graphic and the Help button is now visible.

Capturing ToolBar Click Events

Partial Public Class Window1
  Inherits System.Windows.Window 

  Public Sub New()
    InitializeComponent()
  End Sub 

  Private Sub Window1_Loaded(ByVal sender As Object, _
    ByVal e As System.Windows.RoutedEventArgs) Handles _
    Me.Loaded 

    'set up a RoutedEventHandler for all ToolBar buttons.
    '
    Me.dpToolBarContainer.AddHandler( _
      Button.ClickEvent, New RoutedEventHandler( _
      AddressOf ToolBarButton_Click)) 

  End Sub 

  Private Sub ToolBarButton_Click(ByVal sender As _
    Object, ByVal e As System.Windows.RoutedEventArgs) 

    'TODO developers handle your button click events here
    '
    'cast the e.OriginalSource as a button, then get your
    '  command from the button and act upon it
    '
    'Dim btn As Button = CType(e.OriginalSource, Button) 

  End Sub 

  Private Sub Window1_Unloaded(ByVal sender As Object, _
    ByVal e As System.Windows.RoutedEventArgs) Handles _
    Me.Unloaded 

    'clean up by removing the handler we added in the loaded event
    '
    Me.dpToolBarContainer.RemoveHandler( _
      Button.ClickEvent, New RoutedEventHandler( _
      AddressOf ToolBarButton_Click)) 

  End Sub 

End Class

The above code takes advantage of the WPF RoutedEvent architecture by listening for all ToolBar button Click events in their parent container (grandparent actually).  Since all the ToolBar buttons are contained within the DockPanel or child controls of the DockPanel, we can place a single routed event handler on the DockPanel and listen for the Click event. 

Notice how I call RemoveHandler on the Unload event.  I’m a firm believer in explicit clean up, disposing and de-referencing.

If you are not familar with WPF RoutedEvents, RoutedEventHanders or RoutingStrategys please see the following two articles I have written.  They both has examples of each.

When you write your own code, you’ll need to come up with a strategy for handling the ToolBar button Click events.  When you add your buttons to the ToolBar, you’ll need to mark the button with the command that button represents.  There are several ways to do this.  You can use the CommandParameter and place your command there, you can use the built it WPF Command system and assign a Command to the Command property, you can place a value in the button Tag property, etc.  Many ways to mark a button with its command.  Then just test the button for its command that you have assigned and take appropriate action.

Please keep in mind, for “real world” applications, the ToolBar should be in a UserControl or CustomControl.  The above code is simple layout instruction and all the code is in one form to make it easier to understand.

Source Code: After downloading the source code you MUST change the file extension from .zip.DOC to .zip. This is a requirement of WordPress.com.

DownLoad Source Code 18KB

Hope you can learn just a little bit more about WPF from this article and the Sample Series.

Just a grain of sand on the worlds beaches.