thientung / winforms-geplugin-control-library

Automatically exported from code.google.com/p/winforms-geplugin-control-library
GNU General Public License v3.0
0 stars 0 forks source link

Add new PluginReady2 event handler that can be used from other threads/classes #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The existing PluginReady event handler sends the GE COM object as the sender. 

Normally one would wait for a PluginReady event to run the LoadKml on "this". 

However, if you are instantiate a GeWebBroswer class and set it's
PluginReady event handler to load some KML then this is impossible unless
you are local in the class.

public void showInGoogleEarth()
{
    ...

    GEWebBrowser browser = new GEWebBrowser()
    ...
    browser.PluginReady += new
GEWebBrowserEventHandeler(GEDisplayViewBrowser_PluginReady);

}

private void GEDisplayViewBrowser_PluginReady(object sender, GEEventArgs e)
{

    // sender here is of type IGEPlugin. unfortunately, this can't use the
GeWebBrowser 
    // helper methods..
    // so a better approach is to send "this" to this handler, then you can
do this: -
    GEWebBrowser browser = (GEWebBrowser)sender;
    browser.FetchKml("http://some/path/to/kml");
}

The attached patch doesn't change the existing handler but creates a new
one called PluginReady2 that can be used in the above way.

Original issue reported on code.google.com by blai...@gmail.com on 30 Sep 2009 at 9:38

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

Thinking about this now I agree with your logic and am tempted to just rewite 
the External_PluginReady handler 
to pass the GEWebBrowser object rather than adding an additional event.

My thinking is that it is very easy to obtain the plug-in object from the 
browser but impossible to obtain the 
browser object from the plug-in...

It would mean something like the following would be used...

{{{

private IGEPlugin ge = null;

private void GeWebrowser1_PluginReady(object sender, GEEventArgs e)
{
  GEWebBrowser browser = sender as GEWebBrowser;
  ge = browser.GetPlugin();
}

}}}

So I will either implement the patch or rewrite the method in the next commit.

Thanks!

Fraser

Original comment by fraser.c...@gmail.com on 30 Sep 2009 at 12:21

GoogleCodeExporter commented 9 years ago

Original comment by fraser.c...@gmail.com on 1 Oct 2009 at 11:32

GoogleCodeExporter commented 9 years ago

Original comment by fraser.c...@gmail.com on 12 Oct 2009 at 6:08