-
MetadataDiffViewer updated to .NET Framework 4.0, Silverlight 4.0 and Sharepoint 2010
-
A fast post to tell you that I have updated the MetadataDiffViewer to latest .NET Framework 4.0 beta2, Silverlight 4.0 beta1 and Sharepoint 2010. These versions are compared to the previous specific version.
I have also changed the download method: now it's faster and required less space usage.
The tool is here. Enjoy!
-
New Silverlight 3.0 book!
-
In the last months I have spent a lot of time with my SilverlightItalia community friends to write a new book on Silverlight 3.0. The book is in italian language and it's a guide for developer and designer that use Expression Blend and Visual Studio.
Thank you to Brad Adams for the foreword!

You can buy it here.
-
New codeplex project: DirectShow for Silverlight
-
As you can see in my previous post, I'm working on MediaStreamSouce and audio/video processing. There's a Windows framework called Direct Show used by Windows Media Player, Windows Media Center and many others applications that is so useful and complete. Its architecture allows to read audio and video streams, decode, process and render them.
My idea is to develop a similar framework with same architecture but with revisited types and members names. The framework is available on codeplex and contains basic filter to read ogg, wav and partially avi files. It also contains an audio peak visualization, a wave writer, an infinite pin filter and audio/video render filter. An ElementCaptureFilter allows to grab an element and produce a video stream.
You can try a demo here.
If you want to write a audio video decoder (mp3, aac, dirac, mp4) or other DSP filters, please contact me. With this framework you can easly create a filter and join it to others.
-
Silverlight - Real time audio peak meter
-
I have implemented an audio peak meter for Silverlight. It uses two different ways: pre computed FFT or real time FFT.
The first technique is a console application that process audio file using DirectShow and produce a dat file containing peaks data, 12 frames per second. Then a DataAudioPeakMeter load this data file and it keeps MediaElement and BarVisualization synchronized. That works with any supported media types by Silverlight 2.0/3.0.
The second technique use a custom MediaStreamSource, called WavMediaStreamSource, that loads external wav file and provides raw samples to the MediaElement. This samples are also processed to flow BarVisualization animation.
Here is the result:
Here you can see a video demonstration of pre computed method.
Unluckily MediaStreamSource doesn’t allow to get audio raw samples decoded by Silverlight engine, so you can’t apply FFT on MP3/WMA file. You have to decode it using managed code (anyone has a decoder class?).
I hope in the future MS will give this possibility.
-
Show webcam images into Silverlight
-
With current Silverlight release or available beta you can't view webcam images from local machine so I thought to a trick to do it using a local winform application distributed using ClickOnce.
Here you are the result (YouTube video)
This sample work using two applications:
-
a winform application started navigating to the .application file, that runs a DirectShow graph to grab webcam images and send it through a Motion JPEG;
-
a silverlight application that uses socket connection to the local winform application to receive each frame from the webcam.
The winform application also implements policy server to trust socket connection from Silverlight to local application. From Silverlight prospective, it receive each jpeg frame and show it through the BitmapImage.SetSource method giving a fluid animation. It's a simple game and it allow only to capture and save webcam frames.
You can download full source code here. Enjoy!
-
MetadataDiffViewer updated to .NET Framework 4.0 beta1
-
I have updated my MetadataDiffViewer to the recent .NET Framework 4.0 beta1 so you can see differences by 3.5 SP1.
You can note some interesting changes:
-
System.Web.Routing and System.Web.Abstractions are empties because their classes were included into System.Web. The attributes TypeForwardedToAttribute and TypeForwaredFromAttribute tell to CLR, compilers and serializer to remap to new location so old builds based on 3.5 can work;
-
new assemblies System.Web.DataVisualization and System.Windows.Forms.DataVisualization containing new charting controls for ASP.NET and WinForms application;
-
some new nice classes into System.Core: lots of Action<T,..Tn> and Func<T,..Tn>, a new ExpressionVisitor to navigate into expression tree, and some new static methods for Expression class allowing to create more complex expressions containing try/catch, switch, loop, goto, ecc;
-
new assembly System.ComponentModel.Composition containing Managed Extensibility Framework;
-
new namespace System.Diagnostics.Contracts containing the class Contract with usefull methods for compilation and runtime checks;
-
new namespace System.Collections.Concurrent with ParallelFx collections: Queue, Stack, Dictionary and Partitioner;
-
new classes Tuple<T,..Tn> used by F# but that we can use for fast values storage.
In sum, there are so many new features to study :-)
-
MetadataDiffViewer: never miss a new .NET Framework member
-
A new .NET Framework or Silverlight version is released and you want to know the differences and what is changed?
MetadataDiffViewer is a Silverlight application that allow you to analyze different and future .NET Framework/Silverlight versions and get which assemblies/modules/types/members are changed between one version and another.
The first time you run it, you have to increase the isolated storage quota so the MetadataDiffViewer can download metadata and store it on local machine to increase performance.
Try it now here.
-
Lambda Expression into XAML markup
-
When I write markup I often need an IValueConverter for a Binding and usually the code implementation is small and easy. So, to resolve this typical need I thought that should be useful include small c# expression into the markup.
So I developed a MarkupExtension, called ExpressionExtension that evaluate expression during markup analyzes in order to return value to the target property. To parse the expression I used the DynamicLinq sample of SDK 3.5 which contains an useful DynamicExpression.ParseLambda method to obtain a LambdaExpression from a string. Moreover, evaluating the target property, if this is a IValueConverter, I automatically create a class, implementing the interface, that takes the delegate to convert value for a Binding. This code is compiled so is as fast as a normal c# code.
This is a partial code to understand the functionality:
// Normal expression to evaluate immediately
LambdaExpression le = DynamicExpression.ParseLambda<ExpressionDelegate>(
new ParameterExpression[] {
Expression.Parameter(typeof(object), "target")
},
typeof(object),
this.ConvertExpression,
null);
ExpressionDelegate converter = (ExpressionDelegate)le.Compile();
return converter(provideValueTarget.TargetProperty);
Here how you can use this new MarkupExtension:
<TextBox x:Name="txt" Text="Testo" />
<TextBlock
Text="{Binding Path=Text,ElementName=txt,
Converter={m:Expression value.ToString().ToUpper(culture)}}" />
<TextBlock Text="{m:Expression DateTime.Now.ToShortDateString()}" />
Here you can find the sample and source code.
In XAML 2009 there's a special syntax that will allows to use expression: Text="[DateTime.Now.ToShortDateString()]"
-
StylesExplorer on CodePlex
-
Due many requests for StylesExplorer code I just publishes my project on CodePlex:
http://www.codeplex.com/stylesexplorer
It contains both library for baml decompilation and the tool.
However Rob at pdc spoke about XAML 2009 and there are many new features such class to load baml/xaml so I thinks in the future to replace my library by System.Xaml.dll and work only on the tool.
-
(Real) Force theme on WPF
-
When I develop custom control for WPF that supports theming I need to force the engine to load the right resource instead of my Windows Vista theme. There are some tricks on the web that does is merging the the resources for a specific theme but this works only for default WPF controls.
Here you are a snippet to force a specific theme. It uses reflection so use it only for development purpose:
public App()
{
//ForceTheme("Luna", "NormalColor");
//ForceTheme("Luna", "Homestead");
//ForceTheme("Luna", "Metallic");
//ForceTheme("Aero", "NormalColor");
//ForceTheme("Generic", "");
}
private static void ForceTheme(string themeName, string themeColor)
{
// To force a particular style
Type t = Type.GetType("MS.Win32.UxThemeWrapper, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
FieldInfo themeNameField = t.GetField("_themeName", BindingFlags.NonPublic | BindingFlags.Static);
themeNameField.SetValue(null, themeName);
FieldInfo themeColorField = t.GetField("_themeColor", BindingFlags.NonPublic | BindingFlags.Static);
themeColorField.SetValue(null, themeColor);
}
Enjoy! :-)
-
Styles Explorer: BAML decompiler
-
Since the summer I have studied how XAML markup is "compiled" to produce BAML stream included as resource into the .NET assemblies. So, during free time, I have developed an XmlReader implementation that allow to decompile BAML stream and read it as an XML.
I have also developed a tool called Styles Explorer allowing to open an application or an assembly. For each file you can see the resources and decompile them, or you can explore ResourceDictionary and preview its children.
Here a video showing its usage:

