WPF

WPF, Silverlight, XAML, and Dependency Properties

In my opinion, XAML has a bit of a step learning curve.  I tend to jump head first into something and do my best to learn it.  For some stuff, my head strong, fly-by-the-seat-of-my-pants, style of learning works, XAML was a bit rougher.  I think part of it was I was expected it to work just like HTML which it doesn’t.  I’d pick up a book and play with Expression Blend to help see what does what.  Visual Studio 2010’s updated editor for WPF and Silverlight projects helps a lot as well.  So why even care about XAML? ...

Creating more complex buttons in XAML

Ever look at a project and wonder how they got a epic button instead of the every day average one? There is an extremely easy way to do this in Expression Blend.  I’m also going to show the XAML on how to do it by hand however. Here is a normal button and an ellipse. XAML: <Ellipse Fill="White" Stroke="Black" Margin="139,68,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="105" Height="105"/> <Button Margin="248,68,238,0" Content="Button" VerticalAlignment="Top" Height="105"/> The button acts like a button but I want the ellipse to act like a button.  In Expression Blend, just...

Final tweaks to improve Thumbnailing and now on CodePlex!

In the prior two posts, I talked about creating and fixing the logic for creating video thumbnails / screenshots but it had a few flaws in it. The first was I didn’t realize I had to close the MediaPlayer object’s stream, this caused memory to balloon upward after multiple plays.  Another problem was opening the same file for the same screenshots could cause issues in the long run at the same time.  To solve these issues, one was an easy fix, the other required a bit of threading knowledge. To correct this, I’ll first have a Dictionary object...

Improving Thumbnailing Code

From the prior post about getting thumbnails from a video in .Net, it was just prototype code and wasn’t properly abstracted.  Now it is time to fix it.  We’ll create a class called VideoScreenShot.  This class will function in both an asynchronous and synchronous mode.  This still could be improved by queuing up work but this is a nice refactoring. To get access to the tester app, head over to codeplex and source code can be found there too! public delegate void CaptureWorkerDelegate(BitmapFrame frame, object state); public static void CaptureScreenAsync(Uri source, TimeSpan timeSpan, object state, CaptureWorkerDelegate finalWorkerPrimary) { CaptureScreenAsync(source, timeSpan, -1, state, finalWorkerPrimary, null); } public static void...

Getting Thumbnails in WPF … on a non-UI thread

On my internal application for Channel 9, I have to create thumbnails at certain time codes in a movie.  After a giant headache attempting to track down the proper way of doing this, I figured out how to do this even if for a few hours I thought 127 seconds was the same at 1 minute and 27 seconds.  That caused some testing headaches as my test clip is 1:40 long. In this example I’ll write out the code for a threaded video thumbnail creating tool in WPF (XAML) and c#. To get access to the tester app, head over to codeplex and...

Creating my own media player

I’ve been tasked at creating a new feature / porting an application from WinForms to WPF at work.  Since Channel9 deals heavily with video, you guessed it, I have to deal with video! After attempting to see if there was a decent WPF player or example for the MediaElement, it really didn’t seem like there was.  Some of the examples did some crazy stuff when it wasn’t needed. So here are my requirements for it as of now: Play, Stop, Pause Be able to see current position’s time code ...

Drunktender’s state: Functional and getting prettier

I’ve tested the software pretty heavily and I think it is feature complete.  I before I’m going to show off the code, I need to clean up my naming scheme on some stuff.  I changed my naming scheme for UI elements half way through so … yeah, oops. Here is the current UI, the graphics came from both Ian Hall and Jeff Couturier from 10volt Media.  Jeff really helped me out and whipped up a sweet magnifying glass while Ian did the glasses for me.  Note the glass effect with the whiskey glass.  I got graphics for both in...

WPF and making stuff pretty

I can thank my upbringing for demanding stuff looks good before anyone even sees it.  Appearance matters so how can one person make their application look good and have those styles and features be reusable?  First is to use Styles.  Styles much like CSS but are different.  With CSS in web pages, you can apply multiple styles to one element.  An example of this is <div class="foo bar awesomer" style="width: 1.2em">Clint is awesomer</div> With XAML, you can’t chain styles together but what you can do is create a hierarchy of styles.  Let me show you what I’m talking about in...

WPF StaticResource vs DynamicResource

In the process of creating any program, you’ll need to refactor.  As I’m a newbie with WPF and XAML, I’m still learning the in’s and out’s and came across an interesting issue with the designer while refactoring bits of the application to controls. I have put some resources in my App.xaml. <Application x:Class="Drunktender.Wpf.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Window1.xaml"> <Application.Resources> <Style x:Key="glowEffect" TargetType="TextBlock"> <Setter Property="Foreground" Value="#fff" /> <Setter Property="Effect"> <Setter.Value> <DropShadowEffect ShadowDepth="0" Color="#39f" BlurRadius="4" /> </Setter.Value> </Setter> </Style> <Style x:Key="glowEffectOnGlass" TargetType="Grid"> <Setter Property="Effect"> <Setter.Value> <DropShadowEffect ShadowDepth="0" Color="#fff" BlurRadius="5" /> </Setter.Value> </Setter> </Style> </Application.Resources> </Application> And to reference them, you’ll typically do something like this. <TextBlock Name="textBlock" FontSize="30" Style="{StaticResource...

Making some awesome UI’s with WPF

I’ve been messing with WPF for sometime porting my application from Win32 to WPF.  I’ve transformed into a lover of WPF since you can do some extremely nice UIs with just using a text editor and quickly alter how they look.  Now here are some key things about this.  I used Aero glass, a drop shadow effect, and did everything here using just notepad.   Now it is resizable and stuff stays where it should.  This UI only took me about an hour to fully crank together, another additional hour to refactor bits and pieces.  Simple but good looking in my...