Search
Saturday, May 18, 2013 ..:: Blendblog.net ::.. Register  Login
 Bloggers Minimize

  
 Sponsors Minimize

 Print   
 Users Online Minimize
Membership Membership:
Latest New User Latest: gyrofan
New Today New Today: 0
New Yesterday New Yesterday: 0
User Count Overall: 46

People Online People Online:
Visitors Visitors: 7
Members Members: 0
Total Total: 7

Online Now Online Now:

  
 Welcome to blendblog.net! Minimize

If you are a developer or designer who is creating cutting edge user interface experiences using Microsoft Expression Blend you've just found a great resource!  The purpose of this site is to share our experience with this brand new product.  As with any new piece of software there is a ton to discover.  Bugs will be revealed and workarounds discovered, hopefully this can be a resource to share in the discovery process!

While this site will focus largely on Expression Blend, it will also encompass WPF, Visual Studio, Silverlight, and other .net 3.5 technologies as they relate to the creation of great software.

Please login using your Microsoft LiveID or register a new account.  Doing so will let you comment on any of the blog entries on the site.  We look forward to helping you in your endeavors as well as you helping others in theirs!  We'd love to have more bloggers on our site...if you are interested please register and contact us!

Follow us:


  
 WPF Resource Dictionary Browser for DrawingImages Minimize
Location: BlogsSean Cullinan    
Posted by: Sean Cullinan 3/12/2008 7:01 PM

I apologize for not blogging in a while.  I have been focused 100% on getting a prototype of our product ready for some meetings we have across the pond at months end and haven't had a chance to get on here.

In building our application we have created a big resource dictionary that contains nothing but DrawingImage objects.  I created a helper class to to give me some intellisense to get the images out of this resource dictionary.  The resource dictionary is stored in its own XAML file.  As we added more and more objects it became more difficult to remember exactly what the objects looked like. 

I then started looking for some 3rd party Vector graphics files and found Grafile.  The provided samples of their work that are already put in XAML resource dictionaries.  However they provided no thumbnails to facilitate browsing the images.

This made me realize that there is definitely a need out there for a simple DrawingImage browser application.  Four hours later and I had one :)  Attached to this post is my source and a compiled .exe.  The code is in VB but should be pretty straighforward to C# people. 

The most interesting challenge when writing this code was how to load xaml files off of disk into a resource dictionary.  Most examples I've seen have the XAML files in the project.  The trick is to use the System.Windows.Markup.XAMLReader.  This can "load" the xaml out of a stream into an object, in this case a resource dictionary object declared in code.  I had already read my xaml file into a byte array (as I also keep it in an xmldocument object which I'll explain in a second) and was able to simply use a memorystream object that pointed to this bytearray and use that to load it into the XAMLReader.

Because there is no way to access the resourcedictionary by index, just by key, I also keep a copy of the resource dictionary in an xmlNodeList.  This way I can get the key easily.

Another stumbling block is the lack of a directory picker in WPF.  I used the system.win32.OpenFileDialog method which isn't perfect (it looks like you are picking a file) but works for now.  To make it seem like this behavior is by design I made it so that when you select a file it opens the whole directory but makes the file you selected the "active file." 

The application is simple to use.  It lets you select a directory (or even a file in a directory) and presents a list of files with the .xaml extension in a simple listbox.  If you select a file that is a resource dictionary with drawing images in it then it will load up the first drawingImage on the right side.  It gives you the "key" name of the image in the resource dictionary and a slider to move from image to image.

I included a test resource dictionary in the zip file.  Also, please don't use the maginfier icon that I provided in your commercial apps, it is something that I created for my commercial app and I'd like to keep it unique (its not that great anyway).

If anyone wants to play it would be cool to add a "filmstrip" type view giving previews of all images.

I already found some duplicate entries in our rather large Images ResourceDictionary thanks to this program.  It is going to be very useful for us going forward and I figure I'd share it with the community!

Sean

ImageBrushViewer.zip

Copyright ©2008 Sean Cullinan
Permalink |  Trackback

Comments (1)   Add Comment
Re: WPF Resource Dictionary Browser for DrawingImages    By daview on 10/10/2011 11:41 PM
I have a question.<br><br>I want to use the DrawingImage drawing some ICONs or IconImages for other Application, How can I do?


Your name:
Title:
Comment:
Add Comment   Cancel 

  
 Search Minimize

  
 Archive Minimize

  
 Blendblog Survey Minimize
Our next client application will be written using:




Which Tablet Do you expect to buy?





Submit Survey  View Results

 Print   
Copyright 2011 by blendblog.net   Terms Of Use  Privacy Statement
DotNetNuke® is copyright 2002-2013 by DotNetNuke Corporation