Benutzer mit den meisten Antworten
Using DSL outside VisualStudio with Miami.Modeling.Sdk

Frage
-
Hi People,
Recently I've found this article by Pascal Recchia on netfxfactory.org. They are presenting a custom WPF editor for a model created with DSL Tools outside of VisualStudio.
I want to adopt this approach inside my application. I'm using VisualStudio 2010 and Visual Studio Visualization and Modeling SDK 10.So far I've managed to convert the library provided with the article (Miami.Modeling.Sdk) to .NET 4 and the current Microsoft.VisualStudio.Modeling libraries. I had to reference the Microsoft.VisualStudio.Modeling.Sdk.10.0 and Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0 assemblies, because the Microsoft.VisualStudio.Modeling and Microsoft.VisualStudio.Modeling.Diagrams were not longer available.
I've created a simple Model in vsvm sdk and a custom WPF editor. The model contains elements with Y and X position properties. These properties are used to position the elements on a canvas in the editor. In the editor the properties are bound to Canvas.Left and Canvas.Top Properties of some visual elements. The elements can be repositioned using drag and drop and the changes are written back to the model automatically using the binding functionality provided by the Miami.Modeling.Sdk.Now I am facing a problem when using the undo functionality of the vsvm sdk. When an element repositioning should be undone, there occurs a NullReferenceException coming from the Microsoft.VisualStudio.Modeling.Sdk.10.0. However when an element creation should be undone, everything is working fine.
Below is the code I'm using to trigger the undo operation.
UndoManager um = model.Store.UndoManager; if(um.UndoableTransactions.Count > 0) { TransactionItem t = um.UndoableTransactions.First(); um.Undo(t.Id); }
And the StackTrace of the Exception.
at Microsoft.VisualStudio.Modeling.NotificationDispatcher.NotifyObservers(Object sender, DelegateHashKey key, EventArgs e) at Microsoft.VisualStudio.Modeling.ElementEventManagerImpl.NotifyObserversInternal(Object sender, DomainObjectInfo domainObject, Guid id, EventArgs e) at Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventManagerImpl.NotifyPropertyObservers(Object sender, EventArgs e) at Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventManagerImpl.NotifyObservers(Object sender, EventArgs e) at Microsoft.VisualStudio.Modeling.ChangeElementCommand.NotifyObserversForUndo() at Microsoft.VisualStudio.Modeling.UndoManager.Undo(Guid id) at CustomEditor.MainWindow.Undo_Click(Object sender, RoutedEventArgs e) in C:\berenstein\Workspaces\Visual Studio 2010\Projects\Tests\Dsl\Forms\CustomEditor\MainWindow.xaml.cs:Line 71.
I know this is a very specialized question but I hope someone can help me or maybe point me to another option to implement what I need.
Thank you very much.
Antworten
-
I've discovered that the VS2010 version of vsvm sdk has WPF DataBinding features already integrated in it.
So I removed the DataBinding code from the Miami.Modeling.Sdk and only made use of the repository implementation.After that change the undo / redo operations started to work as expected.
- Als Antwort markiert jfranke Montag, 11. Juli 2011 07:08
Alle Antworten
-
I just discovered that right after the NullReferenceException an InternalModelingErrorException is thrown with the message: Invalid transaction to undo.
So my question is, when is a transaction in vsvm sdk invalid to undo?
-
I've discovered that the VS2010 version of vsvm sdk has WPF DataBinding features already integrated in it.
So I removed the DataBinding code from the Miami.Modeling.Sdk and only made use of the repository implementation.After that change the undo / redo operations started to work as expected.
- Als Antwort markiert jfranke Montag, 11. Juli 2011 07:08