MapWindow 4 - Plugins : MapWindow Discussion Forum
I have a script that is working and does what I need perfectly. But what I needed now was to load that script by clicking in a button of a form, in a plugin. Is that possible?
Scripts loaded from a plugin
Posted by: vm ()
Date: May 09, 2009 08:02PM

I have a script that is working and does what I need perfectly. But what I needed now was to load that script by clicking in a button of a form, in a plugin. Is that possible?

Options: ReplyQuote
Re: Scripts loaded from a plugin
Posted by: enrico chiaradia ()
Date: May 11, 2009 05:12AM

Yes, it is possible but quite complex (not impossible) if you have low programming experience.
I suggest you to look at the source code of some plug in available with MapWindow. There are many example with C#, e.g. Shapefile to Grid is quite simple to study [www.mapwindow.org], few in vb.net like the table editor that you can download (the source code) from the SVN repository.

Start with studying the class that implements the MapWindow.Interfaces.IPlugin, e.g. open the file mwTableEditorClass.vb here [svn.mapwindow.org].
To add a button, you have to implement the "Initialize" method with a routine that create a new button object and adds it to Mapwindow toolbar.
Then, you have to implement the "ItemClicked" method in order to say to Mapwindow what it must do when the new button is pressed. In this position you must add a reference to the function implemented in the script.
Finally, only for this part, you have to implement the "Terminate" method that says to Mapwindow what it must do when the plug in is removed, probably delete the new button.
There are also other properties/methods but too specific for this post!

In the future, please say which programming language are you using.
Thank you,
enrico

Options: ReplyQuote
Re: Scripts loaded from a plugin
Posted by: vm ()
Date: May 12, 2009 07:42AM

Thank you for your reply.
However, I understand the mechanics of building a plugin, in fact this component I speak of is only one amongst others already developed for a project I'm working in.

My doubts are specific to the execution of a script, called from a plugin. This is because I already have the script and I don't want to convert it to a plugin, but instead load it and execute by the click of a button.

I am working in vb.net.

Options: ReplyQuote
Re: Scripts loaded from a plugin
Posted by: enrico chiaradia ()
Date: May 12, 2009 09:24AM

Reading your first post I thought about the necessity of a system (plug in) that permits to add a new button and to attach to it a text file like old arcview 3.x. Sorry to not understand your request immediately and to have underestimated your programming experience!
I think that the "MapWinUtility.Scripting.Run" can help you but I've never tested it, [svn.mapwindow.org].
Adding new button to a toolbar shouldn't be a problem.

Options: ReplyQuote
Re: Scripts loaded from a plugin
Posted by: vm ()
Date: May 12, 2009 04:35PM

Thank you for your help!
I will look into your suggestion, it sounds good.

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: