Profile Picture

Nudge/Align

Posted By Ron Sawyer 14 Years Ago
Author
Message
Ron Sawyer
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 16, Visits: 1
Fantastic! Thank you.

Nevron Support
Posted 14 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,

Your code works, but there’s an easier way to move the currently selected nodes in a direction of your choice:

 

if (view.Selection.NodesCount < 1)

      return;

 

float step = document.Settings.NudgeLeft / view.SceneScaleToDeviceX;

view.Selection.BatchTranslate.Translate(CompassDirection.West, step, false, false);

view.SmartRefresh();

 

 

This moves all currently selected shapes the distance specified by the NudgeLeft document setting. If you want to move the shapes exactly a fixed number of pixels you can use the following code:

 

if (view.Selection.NodesCount < 1)

      return;

 

view.Selection.BatchTranslate.Translate(-10, 0, false, false);

view.SmartRefresh();

 



Best Regards,
Nevron Support Team



Ron Sawyer
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)

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

I am performing a nudge or an align by iterating through the view's selected nodes and setting each shape's location.

Is there a better way to do this?

(example of nudge left)

if (nDrawingView1.Selection.NodesCount < 1)

      return;

 

NShape LclShape = nDrawingView1.Selection.Nodes[0] as NShape;

if (LclShape != null)

{

      foreach (INNode Tmp in nDrawingView1.Selection.Nodes)

      {

            LclShape = Tmp as NShape;

            if (LclShape == null)

                  continue;

 

            NPointF TargetPoint = new NPointF(LclShape.Location.X - 1, LclShape.Location.Y);

            if (TargetPoint.X < 0)

            {

                  TargetPoint = new NPointF(0, LclShape.Location.Y);

            }

 

            LclShape.Location = TargetPoint;

      }

}





Similar Topics


Reading This Topic