void ShowDemo(string name) { if (demoWidgetContainer.Layout.Count <= 1) { demoWidgetContainer.Layout.RemoveWidget(demoWidget); var demoTypeInfo = demoDictionary[name]; demoWidget.Dispose(); demoWidget = (BaseDemoWidget)Activator.CreateInstance(demoTypeInfo); demoWidgetContainer.Layout.AddWidget(demoWidget); demoWidgetContainer.Repaint(); } else { var info = new QMessageBox(icon: QMessageBox.Icon.Critical, title: "Error", text: "Invalid number of demo widgets"); info.Show(); } }