ObservableGraphSourceBase & Business Logic

4 posts, 0 answers
  1. Mike
    Mike avatar
    13 posts
    Member since:
    Dec 2010

    Posted 26 Jul 2013 Link to this post

    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
  2. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 31 Jul 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Mike
    Mike avatar
    13 posts
    Member since:
    Dec 2010

    Posted 31 Jul 2013 Link to this post

    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




  5. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 05 Aug 2013 Link to this post

    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 >>
Back to Top