Profile Picture

Pin Point the click location

Posted By sudarshan rudrappa 11 Years Ago
Author
Message
sudarshan rudrappa
Posted 11 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 9, Visits: 2
Hi,

Please let me know how to get the click position of the user on the nevron diagram.
I want to find which place the user has clicked, store the x,y location of it on mouse click event and place an external image in that position.

Thanks,
Sudhi

Nevron Support
Posted 11 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: Last Week
Posts: 3,054, Visits: 4,009

Hi,

You haven't specified whether this is a WinForm or a WebForm project. If it is a WinForm project, then to create a shape and place it on the clicked position in the drawing view you should subscribe to the MouseDown event of the drawing view and in the event handler you should hit test the drawing document to check whether the user has clicked on a free position and then create and add a shape to the document if he has. Here's a simple implementation:

private void OnViewMouseDown(object sender, MouseEventArgs e)

{

      if (e.Button != MouseButtons.Left)

            return;

 

      NPointF location = new NPointF(e.Location);

      NNodeList shapes = view.Document.HitTest(location, -1, NFilters.Shape2D, view.ProvideDocumentHitTestContext());

      if (shapes.Count == 0)

      {

            // Create a circle shape and place it on the clicked position

            location = view.SceneToDevice.InvertPoint(new NPointF(e.Location));

            NShape shape = new NEllipseShape(location.X - 30, location.Y - 30, 60, 60);

            view.Document.ActiveLayer.AddChild(shape);

      }

}

 

If you want an image, you can simply apply an image fill style (or even better use a style sheet) to the newly created shape.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic