public void ActualizarControl() { if (FormActions == null) { PanelPrimario.Controls.Clear(); return; } this.SuspendLayout(); PanelPrimario.SuspendLayout(); // Primero elimino los botones que ya no están en la lista foreach (System.Windows.Forms.Control btn in PanelPrimario.Controls) { if (btn is Lui.Forms.LinkLabel) { if (FormActions.ContainsKey(btn.Name) == false) { // No existe... lo elimino PanelPrimario.Controls.Remove(btn); btn.Dispose(); } else if (FormActions[btn.Name].Visibility != Lazaro.Pres.Forms.FormActionVisibility.Tertiary) { // Existe... pero no en el panel terciario PanelPrimario.Controls.Remove(btn); btn.Dispose(); } } } // Ahora agrego o actualizo los botones existentes foreach (Lazaro.Pres.Forms.FormAction act in this.FormActions) { if (act.Visibility == Lazaro.Pres.Forms.FormActionVisibility.Tertiary) { if (PanelPrimario.Controls.ContainsKey(act.Name)) { // Existe, lo actualizo Lui.Forms.LinkLabel Btn = PanelPrimario.Controls[act.Name] as Lui.Forms.LinkLabel; Btn.Text = act.Text; Btn.Enabled = act.Enabled; } else { // No existe, lo agrego Lui.Forms.LinkLabel Btn = new Lui.Forms.LinkLabel(); Btn.Margin = new System.Windows.Forms.Padding(4, 0, 0, 0); Btn.Name = act.Name; Btn.Text = act.Text; Btn.Enabled = act.Enabled; Btn.TabIndex = act.TabIndex; Btn.AutoSize = true; //Btn.Size = new System.Drawing.Size(96, PanelPrimario.ClientRectangle.Height); Btn.Visible = true; Btn.LinkClicked += new LinkLabelLinkClickedEventHandler(this.Btn_LinkClicked); PanelPrimario.Controls.Add(Btn); } } } PanelPrimario.ResumeLayout(true); this.ResumeLayout(true); }
private void LowerPanel_ButtonClick(object sender, EventArgs e) { string ActionName = null; Lui.Forms.Button SenderButton = sender as Lui.Forms.Button; if (SenderButton != null) { ActionName = SenderButton.Name; } else { Lui.Forms.LinkLabel SenderLinkLabel = sender as Lui.Forms.LinkLabel; if (SenderLinkLabel != null) { ActionName = SenderLinkLabel.Name; } } if (ActionName != null) { // doy la oportunidad de que lo procese el ControlUnico. Lfx.Types.OperationResult Res = this.ControlUnico.PerformFormAction(ActionName); if (Res != null) { if (Res.Success == false && Res.Cancel == false && Res.Message != null) { Lfx.Workspace.Master.RunTime.Toast(Res.Message, "Error"); } } else { // No lo procesó, así que puedo hacerlo yo switch (ActionName) { case "aceptar": Guardar(); break; case "cancelar": Cancelar(); break; case "imprimir": Imprimir(); break; case "comentarios": EditarComentarios(); break; case "historial": MostrarHistorial(); break; case "panelextendido": EditarPanelExtendido(); break; } } } }