MDC Keynote Slides

9/18/2012 12:10:57 PM

I had a few requests for my keynote slides from the MDC.  You can download here.

Tags:

Windows 8 | Library

Visual Studio Team System 2010 and the Historical Debugger

7/27/2009 3:25:04 PM

One of the coolest new features to be part of VSTS 2010 is the Historical Debugger.  It hasn’t gotten a lot of buzz, so you may want to check out this 10-4 video

If you aren’t familiar at all with the Historical Debugger, I stole this blurb from the video web site…

The new Historical Debugger coming in Visual Studio Team System 2010 promises to revolutionize the way you debug managed applications. You can think of it as something of a VCR for your debugger; "rewind" the debugging trace to examine the state of your application at various points in time so you can all-but-eliminate the guesswork about where to place your breakpoints prior to pressing F5.

Tags:

Library

Pub/Sub with duplex WCF and Silverlight 3

7/25/2009 3:22:36 PM

Check out this great blog post by Tomasz Janczuk on how to accomplish a pub/solution using WCF and Silverlight.  Full source and VS solution are available.  Cool stuff.

Tags:

Headlines | Library

Visual Tree Printing in WPF Applications

5/26/2009 9:22:48 AM

HorseCalc It’s been a while since I have posted, so I thought I would whip out a quick nugget while I work on a longer technical post.  I have been hacking away at a side project and experimenting with Prism 2 and MVC/MVP/MVVM/et al design patterns and came upon the need to print some of the output from that was already on the screen.  This seemed like a somewhat common occurrence for Composite style applications – think “print THAT widget”. The screenshot shows an application I have been working on in my spare time and the red area shows the portion of the screen I would like to print.  I quick, and admittedly cursory, examination of the SDK provided lots of examples on generating custom output to the WPF XPS infrastructure, but it was all about dynamically generating the print content.  I already had the content I wanted to print, why did I need to go through a lot of hoops and additional code just to print something I had already created?

What I was really looking for was a way to print WYSIWYG style.  I wanted to take just the chart portion of the UI and send it to the printer.  A web search got me close - “Printing WPF window(visual) to printer and fit on a page”. The problem was that Pankaj’s solution was printing the entire window, and not just a smaller part of the overall visual tree.  Fortunately, the solution is pretty straightforward but I thought I would post it anyway.  So standing on the shoulder of giants, let me show you what I did.

First, Horse.NET is built on a flavor of MVP, so I have a button on the screen (actually the View for the SummaryPresenter) that initiates the printing process.  Here is the XAML for that button.

   1: <Button Content="Print" Command="{Binding Path=PrintCommand}" CommandParameter="{Binding ElementName=ReportPanel}"></Button>

There are two important things to note here. First, I am using a WPF command to start the printing process.   You don’t have to do it this way, but it lets me tie the presenter to the UI pretty cleanly.  The second thing is the CommandParameter.  It is passing in a reference to the the ReportPanel.  ReportPanel is just a WPF Grid control that wraps the title  TextBlock and a Listbox that contains the actual charts.  The simplified XAML is below:

   1: <Grid x:Name="ReportPanel" > 
   2:     <Grid.RowDefinitions> 
   3:        <RowDefinition Height="Auto" /> 
   4:        <RowDefinition Height="*" /> 
   5:     </Grid.RowDefinitions> 
   6:     <TextBlock /> 
   7:     <ListBox/>> 
   8: </Grid>

With that UI established, lets jump to the code.  When the user clicks the Print button, the following WPF command is executed:

   1: this.PrintCommand = new SimpleCommand<Grid> 
   2: { 
   3:     CanExecuteDelegate = execute => true, 
   4:     ExecuteDelegate = grid => 
   5:         { 
   6:             PrintCharts(grid); 
   7:         } 
   8: };

