Discovering open source WPF components – Orc.Snapshots

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.Snapshots.

Snapshots are like save games. They represent a set of data and/or values from a specific moment in time in an application. Using snapshots allows an application (and thus eventually the end-user) to store data (in memory, in a file or any in other persistence tech) which can later be retrieved. The advantage of using this library is that it will zip all the data into a single snapshot package

Whenever a snapshot is created, the SnapshotManager will:

  1. Create a zip memory stream
  2. For each provider, it will ask the provider to fill up a memory stream which is stored as a separate file
  3. Persist the snapshot memory stream to the required persistence store

Below is an animated gif of the example app that is available in the component repository:

orc_snapshots

The library makes it super convenient to add custom data to a snapshot. Just create a provider and register it in the manager and you’re done. This way you can even store (multiple) files (representing a specific moment in time) in a snapshot. Then the users can restore the snapshots whenever they want to.

Discovering open source WPF components – Orc.Wizard

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.Wizard.

A wizard is a great way to guide users through a process. Every wizard should behave the same, but there is no great out-of-the-box experience in WPF. The wizard included in this library has a few nice features:

  1. Automatic page management (with everything you expect from next / previous / finish, etc)
  2. Automatic (but optional) summary page that gathers all the information from each page to summarize what has been selected inside the wizard
  3. Optional pages that allow users to skip to a next page. It is also possible to enforce validation on a wizard page.
  4. Nice looking wizard header that is generated automatically based on the accent color

In summary, this library allows you to focus on the actual wizard content (the pages), not the wizard itself which is fully taken care of for you.

wizard

Creating wizard pages

A wizard page contains of three parts which are explained below.

Creating the wizard page model

The wizard model will hold all the information of the wizard page and return the summary (which is optional).

Creating the wizard page view model

The view model is responsible for the actual view logic. There can be a lot of stuff in here that is view-specific, as long as the results are stored into the model. This example uses the ViewModelToModel feature of Catel to automatically map the values between the view model and model. As you can see this example even contains validation, so users cannot continue to the next page when the validation does not succeed.

Creating the wizard page view

Below is the xaml view for the wizard page. Note that it’s just an ordinary Catel UserControl.

Creating the wizard

Once all the wizard pages have been created, it’s time to wrap it inside an actual wizard. Below is an example:

Using the wizard

Using the wizard can be done via the IWizardService. Below is an example on how to show a wizard:

Discovering open source WPF components – Orc.WorkspaceManagement

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.WorkspaceManagement.

Workspaces are a great way to empower your end-users to customize the layout of the screen to their own good. There are a lot of different components that can be customized inside an application (some views need settings to be stored, others should be ignored, etc). Orc.WorkspaceManagement provides a nice wrapper around this so whenever the user wants to store a workspace, each component can be stored separately using providers.

orc_workspacemanagement

Retrieving a list of workspaces

Retrieving the current workspace

Retrieving the currently selected workspace is very easy:

To get a typed instance:

Implementing providers

Providers are classes that do the hard work. They will take care of actually saving and loading the state of a specific workspace. Below is a provider that will store the IsMinimized state of a ribbon:

Storing and saving workspaces

The last step is storing workspaces and saving workspaces to disk. Since all the hard work is done by the IWorkspaceManager, it’s very easy to implement this final step.

Storing the workspace means the workspace manager will call all providers to gather their data so the UI state as it’s currently visible on the screen will be persisted into the current active workspace:

To save all workspaces in the workspace manager to disk, use the following code: