A magic lasso tool needs some hard-to-implement algorithm related to
image recognition. And you already took a wrong path by using the class
PictureBox
. It won't be helpful at all. Please see my past answers:
How do I clear a panel from old drawing[
^],
draw a rectangle in C#[
^],
Append a picture within picturebox[
^];
Drawing Lines between mdi child forms[
^],
capture the drawing on a panel[
^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[
^].
[EDIT]
You can use open-source GIMP to find out a couple of similar algorithms:
http://en.wikipedia.org/wiki/GIMP[
^],
http://www.gimp.org/[
^].
You can get source code here:
http://www.gimp.org/downloads/[
^].
First, try how it works. Even though there are no exact "lasso tool" (the tool shown under the "lasso" pictogram is different, just a free-hand selection), there are some similar tools: "Fuzzy Select Tool" (a.k.a. "Magic Wand"), "Select by Color Tool" and "Scissors Select Tool" (the closest to "Lasso Select").
Now, to use the code in your .NET project, you can simply learn how it works and write your code (or translate from GIMP). If you want to use the native C++ code, you can do it either through P/Invoke or by developing a C++/CLI mixed-mode wrapper library.
If you need to learn P/Invoke, start from here:
http://en.wikipedia.org/wiki/P/Invoke[
^],
http://msdn.microsoft.com/en-us/library/Aa712982[
^].
This CodeProject can also be useful:
Essential P/Invoke[
^].
One alternative to P/Invoke is to use C++/CLI mixed-mode (managed+unmanaged) project. This project could build a DLL required by the global hooks, but it can contain some managed wrapper CLI code, so, from the standpoint of your .NET application, you can use it as a regular .NET assembly, that is, reference it. Please see:
http://en.wikipedia.org/wiki/C%2B%2B/CLI[
^],
http://www.ecma-international.org/publications/standards/Ecma-372.htm[
^],
http://msdn.microsoft.com/en-us/library/xey702bw.aspx[
^],
http://msdn.microsoft.com/en-us/library/3bstk3k5[
^].
—SA