//cargar form private void frmGame_Load(object sender, EventArgs e) { //agregar "controlador" para userControl currentControl = new ControlMenu(); currentControl.Dock = DockStyle.Fill; Controls.Add(currentControl); currentControl.Width = Width; currentControl.Height = Height; }
public SourceTabView(Model model, TabControl tab, NewControl nc) { this.model = model; this.tab = tab; this.nc = nc; model.ObjectChangedHandler += new ObjectChangedEventHandler(this.ObjectChanged); foreach (object o in model.Roots) { this.AddRoot(o); } this.ObjectChanged(); }
//Método para cambio de userControl public void ChangeControl(NewControl newControl) { if (newControl == null) { throw new ArgumentNullException("newControl"); } //remover userControl actual if (currentControl != null) { this.Controls.Remove(currentControl); } //Crear nuevo userControl y definir dimensiones currentControl = newControl; currentControl.Width = Width; currentControl.Height = Height; //agregar userControl this.Controls.Add(newControl); }
//Método definir userControl a cambiar public void ShowControl(NewControl control) { //cambiando currentUserControl this.ChangeControl(control); }
private void OnNewControl(Control control) { NewControl?.Invoke(control); }