void UpdateLayoutView(ApplicationSettings settings) { var nextLayout = CreateLayout(settings.DisplayLayoutHorizontal); if (currentLayout != null) { Controls.Remove(currentLayout); currentLayout.Dispose(); currentLayout = null; } Controls.Add(nextLayout); currentLayout = nextLayout; }
void ApplyConfig(ApplicationConfig config) { // nothing to do if correct layout already if (layout is HorizontalLayout && config.DisplayLayoutHorizontal) { return; } // remove old layout if (layout != null) { Controls.Remove(layout); layout.Dispose(); layout = null; } // create new layout var nextLayout = config.DisplayLayoutHorizontal ? new HorizontalLayout(di) as AbstractLayout : new VerticalLayout(di); Controls.Add(nextLayout); layout = nextLayout; }