Exemplo n.º 1
0
 private MainModuleForm getExistingForm(MainModuleForm pForm) {
     MainModuleForm existingForm = null;
     // Iterar por los controles, obteniendo el formulario si existe
     foreach (Control control in this.centerBoxPanel.Controls)
     {
         MainModuleForm currentForm = control as MainModuleForm;
         int formType = currentForm.type;
         // Hacer match de los tipos de formulario
         if (formType == pForm.type)
         {
             existingForm = currentForm;
         }
     }
     return existingForm;
 }
Exemplo n.º 2
0
 public void showFormInMainPanel(MainModuleForm pForm, DateTime? pDrawDate = null, long pGroupId = 0, bool pUpdateBox=false)
 {
     MainModuleForm existingForm = getExistingForm(pForm);
     // Validar si existe o no el formulario
     if (existingForm == null)
     {
         this.centerBoxPanel.Hide();
         // Agregar BoxNumber al AppMediator
         if (pForm.type == SystemConstants.NUMBER_BOX_CODE)
         {
             this.mediator.appNumberBox = (NumberBoxForm) pForm;
         }
         // Agregar a la aplicación el nuevo formulario si no existe
         MainModuleForm formToAdd = pForm as MainModuleForm;
         formToAdd.TopLevel = false;
         formToAdd.Dock = DockStyle.Fill;
         this.centerBoxPanel.Controls.Add(formToAdd);
         this.centerBoxPanel.Tag = formToAdd;
         formToAdd.Show();
         formToAdd.BringToFront();
         this.mediator.updateBoxNumber(0, DateTime.Today);
         this.centerBoxPanel.Show();
     }
     else
     {
         // Destruir el formulario nuevo y mostrar el existente
         pForm.Dispose();
         if (this.activeFormType != existingForm.type || pUpdateBox)
         //if(true)
         {
             this.centerBoxPanel.Hide();
             existingForm.BringToFront();
             // Si se trae al frente un NumberBoxForm, se debe actualizar
             if (existingForm.type == SystemConstants.NUMBER_BOX_CODE)
             {
                 NumberBoxForm numberBox = (NumberBoxForm)existingForm;
                 numberBox.updateNumberBox(pDrawDate, pGroupId);
             }
             else
             {
                 this.mediator.updateBoxNumber(0, DateTime.Today);
             }
             this.centerBoxPanel.Show();
         }
     }
     this.activeFormType = pForm.type;
 }