Design For Developers

6/15/2009 1:55:30 PM

If you are a developer and have been working wit WPF and/or Silverlight, you may have wished you had a better sense of design to really take advantage of XAML and create a visually compelling app.  A new Design for Developer series has been started and you can watch the first installment here.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Headlines

Journey Into Peer-to-Peer Begins

6/12/2009 8:07:00 AM

With some recent announcements from a big Internet company whose name cannot be mentioned, I went off on my own expedition into the dark corners of the .NET and Windows platform to see what cool technology treasures may be lurking there.  If you are like me, you may have heard something about P2P technologies being delivered for Windows.  And if you were like me, you didn’t really pay much attention to it at the time since only file sharing, music stealing people cared about peer to peer technologies.

Well, let me tell you, my friend, that was a very wrong assumption!  There is a ton of amazing P2P technologies in Windows and .NET, and they make the creation of amazing new applications possible.  Ever had an idea where your app would need to dynamically find another computer and communicate with it but both computers might be around the world, not registered with DNS, and hiding behind a NAT device? PNRP in Windows makes that easy! Every thought of having a global hashtable to store all kinds of data that could be retrieved by your app’s users – DRT to the rescue!

What are PNRP and DRT you ask?  That, dear reader, will be what I will cover in a series of blog posts and screencasts in the coming weeks to show you how to leverage and exploit this cool technology.  Want to get a head start?  Check out the P2P team’s blog and the Microsoft Peer-to-Peer Reference page.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Peer2Peer

Building a Composite WPF Application Part 9: Intro to Event Publishing and Subscribing

6/5/2009 8:05:49 AM
In this installment, we take a look at using PRISM events to publish and subscribe to events. Previous versions of the application have used .NET events and event handlers to communicate UI events between presenters. We know use PRISM events in conjunction with WPF Commands (introduced earlier) to notify various parts of the application that something important has happened.

Download video here

Download source code here

Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

WPF Composite App

Wicked Cool Silverlight App

6/4/2009 9:20:52 AM

Hanging at the .NET UG and Scott Davis pointed me to this Silverlight app by some French Microsofties - http://www.microsoft.com/france/entreprises/centre-des-usages/  WOW!!!!!!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Headlines

Wish Me Luck

6/1/2009 5:42:56 AM

Totally off normal topic (if there every really is such a thing on this blog), but I’ve signed up to take motorcycle riding lessons in a couple weeks.  I am still on the fence about getting a bike, but this seems like a logical first step.  I’m looking forward to it.  No idea what to do for a first bike should I decide to pursue it.  All the bikes I really like are much more than likely to be way to much bike for a first time rider.  Admittedly, that takes away some of the allure – not getting to ride a cool bike. ;-)  I get the feeling I need to stick to 600cc or less and that does not leave a lot of cool factor in the choices that remain!  ;-)  I’ve even heard some say to not get anything over 500cc but that is just not an option – I can afford a bike now so I kinda need to get something that I can grow into ‘cause I am not sure an upgrade option will exist in a year or two. Anyone with recommendations/experiences as a first time rider, please leave a comment.  And no, I am refuting the notion that this is some kind of mid-life act out!!! ;-)

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Junk

Building a Composite WPF Application Part 8: Custom Commands and Non-Command UI Elements

5/28/2009 8:26:02 AM

This installment looks at extending the Command concept to controls in WPF that do not natively support Commands.  This allows developers to work inside of the WPF Composite App Framework (PRISM) to connect Commands to controls other than just ICommandSource controls (Button being the prime example).

Download video here

Download source code here

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

WPF Composite App

Building a Composite WPF Application Part 7: Intro to Commands

5/28/2009 8:18:14 AM

This installment looks at using Commands inside of your WPF Composite App using PRISM.  This is a very simple example of how to use Commands and leveraging the DelegateCommand that the PRISM framework provides. 

Download video here

Download source code here

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

WPF Composite App

Why Can't This Be Fixed?

5/28/2009 2:45:00 AM

I’ve been running some flavor of Win 7 for awhile now.  My problem still exists.  In fact, it has existed for as long as you have been able use plug-in-play drive devices.  You’ve probably experienced as well.  It has probably driven you a bit batty like it has me (along with a myriad of other things, many of which are not PC related).  I’ve submitted complaints, suggestions, bitches… you name it, but the problem remains the same.  You might have done the same.

What am I talking about? That FREAKIN’ (I would use another word that begins with F but this is a family blog) dialog box that pops up when you want to disconnect a removable hard dive that says that you can’t remove the device because some other process/application is using that drive.  Well, that is nice to know, but you you please tell me what F’ING application is so I can close it.  When I have 20 different windows open, and some may or may not or maybe did but are not currently using that drive, it is a PIA figuring out which one it is.  God forbid the app is actually a system tray app that Win 7 now conveniently hides the icon for.  ARGHHHHH!!!!!!!!!!!!!!

Can’t the OS say something like, “Sorry, but the DoofinSchwark application is currently using this device.  Close this application if you wish to remove the device.” or something equally helpful.  It’s the little things….. like knowing how to merge onto a busy highway.  Yeah, I’m talking to you jack @$$!!!!

Currently rated 5.0 by 5 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Rant

New Spaghetti Code Podcast: Javier Lozano and Code Frameworks

5/27/2009 1:29:00 AM

Spaghetti Code Talks Code Frameworks with Javier Lozano about the various open source code frameworks he used in the application he is currently developing.  Covering things like nHibernate, Windsor and more, Jav talks about the frameworks he used, the rationale for picking them, and how they helped him create his application fast and with more flexibility and reliability.

  • Direct Download - click here
  • Subscribe - click here
  • iTunes - click here
  • Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Tags:

    Visual Tree Printing in WPF Applications

    5/26/2009 1: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.

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Tags:

    WPF Composite App | Library

    Powered by BlogEngine.NET 1.3.1.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


    My Twitter Updates

    Calendar

    <<  July 2009  >>
    MoTuWeThFrSaSu
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    View posts in large calendar

    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 2009

    Sign in