WPF Photo Print (.NET 3.5 SP1)

UPDATE: Source code now available here and on CodePlex.

Here’s a small WPF utility to help make ad-hoc photo printing a little easier.

image

It borrows a couple of features from Picasa / iPhoto, but with a few notable differences:

  • No need to import your photos into a “walled” library (great if your photos are on a network share like mine, or just want an ad-hoc print from a memory card).
  • Never changes the source image and doesn’t require version history.
  • All operations are additive and vector-based.  Currently supports rotate (90Β° clockwise), crop (with aspect ratios) and straighten (up to 45Β° each way).
  • It’s fast (no need to “Apply” changes or undo them later).
  • Potential to add bitmap / shader effects (designed with it in mind, but not implemented yet)…

image

You should be able to get borderless prints out of it easily enough (or print to XPS for further processing).  It uses the standard print dialog and works fine on my HP Photosmart C7250 (haven’t tested elsewhere yet).  I plan to add extra options like “Save as…” and “Copy to clipboard” when time (and inclination) allows… πŸ™‚

You can get the app here (only 45kb unzipped!).  Note: You’ll need .NET 3.5 SP1.  Later I’ll either post source code here or maybe put it on Codeplex (if any interest from you guys).

Enjoy!

Improved WPF "Loading" animation

Here’s a simplified version of the WPF "Loading" animation I did some time ago.  This one uses an Image and a DrawingImage and scales better to its container (note it’s hard-coded to "blue" right now):

        <ControlTemplate x:Key="loadingAnimation">
            <ControlTemplate.Triggers>
                <Trigger Property="Visibility" Value="Visible">
                    <Trigger.EnterActions>
                        <BeginStoryboard Name="animation">
                            <Storyboard>
                                <DoubleAnimation From="0" To="359" Duration="0:0:5" RepeatBehavior="Forever"
                                                 Storyboard.TargetName="angle" Storyboard.TargetProperty="Angle"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.EnterActions>
                    <Trigger.ExitActions>
                        <StopStoryboard BeginStoryboardName="animation"/>
                    </Trigger.ExitActions>
                </Trigger>
            </ControlTemplate.Triggers>
            <Image Name="content" Opacity="1">
                <Image.Source>
                    <DrawingImage>
                        <DrawingImage.Drawing>
                            <DrawingGroup>
                                <GeometryDrawing Brush="Transparent">
                                    <GeometryDrawing.Geometry>
                                        <RectangleGeometry Rect="0,0,1,1"/>
                                    </GeometryDrawing.Geometry>
                                </GeometryDrawing>
                                <DrawingGroup>
                                    <DrawingGroup.Transform>
                                        <RotateTransform x:Name="angle" Angle="0" CenterX="0.5" CenterY="0.5"/>
                                    </DrawingGroup.Transform>
                                    <GeometryDrawing>
                                        <GeometryDrawing.Pen>
                                            <Pen Brush="Green" Thickness="0.1"/>
                                        </GeometryDrawing.Pen>
                                        <GeometryDrawing.Geometry>
                                            <PathGeometry>
                                                <PathFigure StartPoint="0.9,0.5">
                                                    <ArcSegment Point="0.5,0.1" RotationAngle="90" SweepDirection="Clockwise" IsLargeArc="True" Size="0.4,0.4"/>
                                                </PathFigure>
                                            </PathGeometry>
                                        </GeometryDrawing.Geometry>
                                    </GeometryDrawing>
                                    <GeometryDrawing Brush="Green">
                                        <GeometryDrawing.Geometry>
                                            <PathGeometry>
                                                <PathFigure StartPoint="0.5,0">
                                                    <LineSegment Point="0.7,0.1" />
                                                    <LineSegment Point="0.5,0.2" />
                                                </PathFigure>
                                            </PathGeometry>
                                        </GeometryDrawing.Geometry>
                                    </GeometryDrawing>
                                </DrawingGroup>
                            </DrawingGroup>
                        </DrawingImage.Drawing>
                    </DrawingImage>
                </Image.Source>
            </Image>
        </ControlTemplate>

Note it has a Trigger defined on Visibility to ensure the animation stops when the control is collapsed (otherwise it’ll consume resources even when hidden).  You could use it like this:

        <Control Name="loading" Grid.Column="4" Template="{StaticResource loadingAnimation}"
                 Width="20" Visibility="Collapsed" />

Then set loading.Visibility to show or hide the animation (or fade in/out with another Storyboard).

kick it

Newton Physics Extensions for WPF

Here’s something you’ll want to check out…  Leslie Godwin has written some WPF extensions for the Newton Game Dynamics engine – the same physics engine I used in one of my first demos (the sweet one with the car).  Although the resulting moon lander demo is HARD (my landing gear kept snapping off), Leslie’s description of building it (including using Blender and exporting a model to XAML) is definitely worth reading; even more so if you’re into this stuff πŸ™‚