Resize/Edit notification that can be cancelled?

I have a controller that controls the GoDocument/GoView. GoDocument exposes a changed event that provides notifications when the users edits or resizes an object.
I’d like to be notified, then cancel the event. Notify my controller class about the user action and let it dictate commands to the GoDocument/GoView on how to proceed next. I find that barring SelectionDeleting - other events are not cancelable.
Am I missing something? How do I go about implementing this.

There are several places where you could implement such functionality, depending on exactly when in the process you want to be able to control it.

For resizing, I assume you already know about the AllowResize property on GoLayer, GoDocument, and GoView, and about the GoObject.Resizable property. But I think setting these properties to false is too early in the process for your scenario – too static.

Perhaps more appropriate would be overriding GoToolResizing.CanStart(), so that you can dynamically inquire your “controller” about whether interactive resizing is permitted. If you want to distribute that code amongst your various GoObject classes, I would override GoObject.CanResize().

(When customizing a tool, remember to replace the standard instance of the tool in the view by calling GoView.ReplaceMouseTool with an instance of your tool subclass.)

For in-place editing, there isn’t a separate tool for that behavior, since it is basically just a command, like deleting. You can either override GoView.EditObject(GoObject) to do nothing, or you can override GoObject.CanEdit().

What i would have liked/expected is events of type BeforeXXX which can be cancelled. e.g. BeforeResize with void Handler(object, CancelableEventArgs)
e.g. If the user resizes a textbox, I want to be notified before the textbox changes are applied with an option to cancel. I would cancel the user action, inform a MainController class that the user attempted to resize to this new value. The controller then can take a decision on how to proceed and in turn notify the view on the final action to be taken. MVC behavior.

Is subclassing and overridding GoObject lifecycle methods the recommended way of doing this ? I want to reuse the rich editing existing base behavior but with the notification… wouldn’t like to have to recode editing related functionality in the overridden method.

Yes, the only such event that GoView defines is the GoView.SelectionDeleting event, which is cancelable. This is raised by GoView.DeleteSelection before the actual deletion. GoView.DeleteSelection then raises the GoView.SelectionDeleted event afterwards. It’s called by both GoView.EditDelete() and GoView.EditCut().

You can easily implement those kinds of events by generalizing what I suggested in my previous post. For example, you could define a CustomView.ObjectResizing cancelable event. In your override of GoToolResizing.CanStart, you can raise that event. If the CancelEventArgs.Cancel property becomes true, you would have CanStart() return false.

I had assumed that you didn’t need the generality of implementing your own GoView.ObjectResizing event, since you probably would only implement a single event handler for it. But if your custom tool would be used in multiple or varying circumstances, and thus it could not know about consumers of the GoView, then it makes sense that you would need to design it as an event on the GoView.

Thanks for clearing that up, Walter.