Page 1 of 1

Drawing a line

Posted: Tue Dec 22, 2009 6:48 pm
by t.abbach
I want to press on the left mouse button and then i want to draw a line.
when i put my finger of the left mouse button then the line must stop ?

how can i do that

Re: Drawing a line

Posted: Wed Dec 23, 2009 11:04 am
by Yuri
It's possible to draw Line annotation as following in Annotation Demo example:

- You choose line annotation

-Click and hold left mouse button on necessary position in an image, then pull the mouse: drawing starts

- Release left mouse button: drawing stops

You can also use Lines annotation (next one after Line annotation).
Here is possible the following:

- You choose lines annotation

-Click left mouse button on necessary position in an image, then pull the mouse: drawing starts

- Double click left mouse button: drawing stops

Re: Drawing a line

Posted: Wed Dec 23, 2009 12:23 pm
by t.abbach
When i draw a line in your demo, the line starts with the left mouse button and stops with the right mouse button.
i want to start drawing a line with the left mouse button and hold my finger on the left mouse button till i want to stop the line.

how do i do that ?

Re: Drawing a line

Posted: Thu Dec 24, 2009 11:58 am
by Yuri
You should create custom annotation based on standard one (please read the library documentation "Getting Started - Create a custom annotation").

Please try one of the variants of c# code below, both allow start and finish drawing with left mouse click:

Code: Select all

//based on LinesAnnotation
class MyLineAnnotation : LinesAnnotation
{
    protected override void OnBuilding(MouseEventArgs mouse, MouseActions action)
    {
        if (action == MouseActions.Click && Points.Count == 3)
            FinishBuilding(mouse.Location);
        else
            base.OnBuilding(mouse, action);
    }
}

Code: Select all

//based on LineAnnotation
class MyLineAnnotation2 : LineAnnotation
{
    bool _skipFirstUp;

    protected override void OnStartBuilding(PointF point)
    {
        _skipFirstUp = false;
        base.OnStartBuilding(point);
    }
    
    protected override void OnBuilding(MouseEventArgs mouse, MouseActions action)
    {
        if (action == MouseActions.Up && !_skipFirstUp)
        {
            //Skip first Mouse Up action 
            _skipFirstUp = true;
            return;
        }
        base.OnBuilding(mouse, action);
    }
}

Re: Drawing a line

Posted: Mon Dec 28, 2009 1:58 pm
by t.abbach
thank a lot it works.