Styles Explorer
You can install and try it through ClickOnce (.NET Framework 3.5 required). Hope this is useful to you and I will try to improve and maintain Styles Expolorer, so please send to me requests and bugs.
In the future I will explain how BAML is structured.
-
A complete WPF TreeListView control
-
Yes, I know, there already is a TreeListView control in the SDK, but it's simple and it isn't complete, so I developed a my custom control working on .NET Fx 3.0/3.5. It supports template, binding, scrolling and themes (classic, aero, luna). It's quite simple to use:
<
r:TreeListView ItemsSource="{Binding Source={StaticResource data},XPath=/opml/body/outline/outline}" ItemTemplate="{StaticResource dt}">
<r:TreeListView.Columns>
<GridViewColumn Header="Title" DisplayMemberBinding="{Binding XPath=@title}" Width="150" />
<GridViewColumn Header="Childs" DisplayMemberBinding="{Binding XPath=@count}" Width="100" />
<GridViewColumn Header="Url" DisplayMemberBinding="{Binding XPath=@xmlUrl}" Width="200" />
</r:TreeListView.Columns>
</r:TreeListView>
And below a screenshot of the control in action:

The control inherits from TreeView and TreeViewItem classes and uses a custom converter to indent items. The most of work is into the xaml files, built copying markup from original TreeView and ListView styles.
I used this control into my project PaperBoy.
I hope you find useful :-). Download full source control.
-
WPF AdvancedListBox for Zune effect
-
I like WPF very much and I often prepare some controls for my applications. This time I want to show a simple control extension added to ListBox. Its name is AdvancedListBox that uses custom ListBoxItem and it exposes some properties to know if ListBox is loosing or capturing the selection.
Using style I have created a sample that simulates Zune navigation effect: a background animation from previous to next selection. Here the result:

WPF AdvancedListBox
And here the source.
-
Audio spectrum using WPF and C++ CLI
-
Hi! this is my first post and I want to begin to tell you about my experiences and experiments regard .NET world.
There is a feature that lots of applications and sites miss. I'm talking about the audio spectrum, sometime built by fake bars that don't follow the music. So I developed a mixed assembly using C++ CLI that process audio samples and computes peaks grouping them by frequency range. Through DirectShow I load audio track and I grab 44100 samples per second and I transform them with FFT (I found this good guide) . FFT is heavy calculation to repeat many times per second, thus I chosen C++ CLI to reduce interop, limiting it only to the peaks exposed as a property.
The WPF side contains a custom element named AudioVisualization that 12 times per second loads peaks and shows bars using animations. My sample player contains a simple skin, but obviuosly we can customize bars exploiting WPF capabilities.
Here a video demo:

Reyalp
Full source code is available here.