public void AddContronToPannel(PanelEnum panelEnum, Xtra_UC_Base userControl, object obj) { var panel = ((IfrmMainBase)_ParentForm).Get_Panel(panelEnum); using (WaitCursorHelper w = new WaitCursorHelper(_ParentForm)) { Type T = userControl.GetType(); ///Si no fue agregado lo agega al contenedor if (!controls.Contains(userControl.Key)) { userControl.ParentPanel = panel; panel.Controls.Add(userControl); controls.Add(userControl.Key); userControl.Dock = System.Windows.Forms.DockStyle.Fill; userControl.OnExitControlEvent += new ExitControlHandler(ctrl_OnExitControlEvent); userControl.OnLunchUserControlEvent += ctrl_OnLunchUserControlEvent; userControl.Populate(obj); } CurrentControl = userControl; userControl.BringToFront(); userControl.Refresh(); } }
public void AddContronToPannel(DevExpress.XtraEditors.PanelControl panel, Fwk.UI.Controls.Menu.Tree.MenuItem item, object obj) { using (WaitCursorHelper w = new WaitCursorHelper(_ParentForm)) { Xtra_UC_Base ctrl = null; Type T = null; try { T = Fwk.HelperFunctions.ReflectionFunctions.CreateType(item.AssemblyInfo); } catch (FileNotFoundException fe) { TechnicalException te = new Fwk.Exceptions.TechnicalException(String.Concat("No se puede cargar el user control por q falta el archivo ", fe.FileName, "\r\n o alguna dependencia")); throw te; } catch (System.TypeLoadException) { TechnicalException te = null; if (item.AssemblyInfo.Split(',').Count() == 2) { te = new Fwk.Exceptions.TechnicalException(String.Concat("No se puede cargar el user control [", item.AssemblyInfo.Split(',')[0], "] en el archivo ", item.AssemblyInfo.Split(',')[1])); } te = new Fwk.Exceptions.TechnicalException(String.Concat("No se puede cargar el user control definido en [", item.AssemblyInfo, "]")); throw te; } catch (Exception ex) { TechnicalException te = new TechnicalException(String.Concat("No se puede cargar el user control ", item.AssemblyInfo, " ", ex.Message)); throw te; } if (!controls.Contains(string.Concat(T.FullName, item.ID))) { ctrl = (Xtra_UC_Base)Fwk.HelperFunctions.ReflectionFunctions.CreateInstance(item.AssemblyInfo); ctrl.ParentPanel = panel; ctrl.Tag = item.Tag; ctrl.Key = item.ID.ToString(); panel.Controls.Add(ctrl); controls.Add(ctrl.Key); ctrl.Dock = System.Windows.Forms.DockStyle.Fill; ctrl.OnExitControlEvent += new ExitControlHandler(ctrl_OnExitControlEvent); ctrl.OnLunchUserControlEvent += ctrl_OnLunchUserControlEvent; ctrl.Populate(obj); } else { ctrl = GetControlFromPanel(string.Concat(T.FullName, item.ID), panel); } CurrentControl = ctrl; ctrl.BringToFront(); ctrl.Refresh(); } }