void userInfo_ShowPHR(UCUserInfo sender, Userinfo obj) { sender.ShowWaitingPanel(() => new PHRMain(obj), x => ((PHRMain)x).Show(this), "加载中...请稍候"); }
/// <summary> /// 显示Mdi窗体 /// </summary> /// <param name="ucControl"></param> public void ShowMdiForm(UCBase ucControl) { try { Type ucType = ucControl.GetType(); if (ucType.BaseType != typeof(UCBase) && ucType.BaseType.BaseType != typeof(UCBase)) { return; //类型不正确 返回 } if (mdiForms.ContainsKey(ucType)) //限定同一类型控件只能打开一个 { if (mdiForms[ucType] != null) { mdiForms[ucType].Activate(); return; } else { mdiForms.Remove(ucType); } } mdiForms.Add(ucType, null); //this.ShowWaitingPanel(() => //{ if (ucControl is UCMainPage) { UCMainPage mainPage = (UCMainPage)ucControl; mainPage.BtnClick += ShowMdiForm; } if (ucControl is UCUserInfo) { UCUserInfo userInfo = (UCUserInfo)ucControl; userInfo.ShowPHR += userInfo_ShowPHR; } // return ucBase; // }, x => //{ // UCBase ucBase = (UCBase)x; RibbonForm mdiFrm = new RibbonForm() { MdiParent = this, Text = ucControl.Title, Dock = DockStyle.Fill }; ucControl.Dock = DockStyle.Fill; mdiFrm.Controls.Add(ucControl); mdiFrm.FormClosing += (object sender, FormClosingEventArgs e) => { if (e.CloseReason == CloseReason.UserClosing && !loginOut) { if (ucControl is UCMainPage) //阻止关闭主页 { e.Cancel = true; } } }; mdiFrm.Disposed += (object sender, EventArgs e) => { if (mdiForms.ContainsKey(ucType)) { if (!loginOut) { mdiForms.Remove(ucType); } } GC.Collect(); }; mdiForms[ucType] = mdiFrm; mdiFrm.Show(); // }); } catch (Exception e) { throw new Exception("打开Mdi窗体出错!原因:" + e.Message); } }