This project has moved and is read-only. For the latest updates, please go here.

Real time Shape Moving

Sep 1, 2015 at 9:30 AM
Edited Sep 2, 2015 at 12:30 AM
Hello.

When moving shape by mouse, selected shape is not moving real time before 'Mouse-Up'.
But I can see 'Semi-transparent' shape when mouse moving.

How to implement Real-time shape moving. (Selected shape is moving when mouse moving)
or.
Can I get information about 'Semi-transparent' shape?

Thank you.
Sep 2, 2015 at 3:32 PM
Hello newblack.

newblack wrote:
How to implement Real-time shape moving. (Selected shape is moving when mouse moving)
If you do not use the SelectionTool (set the display's ActiveTool property to null), you can implement shape movement yourself. Just handle the events and move the shapes.

newblack wrote:
Can I get information about 'Semi-transparent' shape?
Yes, the SelectionTool (accessible via the display's ActiveTool property) provides these methods:
        public Shape FindPreviewOfShape(Shape shape)
This method will return the transparent preview shape for the 'real' shape.
        public Shape FindShapeOfPreview(Shape previewShape)
This shape will return the 'real' shape for the given preview shape.
Please keep in mind that the preview shapes are neither in the diagram's shape collection nor in the repository. They will be disposed after the shape movement has been performed.
Sep 3, 2015 at 6:55 AM
Edited Sep 3, 2015 at 7:06 AM
Thanks a lot.
With your help, I've solved the problem.

I tried Real-time shape moving, without shape selection.
// Disable SelectionTool
toolSetController1.SelectedTool = null;
MyShapeType NaviShape;  // Specific shape for moving in diagram.
bool IsNaviMoving;
Point _previousLocation = Point.Empty;


private void display1_MouseDown(object sender, MouseEventArgs e)
{
    if (NaviShape.ContainsPoint(e.X, e.Y))
    {
        IsNaviMoving = true;
        _previousLocation.X = e.X;
        _previousLocation.Y = e.Y;
    }
}

private void display1_MouseMove(object sender, MouseEventArgs e)
{
    if (IsNaviMoving)
    {
        Point pt = Point.Empty;
        display1.ControlToDiagram(e.Location, out pt);
        if (_previousLocation != pt)
        {
            NaviShape.MoveBy(pt.X - _previousLocation.X, pt.Y - _previousLocation.Y);
            _previousLocation = pt;
        }
    }
}

private void display1_MouseUp(object sender, MouseEventArgs e)
{
    IsNaviMoving = false;
}