Closed dhuantes closed 6 years ago
I spoke with Sergey about it and this is reply:
It seems that the only way to save plugin settings right now is via AppConfig.cs class. It has settings for several plugins. It certainly not practical for custom plugins. I would suggest to serialize / deserialize their settings in BasePlugin.Initialize / BasePlugin.Terminate events. Also it seems to me that BasePlugin.Teminate event is not fired on closing the application. It should be called. If some plugin settings should be saved to the project file, I would suggest to add XmlPlugin.State property (string). I guess it will also require some tweaks to project / plugin events (I don't see ProjectOpened event in BasePlugin class for example).
So at the moment it is not possible to easily save your custom plug-in settings. Feel free to make the changes Sergey suggests and send me the patch
Unfortunately I've been buried in other projects for most of 2017 but expect to have time later this summer to work my MapWindow 5 plugin project. I had previously discussed using PostGreSQL for persisting project settings with the end users. Has that been flushed out/demonstrated by any plugins in MapWindow5? Additionally it would be nice if the plugin developer's were provided an interface that allowed them to select either a DB or project file to persist their changes without significant differences. So I will look at project file persistence but would like to do so knowing the way I would do the same with a DB. Thanks!
My previous MapWindow4 plugin implement overrides for ProjectLoading and ProjectSaving methods to add plugin specific state information that I wanted to save/serialize to the project file. Looking through MapWindow5 I'm not finding an obvious replacement. Unfortunately I'm more of a C++ guy than a C# guy but it looks like MW5 is leveraging the DataContractSerializer (wrapped by DataContractSerializer) to serialize XmlProject which has DataMembers that reference just about everything else. The only Plugin Serialization that is done though appears to via the Plugins property of tthe XmlProject. Unfortunately XmlPlugin is only one that doesn't use the DataContract and DataMember attributes..... How is a plugin developer supposed to serialize to the project file? Thought I'd ask just in case someone already knows this answer. I'll continue digging. Thanks!