Skip to main content

Posts

Showing posts from February, 2012

Playing around with undo & redo functionality on WP7

Following on from my previous post about ' undo, redo, undo, redo ' I thought I would port this to WP7, I say port more a case of re-compile. What follows is an example of simple WP7 app using undo-redo functionality, whether this is any use for a real-world Wp& is up for debate. I pushed the code out to GitHub here , the only explicit changes required was a WP7 solution & project files. I also added support for  INotifyPropertyChanged this allows the CanUndo & CanRedo properties to push out change notifications - this was done to allow the binding of the enable property of an input control (button). So now the undoable class looks like this; the same implementation for all .Net versions: public class Undoable : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged = delegate { } ; private readonly Stack < Memento > undoStack ; private readonly Stack < Memento > redoStack ; publi...

undo-redo-undo-redo...

Code available on GitHub I'm currently building a UI with a semi-complex input-form that requires the ability to ' undo, redo, undo, redo ' user actions ad-infinitum. Not only does it require the ability to undo the text typed in text-boxes etc it needs the ability to undo (or redo) button clicks that add\remove complex properties (reference types). For example imagine I have the following model, where there is a hierarchical structure to the data  - parent-child relationships, the Widget has one settable value type property - 'Name' & a collection of child Widgets accessed via the 'Children' property, this property can not set by the caller- the caller has to use the 'AddChild' & 'RemoveChild' methods to affect the enumerable 'Children' property. I want the ability to ' undo, redo, undo, redo ' on these two properties. public class Widget : Model { private int ? id ; private Widget parent ; ...

Trying to test strongly typed datatables with sqlite...

Following on from my previous post  about wrapping an auto-generated strongly typed set of data-tables behind a service interface, in this post I want to show how I attempted to unit this service and failed! The service was created for the sole purpose of abstracting away the complexity I believe an ORM would have removed (see previous post), if this functionality had been implemented by an ORM then this interface would not have existed and no testing would be required. I was trying to perform unit testing - I wanted to test the code in isolation without any external dependencies. At this stage I didn't want to write any integration tests, since the development was deon off site and the client owned and managed the system infrastructure we believe they can take the opportunity to write integration tests after our delivery - this would allow them to prove the code base we have developed. The system uses a Sql Server 2008 back-end - standard 2 tier stuff. So the firs...

An ORM would have saved time...

I've just finished working on a WPF, a pretty standard inventory system for widgets & gadgets. A hierachurial structure to the data that lends its self to a tree-view structure - essentially each node has a parent-child relationship, where a node can have multiple child nodes and each node has a reference to it's parent. The app is a simple a CRUD application with some UI tweeks on how the data was to be displayed - visualising the modified nodes in the tree and hows these affected the parent node. What made this interesting was the fact this wasn't a new app from the ground-up, it was literally only a new UI, the database was already established in a production environment and had been for over 5 years, what made this interesting was the client was providing the DAL & BLL for the application - we were abstracted away from the database. All queries for data are returned via strongly typed data tables and all commands (updates) are done via explicit methods on th...