In my application I have several different "Workspaces". Initially all the workspaces display the same ToolWindows, they are just arranged differently.
When a user goes from one workspace to another, the current layout is stored using DockSiteLayoutSerializer.SaveToString(), and the newly selected workspace is loaded using DockSiteLayoutSerializer.LoadFromString().
The issue that has arised, is that when calling DockSiteLayoutSerializer.LoadFromString(), the DockSite.WindowsClosed event is fired, closing all the ToolWindows, before openeing all the same windows again (given I have the same windows open in both workspaces).
This is rather unfortunate, since this is the same event that is fired when pressing the "X" on the ToolWindow to manually close it. When a user manually closes a window this way, I want to perform some extra logic (such as destroying the window and removing it from the DockSite).
Is there some straightforward way to accomplish what I'm trying to do?