Profile Picture

Extending Nevron Diagram

Posted By Elia Dal Santo 13 Years Ago
Author
Message
Elia Dal Santo
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 3, Visits: 1
Hi

We're currently in the process of developing an application that let's our users crete diagrams, and we were evaluating Nevron Diagram to achieve this.

However, some of the features we require are not present out-of-the-box, so I was trying to find out how to extend nevron diagram but in this reguard I must admint I find the documentation a bit lacking

In particular, is there any documentation/examples that explains how to create our own custom drawing tools, place them on the bar manager's Tools toolbar and use them?


Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi,

You can start from the following example:
C# Examples - Drawing View - Controller

This example demonstrates how to create a custom tool and activate it. The custom tool in the example implements a zoom to range feature, but outlines what needs to be done to make a custom tool that interacts with the document/view in a custom way.

Then you can take a look at the following example:

C# Examples - Visual Interface Components - Command Bars

The example demonstrates how to create a custom diagram command and place it in the commands bars manager. In general the creation of a toolbar command that activates a custom tool is very easy. You need to derive from NDiagramCheckButtonCommand, and override the Enabled, Checked and Executed methods of the base class. For example following is the implementation of the NEnablePanToolCommand:

   public class NEnablePanToolCommand : NDiagramCheckButtonCommand
   {
      public NEnablePanToolCommand()
         : base((int)DiagramCommandRange.Tools, (int)DiagramCommand.EnablePanTool, "Pan tool", "Pan tool")
      {
      }

      ///
      /// Overriden to determine whether there is a valid commander and view
      ///

      public override bool Enabled
      {
         get
         {
            if (Commander == null || Commander.View == null)
               return false;

            return true;
         }
      }

      ///
      /// Determines whether the Pan tool is enabled
      ///

      public override bool Checked
      {
         get
         {
            if (Commander == null)
               return false;

            NDrawingView view = Commander.m_View;
            if (view == null)
               return false;

            return view.Controller.Tools.IsToolEnabled(NDWFR.ToolPan);
         }
      }

      ///
      /// Enables the Pan tool
      ///

      public override void Execute()
      {
         if (Commander == null)
            return;

         NDrawingView view = Commander.View;
         if (view == null)
            return;

         view.Controller.Tools.SingleEnableTool(NDWFR.ToolPan);
      }   
}

Hope this helps - questions or comments - please feel free...

Best Regards,
Nevron Support Team



Elia Dal Santo
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 3, Visits: 1
Thanks for the sample. I managed to add the button to the toolbars.

I then tried to inherit existing tools to generate my custom shapes, but I'm having some troubles.

In particular, I tried to create a new tool that creates a shape with a control inside, this is what I managed:

Public Class CreateRichTextTool
Inherits NCreateRectangleTool

Protected Overrides Function CreateElement(ByVal preview As Boolean) As Nevron.Diagram.INDiagramElement
If preview Then
Return MyBase.CreateElement(preview)
Else
Dim rtn As New NWinFormControlHostShape(New RichTextBox)
Return rtn
End If
End Function
End Class


However, this doesn't seem to work, the control is not created when I release the mouse button. What is the correct way to implement a new tool?


EDIT: Another important question: Is it possible to use the diagram library without the included NDiagramCommandBarsManager?? To be consistent with the rest of our apps I need to use a Ribbon menu, rather than the provided "classic" toolbars. I tried doing this, but it seems the commandbarsmanager is doing some magic of it's own behind the scenes, because tools don't behave the same way as in the samples. For example, to enable the selector tool I do this:

NDrawingView1.Controller.Tools.SingleEnableTools({"SelectorTool", "MoveTool", "CreateGuidelineTool", "HandleTool", "ContextMenuTool", "KeyboardTool", "InplaceEditTool", "DragDropTool"})

(note: I previously added all of those tools of course)

With that, the pointer *almost* works as expected, but not quite. Moving the shape doesnt work for example, and the mouse cursors do not change (ie: when I move the pointer over the rotate grip the cursor doesn't turn into the "ciruclar arrow" icon, even tho the rotation works just fine, same thing with resizing).

Elia Dal Santo
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 3, Visits: 1
I narrowed down the "can't move nodes" problem, it appears there's conflict between the MoveTool and the SelectorTool, I can only move if the SelectorTool is in ClickMode, if it's in ClickAndRegion mode moving nodes around doesn't work. Any idea how to solve this? (as for the custom cursors, I don't know what I did but now they work )

Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009

Hi Elia,

If you need a tool to create custom shapes, you may take advantage of the NCreateShapeTool and set the shape you want to create to its Shape property. The following is a simple example that demonstrates you how to create a tool that places a button shape on the diagram:

 

Button button = new Button();

button.Text = "Button";

 

NCreateShapeTool createButtonTool = new NCreateShapeTool();

createButtonTool.Name = "Create button tool";

createButtonTool.Shape = new NWinFormControlHostShape(button);

 

If you want the control to be active even when the shape is not currently selected set the DeactivateOnLostFocus property of the NWinFormControlHostShape to false.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic