Drawing a line

Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.

Moderator: Alex

Post Reply
t.abbach
Posts: 6
Joined: Mon Dec 21, 2009 1:43 pm

Drawing a line

Post by t.abbach » Tue Dec 22, 2009 6:48 pm

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

Yuri
Posts: 56
Joined: Wed Jul 23, 2008 2:47 pm

Re: Drawing a line

Post by Yuri » Wed Dec 23, 2009 11:04 am

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

t.abbach
Posts: 6
Joined: Mon Dec 21, 2009 1:43 pm

Re: Drawing a line

Post by t.abbach » Wed Dec 23, 2009 12:23 pm

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 ?

Yuri
Posts: 56
Joined: Wed Jul 23, 2008 2:47 pm

Re: Drawing a line

Post by Yuri » Thu Dec 24, 2009 11:58 am

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);
    }
}

t.abbach
Posts: 6
Joined: Mon Dec 21, 2009 1:43 pm

Re: Drawing a line

Post by t.abbach » Mon Dec 28, 2009 1:58 pm

thank a lot it works.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest