public async void SetComponent(ComponentBase component) { try { _currentComponent = component; this.Content = null; var newControl = component.MainControl; if (newControl == null) { throw new Exception("The component " + component.GetType().Name + " does not define a Control. Every component needs a control"); } this.Content = newControl; } catch (Exception e) { var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); System.IO.File.WriteAllText(folder + "/InstallerError.txt", e.ToString()); } await component.Show(); }
public async void SetComponent(ComponentBase component) { _currentComponent = component; Controls.Clear(); var newControl = component.MainControl; if (newControl == null) { throw new Exception("The component " + component.GetType().Name + " does not define a Control. Every component needs a control"); } var host = new ElementHost(); host.Child = newControl; Controls.Add(host); host.Dock = DockStyle.Fill; host.Margin = new System.Windows.Forms.Padding(0); await component.Show(); }