Basically the only difference between liftplan and treadle drafts is the constraint for a single treadle selection in normal drafts is lifted. It also constrains the treadle plan to be a simple diagonal. The original code bakes in the assumption of not-liftplan in a few places that need to be changed in order to implement liftplan. Also the name "Treadle" will become a little inappropriate in some places but I might just live with that.
Sharing the selection between the two grids means having an object to represent the selection. It makes sense for that to be the thing that does transforms on the selection (stretch, reflect etc). But where does it live? It seems to be a property of the session. Persisting it seems wrong. It needs to be visible to either the grid model or the grid view to implement pasting; probably the model. Copying could be implemented with an event but I can't see how to do paste with events. Paste should implemented by the grid model, and selection buffer definitely originates there. Using the window to mediate would be ugly and anyway wouldn't help because the GridControls sit between. An EventAggregator might help but something still has to pass that object to where it needs to be, unless we use a singleton.
The session is created by the WeavingSimulatorApp but immediately passed to the WeavingDraftWindow to be owned. Reasonable enough, there can be multiple sessions with a window on each. So with a little refactoring, the two grid models in question can see the session. There seems to be two selection concepts here: the thing that can be pasted, and the cells that are highlighted on the screen. probably need to separate those. Can we stop displaying the selection at click-away? Seems like normal behaviour.
It is well known that Undo is generally implemented with Command pattern objects held in two queues. Editing Session is the obvious place for those queues. The problem is, nothing so far uses command objects. I wouldn't start from here. So it looks like we need to
How does the command work? It should be able to know which elements of the draft it is setting, so it can record the state before to restore it. Its interface has do and undo methods. The object is bound to its target at construction. What commands are there:
The first three are the most important, it will be nice to support the rest too.