This is a migrated thread and some comments may be shown as answers.

ObservableGraphSourceBase & Business Logic

3 Answers 76 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 26 Jul 2013, 03:43 PM
Hello,

I'm performing EF and BL in the AddLink method of ObservableGraphSourceBase and things are working fine.  As items/links are added/removed to/from the graph I can easily update my EF and persist.

I'm now adding in some business logic.  For example, I have 3 node types, A, B, C, where my BL says that node type A can only be connected to node type B.  I'm catching the AddLink and my BL is executed and when I see a link added from A to C this violates rules so I simply do no call base.AddLink(link).

This works, the internal structures are correct, however the UI is left with an orphaned connection.  I'm assuming in this case I simply need to force the diagram to redraw and this orphan will be removed.  Is that correct and how should I force the redraw?

Thanks,
Mike

3 Answers, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 31 Jul 2013, 10:49 AM
Hello Mike,
We're aware of this shortcoming in our diagram MVVM and we'll probably fix it (I say probably because the fix will be a breaking change and we still haven't decided on it), but for now you'll have to use the ConnectionManipulationConpleted event with something like this:
private void OnConnectionManipulationCompleted(object sender, ManipulationRoutedEventArgs e)
{
    if (e.ManipulationStatus == Telerik.Windows.Diagrams.Core.ManipulationStatus.Attaching)
    {
        var source = e.Connection.Source as RadDiagramShape;
        var target = e.Shape as RadDiagramShape;
        if (source != null && target != null)
        {
            // BL here.
            if(Don'tWantThisLink)
                e.Handled = true;
        }
    }
}
I hope I was able to help you and if you have further questions please feel free to ask.

Regards,
Zarko
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Mike
Top achievements
Rank 1
answered on 31 Jul 2013, 03:24 PM
Hello Zarko,

Thanks for the answer to my question and a solution.  Your solution will work fine, I'm not (always) an MVVM purist, and I can easily route the event into my BL chain.

I see several other events of interest, AdditionalContentActivated, Manipulation....., ShapeClicked, etc.  Can you please point out some of the more powerful hooks, or point me to the proper documentation/examples for these events and why they should be used?

Thanks,
Mike




0
Zarko
Telerik team
answered on 05 Aug 2013, 11:57 AM
Hi Mike,
I'm glad that my solution meets your needs and you can read more about the Diagram events here. The AdditionalContentActivated event is used by the settings pane and it's fired after rotation, resizing, dragging and selection. The Connection Manipulation events can be used for BL that has anything to do with connections and the Items Collection events are used for BL with add/remove actions. Other useful events are CommandExecuted (called after almost all diagram actions), Rotate, Resize, Drag and SelectionChanged.
If you need further assistance please feel free to ask.

Regards,
Zarko
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Diagram
Asked by
Mike
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Mike
Top achievements
Rank 1
Share this question
or