/// <summary> /// 隐藏当前窗口 /// </summary> public void HidePopWindow() { if (currentPop != null) { currentPop.Hide(); } currentPop = null; }
/// <summary> /// 释放当前窗口 /// </summary> /// <param name="window">窗口实例</param> public void ReleasePopWindow(PopWindow window) { pops.Remove(window); if (currentPop == window) { currentPop = null; } window.Dispose(); }
/// <summary> /// 资源释放 /// </summary> public override void Dispose() { if (pops != null) { for (int i = 0; i < pops.Count; i++) { pops[i].Dispose(); } } pops.Clear(); currentPop = null; base.Dispose(); }
/// <summary> /// 移除窗口 /// </summary> /// <typeparam name="T">窗口类型</typeparam> public void ReleasePopWindow <T>() { for (int i = 0; i < pops.Count; i++) { if (pops[i] is T) { pops[i].Dispose(); pops.RemoveAt(i); break; } } if (currentPop is T) { currentPop = null; } }
/// <summary> /// 显示一个窗口 /// </summary> /// <param name="type">窗口类型</param> /// <param name="obj">数据</param> /// <param name="parent">父坐标变换,为空则默认为当前页的父坐标变换</param> /// <returns></returns> protected object ShowPopWindow(Type type, object obj = null, UIElement parent = null) { if (currentPop != null) { currentPop.Hide(); currentPop = null; } for (int i = 0; i < pops.Count; i++) { if (pops[i].GetType() == type) { currentPop = pops[i]; pops[i].Show(obj); if (pops[i].CurLan != LanName) { pops[i].ChangeLanguage(); } return(pops[i]); } } var t = Activator.CreateInstance(type) as PopWindow; pops.Add(t); currentPop = t; if (parent == null) { t.Initial(Parent, this, obj); } else { t.Initial(parent, this, obj); } t.ChangeLanguage(); t.ReSize(); return(t); }
/// <summary> /// 显示一个窗口 /// </summary> /// <typeparam name="T">窗口类型</typeparam> /// <param name="obj">数据</param> /// <param name="parent">父坐标变换,为空则默认为当前页的父坐标变换</param> /// <returns></returns> protected T ShowPopWindow <T>(object obj = null, UIElement parent = null) where T : PopWindow, new() { if (currentPop != null) { currentPop.Hide(); currentPop = null; } for (int i = 0; i < pops.Count; i++) { if (pops[i] is T) { currentPop = pops[i]; pops[i].Show(obj); if (pops[i].CurLan != LanName) { pops[i].ChangeLanguage(); } return(pops[i] as T); } } var t = new T(); pops.Add(t); currentPop = t; if (parent == null) { t.Initial(Parent, this, obj); } else { t.Initial(parent, this, obj); } t.ChangeLanguage(); t.ReSize(); return(t); }