void AddContronToPannel(Fwk.UI.Controls.Menu.Tree.MenuItem item, object obj) { using (WaitCursorHelper w = new WaitCursorHelper(this)) { Xtra_UC_Base ctrl = null; Type T = Fwk.HelperFunctions.ReflectionFunctions.CreateType(item.AssemblyInfo); if (!controls.Contains(string.Concat(T.Name, item.ID))) { ctrl = (Xtra_UC_Base)Fwk.HelperFunctions.ReflectionFunctions.CreateInstance(item.AssemblyInfo); ctrl.Tag = item.Tag; ctrl.Key = string.Concat(T.Name, item.ID); this.panelControl1.Controls.Add(ctrl); controls.Add(ctrl.Key); ctrl.Dock = System.Windows.Forms.DockStyle.Fill; ctrl.OnExitControlEvent += new EventHandler(ctrl_OnExitControlEvent); ctrl.Populate(obj); //ctrl.Populate(null); } else { int i = this.panelControl1.Controls.IndexOfKey(T.Name); ctrl = (Xtra_UC_Base)this.panelControl1.Controls[i]; } btnClose.Visible = ctrl.ShowClose; btnSaveChanges.Visible = ctrl.ShowSave; CurrentControl = ctrl; ctrl.BringToFront(); ctrl.Refresh(); } }
void RemoveControlFromPannel(Xtra_UC_Base ctrl) { if (ctrl != null) { ctrl.Exit(); if (this.panelControl1.Contains(ctrl)) { this.panelControl1.Controls.Remove(ctrl); controls.Remove(ctrl.Key); if (this.panelControl1.Controls.Count != 0) { using (WaitCursorHelper w = new WaitCursorHelper(this)) { btnClose.Visible = ctrl.ShowClose; btnSaveChanges.Visible = ctrl.ShowSave; ctrl = (Xtra_UC_Base)this.panelControl1.Controls[0]; ctrl.Refresh(); } } } } }