Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProjectOpened Event #18

Open
odiezgz opened this issue Nov 17, 2017 · 1 comment
Open

ProjectOpened Event #18

odiezgz opened this issue Nov 17, 2017 · 1 comment

Comments

@odiezgz
Copy link

odiezgz commented Nov 17, 2017

I am developing a plugin (for mapwindow v5.1.1.207023) that serializes metadata associated to each of the layers created by my plugin during the execution. The problem is that when I load the saved project file again and during deserialization I capture the event "plugin.LayerAdded" but the layer has not yet restored its metadata values because the restore function is called after adding the layer:

private bool RestoreLayers(XmlProject project, out int selectedLayerHandle)
{
   ...
   foreach (var xmlLayer in project.Layers
   {
        ...
        if (_layerService.AddLayerIdentity(xmlLayer.Identity))     // Add layer and inside called LayerAdded event
        {   
               ...
               xmlLayer.RestoreLayer(layer, _broadcaster);     // Deserialize layer metada
}

Everything would be much easier if in "BasePlugin.cs" had a new event "ProjectOpened" just like there is one for "ProjectClosed", ...

        public event EventHandler<EventArgs> ProjectOpened
        {
            add { ProjectOpened_ += value; }
            remove { ProjectOpened_ -= value; }
        }

... triggered by the method "public bool Open (string filename, bool silent = true) "from the file" ProjectService.cs "when result is true:

public bool Open(string filename, bool silent = true)
{
...
       if (legacy)
       {
           result = OpenLegacyProject(filename);
       }
       else
       {
           result = OpenCore(filename, silent);
       }

       if (result) _broadcaster.BroadcastEvent(p => p.ProjectOpened, this, args);
@pmeems
Copy link
Contributor

pmeems commented Nov 19, 2017

I've created https://mapwindow.atlassian.net/browse/MW5CORE-206 for this.
At the moment we're very busy getting a new version of MWGis out. After that (hopefully in a week) we'll work on a new version of MW5 and then we'll look at this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants