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(); } }
void ctrl_OnExitControlEvent(Xtra_UC_Base sender, PanelControl panel) { if (panel.Contains(sender)) { RemoveControlFromPannel((Xtra_UC_Base)sender); } }
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(); } }
public Xtra_UC_Base GetControlFromPanel(String controlKey, PanelControl panel) { Xtra_UC_Base userControl = null; foreach (System.Windows.Forms.Control c in panel.Controls) { if (c.GetType().IsSubclassOf(typeof(Xtra_UC_Base))) { if (((Xtra_UC_Base)c).Key.Equals(controlKey)) { userControl = (Xtra_UC_Base)c; break; } } } return(userControl); }
public void RemoveControlFromPannel(Xtra_UC_Base ctrl) { PanelControl panel = ctrl.ParentPanel; if (ctrl != null) { ctrl.Exit(); if (panel.Contains(ctrl)) { panel.Controls.Remove(ctrl); controls.Remove(ctrl.Key); if (panel.Controls.Count != 0) { using (WaitCursorHelper w = new WaitCursorHelper(ParentForm)) { ctrl = (Xtra_UC_Base)ctrl.ParentPanel.Controls[0]; ctrl.Refresh(); } } } } }
/// <summary> /// /// </summary> /// <param name="luncherControl"></param> /// <param name="panelEnum"></param> /// <param name="menuItem"></param> /// <param name="populateObject"></param> protected void ctrl_OnLunchUserControlEvent(Xtra_UC_Base luncherControl, PanelEnum panelEnum, Fwk.UI.Controls.Menu.Tree.MenuItem menuItem, Object populateObject) { AddContronToPannel(panelEnum, menuItem, populateObject); }
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(); } }
protected void RemoveControlFromPannel(Xtra_UC_Base ctrl) { userContrlManager1.RemoveControlFromPannel(ctrl); }
protected void AddContronToPannel(PanelEnum panelEnum, Xtra_UC_Base userControl, object obj) { userContrlManager1.AddContronToPannel(panelEnum,userControl,obj); }