UndoService

I recently published a generic undo/redo service on NuGet and GitHub. It is based on the momento pattern and uses delegate methods to access state.

The main benefit of this is how simple it is to use. To use it, you pass the type that is used to store state and the methods to get and set the state (most likely in wrappers to match the delegate signature). Once that is in place, you just invoke RecordState() to get the state and store it in the Undo stack, along with Undo(), Redo() and Clear() methods as appropriate.

The data structure it uses depends on whether you set a limit on the number of states that it stores. If a limit is set, it uses a dropout stack. Without a limit, it uses a standard stack.

There is no nesting or grouping of undoable actions. It is possible that I’ll add such a feature in the future but I have no specific plans to do so.

https://github.com/peterdongan/UndoService

https://www.nuget.org/packages/UndoService/

AutoScroller for Silverlight ScrollViewer

This is a small project I released as open source some time ago. It facilitates programmatic scrolling of a ScrollViewer in Silverlight.

ScrollViewer is a sealed class. Applying the functionality to it via a separate class seems like a neat approach.

Below is an example of its application. The functionality is applied by default in the example. Clicking the off button shows the default behaviour of the ScrollViewer. For convenience, this example is included in the source code download.

[silverlight: autoscrollviewer.xap]

The first three buttons on the right set the mode property of the AutoScroller. The ‘New Rectangle’ button adds a shape that may be dragged around the canvas, to demonstrate the autoscrolling functionality.
Automatic scrolling can be set directly also via the ScrollLeft, ScrollUp, SrollRight, ScrollDown properties. Lastly, there are properties to set the scrolling speed and the size of the canvas area that triggers the scrolling in Mode.Drag and Mode.Auto.

Download:

AutoScroller DLL
AutoScroller Source Code