public void processViewChanges() { foreach (var panel in openPanelsEnumerator.Values) { if (panel.Queued != null) { //If there is no panel open if (panel.Current == null) { panel.Current = viewHostFactory.createViewHost(panel.Queued, panel.QueuedContext); panel.Current.opening(); guiManager.changeElement(panel.ElementName, panel.Current.Container, panel.Current._finishedWithView); } //If there is a panel open they must be switched else { ViewHost last = panel.Current; last.closing(); panel.Current = viewHostFactory.createViewHost(panel.Queued, panel.QueuedContext); panel.Current.opening(); guiManager.changeElement(panel.ElementName, panel.Current.Container, panel.Current._finishedWithView); } } //There is no other panel queued and the current panel wants to be closed else if (panel.Current != null && panel.Current._RequestClosed) { panel.Current.closing(); guiManager.closeElement(panel.ElementName, panel.Current.Container); panel.Current = null; } panel.Queued = null; panel.QueuedContext = null; if (panel.Current == null) { openPanelsEnumerator.RemoveCurrent(); } } }