Discovering open source WPF components – Orc.Search

In the discovering open source WPF components series, I will look into useful open source components that can be used to create WPF apps. This weeks component is Orc.Search.

Most applications sooner or later need a search functionality. Since most .net applications work with models (objects containing the actual information users want to search for), it might be hard to implement such functionality.

A great open-source search engine for indexing and searching is Lucene.net, but it requires quite some work to implement it from scratch in an application. Orc.Search provides a great wrapper around Lucene.net in 3 simple steps. Of course it also comes with xaml controls to easily add search boxes with status indicators to your applications.

Step 1: decorate your models with the right attributes

An alternative to using attributes is to implement a custom IMetadataProvider (you are never forced to only use attributes).

Step 2: Add the projects to the search service

Step 3: Use the Search method

Once the objects are indexed, you can easily use the search method to search for any values:

Enjoy your results!

orc_search

Discovering open source WPF components – Orc.ProjectManagement

In the discovering open source WPF components series, I will look into useful open source components that can be used to create WPF apps. This weeks component is Orc.ProjectManagement.

Ever needed to manage one (SDI) or multiple (MDI) projects in your application? At first you start with a model, very easy. Then people ask you if they can have multiple projects at the same time. Then they ask you have application-wide commands for the currently active project. And then you found out that all that you have written was already in Orc.ProjectManagement.

The project management library makes it easy to manage projects. The main component is the IProjectManager that contains the current project and allows to load or save a project. Note that this library does not force you to use a specific project location of any sort, so it can even be a database or server call to read / write the project. A few very handy events that every app needs are listed below:

  • ProjectLoading
  • ProjectLoaded
  • ProjectClosing
  • ProjectClosed
  • ProjectRefreshing
  • ProjectRefreshed
  • ProjectSaving
  • ProjectSaved
  • etc

Creating a project

The most important thing in project management is a project class that can be managed.

Creating a project reader

Creating a project writer

There is much more to discover

To prevent this blog post from getting too long, I will stop here. But there is much more to discover in this library:

  • IProjectValidator => validate if a project can be loaded (file exists, directory exists, can connect to db, etc)
  • IProjectInitializer => what should the IProjectManager do at startup? Load a file that was specified via command line arguments, open a directory, always start with an empty demo project, or anything you like

Discovering open source WPF components – Orc.FileAssociation

In the discovering open source WPF components series, I will look into useful open source components that can be used to create WPF apps. This weeks component is Orc.FileAssociation.

Sometimes applications need to be associated with certain file types. When searching the internet for a solution, you mostly get some code that hacks the registry (and requires user elevation). This was the primary reason why Orc.FileAssociation was written: associate an application with file types without elevation and no need to hack the registry yourself. Depending on the version of Windows your end-users are using, below are the screenshots showing the process.

Example application

Windows 10 default apps

Windows 10 default apps

Application registration

First you need to register the application in the registry for applications to be able to be associated with file types. This can be done very easily by using the following code:

 

File association

To start the file association, use the following code:

 

Remember that this code does not require elevation and will associate file types for the current user.