Coding

Improving a control–Windows Phone 7 Wheel Control

The wheel control, thanks to Rene Schulte for telling me what the term on the street was, is used in a few places in Windows Phone 7 (WP7) and Nick Randolph created a user control to mimic it.  It was great but needed a few little tweaks.  Nick did all the heavy lifting on this. Currently you can go to his blog entry on it here:  Windows Phone7 Wheel Control – Updated to get the most up to date version. What I did: Enabled flick gestures Removed a flicker on...

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...

Getting a database to attach from a My Document folder

Ever want to mount a database from your My Document Folder?  I do … far too often.  In this instance, my SQL Server database MDF file is in: C:\Users\crutkas\Documents\Visual Studio 2008\Projects\Bartender.  Going into SQL Server Management Studio, and attaching a database will give you this issue.  As you can see, I can’t go in and use anything there.   So what the issue is I have to give SQL Server’s user that is running under access to that folder!  You can do this a few different ways.  Give access to the SQL Server user to read...

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 ...

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...

Hardware Complete? The magic is in the software

I’m hardware complete now.  I’ve wired up all 10 of the valves, hooked in the liquid and pressure tubing.  I even added in a pressure sensor to monitor what the pressure is in real time! Now it is time for some software magic.  With WPF, I’m given some pretty nice power to do some stuff like below.  I think the learning curve is well worth it once you start tapping into the power of it.  My “Big Button” is functionally complete, moved into a user control, and now I can easily put code and get it to...