Skip to content

Advanced version of the stand by Create GUID in a variety of canned formats. Also a fairly simple example of my work in the WPF stack.

License

Notifications You must be signed in to change notification settings

mwpowellhtx/guidgenwpf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GUIDGEN (WPF)

If you have been around the Microsoft development stacks for any length of time, especially hearkening back to the good old days of ActiveX, then you are undoubtedly familiar with the stand by utility, GUIDGEN. Typically you can find it lurking in the bowels of your favorite version of Visual Studio, I believe it also distributes with the Platform SDKs, and so on.

Well, recently, I found that I wanted to generate some GUIDs. Do not ask me why. I just did. And I needed a version of GUIDGEN to support a couple of different flavors that were not there in the traditional version. So I thought to myself: "Self, why not work up a 'simple' WPF MVVM style version, along similar lines with the GUIDGEN," and thus was borne GUIDGENWPF.

Internally, it's quite simple. The crux of the matter is to take a System.Guid, along with some nominal options (such as text case, upper or lower, etc), and generate the desired Guid format. Same as with the traditional version, copy that to the Clipboard, except adding a few. No problem.

MVVM enters the picture in the sense that it also leverages model binding goodness, even two-way binding for selecting the desired format. Data bound results are displayed upon selection. Really quite simple, and demonstrates how a ListView may be bound to a View Model, and how that gets automatically updated.

There are a million different ways those details could be injected, plugged into, or what have you, into the generator view models, but for simplicity sake, I am keeping it simple for now. I think it serves as a pretty good example of some fairly introductory concepts of the WPF and MVVM architectures.

I even went so far as to download the Visual Studio Image Library and connect one of its images to give the app a little better look and feel than the vanilla WPF style. Nothing fancy there, just an icon, for both the app executable file and the MainWindow.

I finally decided to move forward with the plugin idea. I added an interface, IFormat, that the formats all implement. Which leaves each format plugin being a fairly simple class. Actually 'stupidly' so. All that needs to be specified, basically, is a name and a formatter/handler. Oh, and the plugins also need to be aware of the IGeneratorOptions.

With this approach, it 'created' another opportunity: to sort the instances according to desired order. This was previously done by declaratively specifying each instantiation. Again, could do this a hundred different ways. I decided to add a DisplayOrderAttribute, including an extension method to make it easier to look up the value from the type. This worked pretty well.

Feedback, comments, etc are welcome and appreciated.

Thank you.

About

Advanced version of the stand by Create GUID in a variety of canned formats. Also a fairly simple example of my work in the WPF stack.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages