Several issues in sfDiagram

Hi,

I want to integrate sfDiagram in one of our applications and have some questions regarding it:

     1. I want to disable infinite scrolling (the diagram should be only 300x300 for ex.)
         I found the solution in this forum (ScrollLimit = ScrollLimit.Diagram) but it still stays scrollable and infinite.

     2. How can I prevent from user to change the diagram (moving/resizing nodes, he should only select it) but I should be able to change it programmatically?

     3. I am receiving exception while resizing nodes:
     
System.ArgumentNullException
  HResult=0x80004003
  Message=Value cannot be null.
Parameter name: source
  Source=System.Core
  StackTrace:
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Syncfusion.UI.Xaml.Diagram.Layout.FlowchartLayout.CreateVertex(IInternalNode node)
   at Syncfusion.UI.Xaml.Diagram.Layout.FlowchartLayout.UpdateLayout()
   at Syncfusion.UI.Xaml.Diagram.Panels.DiagramPage.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at sfDiagramTester.App.Main()


  This exception was originally thrown at this call stack:
 System.Linq.Enumerable.ToList(System.Collections.Generic.IEnumerable)
 Syncfusion.UI.Xaml.Diagram.Layout.FlowchartLayout.CreateVertex(Syncfusion.UI.Xaml.Diagram.IInternalNode)
 Syncfusion.UI.Xaml.Diagram.Layout.FlowchartLayout.UpdateLayout()
 Syncfusion.UI.Xaml.Diagram.Panels.DiagramPage.ArrangeOverride(System.Windows.Size)
 System.Windows.FrameworkElement.ArrangeCore(System.Windows.Rect)
 System.Windows.UIElement.Arrange(System.Windows.Rect)
 System.Windows.ContextLayoutManager.UpdateLayout()
 System.Windows.ContextLayoutManager.UpdateLayoutCallback(object)
 System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
 System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
    ...
    [Call Stack Truncated]


Do you have any idea why it happens? I created the diagram according to "Getting started with WPF diagram" tutorial on your site.

Thanks in advance,

Dennis.



4 Replies 1 reply marked as answer

RA Ranjitha Amirthalingam Syncfusion Team June 3, 2020 01:09 PM UTC

Hi Dennis, 
 
Thanks for contacting Syncfusion support. 
 
Please find the response to your queries as below. 
 
S.No 
Query 
Response 
1 
I want to disable infinite scrolling (the diagram should be only 300x300 for ex.) 
I found the solution in this forum (ScrollLimit = ScrollLimit.Diagram) but it still stays scrollable and infinite. 
 
Requirement: How to stop infinite scrolling in SfDiagram? 
 
We have KB document for your requirement. Please refer to the document from the following link. 
 
 
For more details about ScrollLimit, please visit our online hep documentation. 
 
2 
How can I prevent from user to change the diagram (moving/resizing nodes, he should only select it) but I should be able to change it programmatically? 
Requirement: Need to restrict interaction for node except selection. 
 
We have support to achieve your requirement using NodeConstraints. Please set the Nodeconstraints as NodeConstraints.Select for the desired or all NodeViewModel to restrict other actions like dragging, resizing, rotation. 
 
Code Example: 
//Create NodeViewModel collection  
diagram.nodes = new ObservableCollection<NodeViewModel>(); 
//Create NodeViewModel  
NodeViewModel node = new NodeViewModel() 
{  
Constraints = NodeConstraints.Select,  
UnitWidth = 50, 
UnitHeight = 50,  
OffsetX = 100,  
OffsetY = 100,  
};  
//Add NodeViewModel to Nodes Collection  
(diagram.Nodes as ObservableCollection<NodeViewModel>).Add(node); 
 
 
 
For more details about constraints, please visit our online hep documentation. 
 
3 
I am receiving exception while resizing nodes: 
Reported Issue: Exception occurs while resizing the node. 
 