This is pretty simple stuff.  SimpleCommand implements the ICommand interface and lets me pass in some lambda expressions defining the code I want to run when this command is fired.  Clearly, the magic happens in the PrintCharts(grid) call.  The code shown below is basically the same code you would find in Pankaj’s article with a couple of modification highlighted in red. 

   1: private void PrintCharts(Grid grid) 
   2: { 
   3:     PrintDialog print = new PrintDialog(); 
   4:     if (print.ShowDialog() == true) 
   5:     { 
   6:         PrintCapabilities capabilities = print.PrintQueue.GetPrintCapabilities(print.PrintTicket); 
   7:  
   8:         double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / grid.ActualWidth, 
   9:                                 capabilities.PageImageableArea.ExtentHeight / grid.ActualHeight); 
  10:  
  11:         Transform oldTransform = grid.LayoutTransform; 
  12:  
  13:         grid.LayoutTransform = new ScaleTransform(scale, scale); 
  14:  
  15:         Size oldSize = new Size(grid.ActualWidth, grid.ActualHeight); 
  16:         Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight); 
  17:         grid.Measure(sz); 
  18:         ((UIElement)grid).Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), 
  19:             sz)); 
  20:  
  21:         print.PrintVisual(grid, "Print Results"); 
  22:         grid.LayoutTransform = oldTransform; 
  23:         grid.Measure(oldSize); 
  24:  
  25:         ((UIElement)grid).Arrange(new Rect(new Point(0, 0), 
  26:             oldSize)); 
  27:     } 
  28: }

All right, what are these modifications?  The most obvious is that I am replacing the use of the original this object (which represented the entire application window in the original code) with the Grid control that was passed in as part of the Command.  So all of the measurements and transforms are executed using the Grid.  The other change is that I have save the original Transform and Size of the Grid as well.  The reason is that when you transform the Grid to fit to the printing page, it causes the actual application UI to change as well.  This doesn’t look so good on your screen, so after sending the Grid to the printer, I transform it back to its original screen layout. 

There you have it.

Tags:

WPF Composite App | Library

Build Your Skills Content

4/6/2009 7:57:00 AM

Posted below are links to the slides/content delivered by the speakers during the Saint Louis and Minneapolis Build Your Skills events.

Profiling – Scott Colestock
Find here

Loosely Coupled Applications - Shannon Braun
Find Here

Exceptions - Jason Bock
Find Here

Intro to Unit Testing - Kirstin Juhl
Download Here

Advanced Unit Testing - Raymond Lewellan
Download Here

Tags:

Library | Slick Thoughts

Presentation on Velocity Now Posted for Download

3/4/2009 8:36:09 AM

I recently gave a presentation on “Velocity” – Microsoft’s Distributed Cache technology for use by .NET applications.  It is a very cool piece of technology that should probably be getting much wider attention that it is.  It has a broad range of applicability to any large scale application that could benefit from any sort of caching.  If you are building large applications that need to scale, make sure you check it out.  I have posted my overview presentation in the Downloads section of SlickThought.  You can go VFR direct here.

Tags:

Library

Interested in Windows Workflow?

11/21/2008 9:23:10 AM

If you have been looking for a good way to start getting up to speed on Windows Workflow, Matt Milner, Minneapolis-based .NET guru and all-around good guy, has been recording a series of screencasts on various aspects of Workflow.  Good stuff.

Tags:

Library

Unity Overview Presentation from CRIneta and Iowa Code Camp

11/11/2008 10:27:26 AM

I’ve posted my Unity Overview presentation in the Download section for those that were interested.

Tags:

Library | Headlines

Apache POI Working on Access to Microsoft Office Open XML Support

3/27/2008 10:38:39 PM

From the Apache POI web site...

We are currently working to support the new Office Open XML file formats, such as XLSX and PPTX, which were introduced in Office 2007.

Good news if you need to work with OOXML from the Java world.

Tags:

Headlines | Library

Ever Wonder About WPF for Real World Business Applications?

3/24/2008 8:14:00 PM

Shannon Braun has a post about some of the benefits of using WPF for real world business applications.  Shannon has gained a ton of experience working on one of the largest WPF projects that I am aware of.  This post shares a little bit of the value of WPF vs. more traditional approaches.  Good stuff.

Tags:

Library

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen

About the author

Jeff Brand Jeff Brand

This is the personal web site of Jeff Brand, self-proclaimed .NET Sex Symbol and All-Around Good guy. Content from my presentations, blog, and links to other useful .NET information can all be found here.

E-mail me Send mail


Calendar

<<  July 2014  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

My Twitter Updates

XBOX
Live

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2014

Sign in