georeference.org
Subscribe to this thread
Home - Scripting / All posts - Select with mouse inside C# application
alex3 post(s)
#03-Nov-08 11:31

I use Manifold ActiveX control inside a C# based application to display roads (lines) and other geographical elements (represented as points and areas).

How do I replicate Manifold's GUI select functionality where the user clicks on the drawn line and it changes color.

In addition I need to get a handle on the selected object in order to display and change its properties (like road width, traffic volume, etc.)

I looked at the documented OnClick (http://www.manifold.net/doc/click_events.htm) script but I could not find a global object EventArgs in ActiveX manifold control.

Thank you,

Alex.

ghelobytes97 post(s)
#04-Nov-08 06:15

Currently i'm doing something like this:

private void mapControl_ClickEvent(object sender, AxManifold.Interop.IComponentControlEvents_ClickEvent e)

{

    string componentName = "Drawing1";

    string wkt = String.Format("POINT ({0} {1})",e.pArgs.LocationNative.X.ToString(),e.pArgs.LocationNative.Y.ToString());

    string sql = "UPDATE [{0}] SET [Selection (I)] = True WHERE " +

             "TOUCHES(ID, Buffer(AssignCoordSys(CGeom(CGeomWKB(""{1}"")), CoordSys(""{0}"" AS COMPONENT)),{2}))"

             componentName, wkt, mapControl.ScaleAbsolute * .001);

    Manifold.Interop.Query tempQuery = mapControl.get_Document().NewQuery(""false);

    tempQuery.Text = sql;

    tempQuery.Run();

    mapControl.get_Document().ComponentSet.Remove(tempQuery);

    mapControl.Refresh();

}

You'll just have to make sure that mapControl.RenderSelection is set to true either thru code or the control's property.


ghelo.arboleda

namria, philippines

ghelobytes@yahoo.com

lionel_

627 post(s)
#06-Nov-08 12:07

could you explain what mean / why occur pArgs after e ?

thank's

ghelobytes97 post(s)
#08-Nov-08 07:47

if you are pertaining to this: e.pArgs

well, "e" contains the event arguments that get passed everytime a Click event occurs.

The "pArgs" holds these arguments as properties.


ghelo.arboleda

namria, philippines

ghelobytes@yahoo.com

alex3 post(s)
#11-Nov-08 11:06

Ghelo, thank you for your code example; I did not expect to use SQL for this, but your solution makes sense. However, I can't make it work. While debugging, I can follow up to tempQuery.Run(), but then it strangely returns to the application and the last two lines are not executed. I tried to change the tolerance (.001) to a heigher number, but it does not help.

Thanks again, Alex.

ghelobytes97 post(s)
#12-Nov-08 01:30

sorry... my bad!

try this attached demo..

Attachments:
Sample.zip


ghelo.arboleda

namria, philippines

ghelobytes@yahoo.com

alex3 post(s)
#25-Nov-08 10:54

Ghelo, many thanks for the helpful sample.

Alex.

0 msec Copyright (C) 2007-2008 Manifold.net. All rights reserved.