We could notice that you have faced exception while resizing the node in flowchart layout from the stack trace. So, we have tried to replicate the issue in flowchart, but issue not reproduced in our end. We have provided video to represent this. 
 
 
If the scenario represented in the video is different from the reported scenario, please provide us issue replicable video or sample to reproduce the issue in our end. This helps us to serve you better. 
 
 
 
Regards, 
Ranjitha A. 


Marked as answer

DE Dennis June 14, 2020 06:11 PM UTC

Hi,

Thank you for the quick response.

1)  I have solved issues #2 and 3, but #1 still happens.

     It happens even in the example you have provided.

     When you are moving the node outside the diagram limits, the diagram grows and the scrollbar appears.

     I have tried using:
  1. "diagram.ScrollSettings.ScrollLimit = ScrollLimit.Diagram;"
  2. "diagram.ScrollSettings.ScrollLimit = ScrollLimit.Limited;"

     Both options do not prevent the diagram resizing.


2)  I have another issue - I am disabling right click menu for the node:

Constraints = NodeConstraints.Default & ~(NodeConstraints.Menu | NodeConstraints.InheritMenu)                                  

     but it still appears.

Thanks in advance,
Dennis.




     


RA Ranjitha Amirthalingam Syncfusion Team June 15, 2020 12:53 PM UTC

Hi Dennis, 
 
Currently, we are validating the ways to achieve your requirement. We will update you the details on June 16, 2020. 
 
Regards, 
Ranjitha A. 
 



KR Karkuvel Rajan Shanmugavel Syncfusion Team June 16, 2020 10:10 AM UTC

Hi Dennis, 
 
Please find the response to your queries in below table. 
 
Query 
Response 
It happens even in the example you have provided. 
 
     When you are moving the node outside the diagram limits, the diagram grows and the scrollbar appears. 
 
     I have tried using: 
  1. "diagram.ScrollSettings.ScrollLimit = ScrollLimit.Diagram;"
  2. "diagram.ScrollSettings.ScrollLimit = ScrollLimit.Limited;"
     Both options do not prevent the diagram resizing. 
 
We have prepared a simple sample for your requirement. In the sample we have used ScrollLimit as Limited and it worked properly for us. In the sample we have provided the code to limit Auto Scroll (Scrolling of Page by click and drag diagram element over the edge of the viewport) and Scroll (Mouse wheel scroll for Vertical and Shift + Mouse wheel scroll for Horizontal). Please find the code snippet below. 
 
Code Snippet : 
 
 
            // Scrollable area which is common for ScrollLimit and AutoScrollLimit 
            Diagram.ScrollSettings.ScrollableArea = new Rect(0, 0, 2500, 1500); 
 
            // This code is to limit the mouse wheel scroll till the provided region 
            Diagram.ScrollSettings.ScrollLimit = ScrollLimit.Limited; 
 
            // This code is to limit the Autoscroll(i.e) Click and drag of nodes over the viewport through moving them to the edges of the viewport 
            Diagram.ScrollSettings.AutoScrollLimit = ScrollLimit.Limited; 
 
  
 
I have another issue - I am disabling right click menu for the node: 
Constraints = NodeConstraints.Default & ~(NodeConstraints.Menu | NodeConstraints.InheritMenu)                                   
     but it still appears. 
 
We are able to reproduce the reported issue. We will fix the issue in our upcoming Volume release. For your requirement of ContextMenu not shown for Node can be achieved by Menuopening event. Please find the code snippet below. 
 
 
            (Diagram.Info as IGraphInfo).MenuOpening += MainWindow_MenuOpening; 
 
        private void MainWindow_MenuOpening(object sender, MenuOpeningEventArgs args) 
        { 
            if(args.Source is INode) 
            { 
                args.Cancel = true; 
            } 
        } 
  
 
 
 
If the issues still there then please revert us with your version details that will help us to investigate further about the reported issue. 
 
Regards, 
Karkuvel Rajan S 


Loader.
Up arrow icon