/// <summary> /// 出栈 ,把页面从界面上移除 /// </summary> public void PopPanel() { if (m_panelStack == null) { m_panelStack = new Stack <IPanel>(); } if (m_panelStack.Count <= 0) { return; } //关闭栈顶页面的显示 IPanel topPanel = m_panelStack.Pop(); topPanel.OnExit(); if (m_panelStack.Count <= 0) { return; } IPanel topPanel2 = m_panelStack.Peek(); topPanel2.OnResume(); }
/// <summary> /// A scanner closed. If this panel has child windows (scanners) /// close them as well. If there is a parent, Resume it. /// </summary> /// <param name="sender">event sender</param> /// <param name="e">event args</param> private void panel_FormClosed(object sender, FormClosedEventArgs e) { var form = (Form)sender; Log.Debug("Enter (" + form.Name + ")"); IPanel panel = form as IPanel; if (panel.SyncObj.Status == SyncLock.StatusValues.Closed) { Log.Debug("Form is already closed. Returning " + form.Name); return; } Log.Debug("Setting CLOSED for " + form.Name); (form as IPanel).SyncObj.Status = SyncLock.StatusValues.Closed; form.FormClosed -= panel_FormClosed; Form parentForm = form.Owner; Form[] array = form.OwnedForms; auditLogScannerEvent(form, "close"); Log.Debug("number of owned forms: " + array.Length); // close all the forms this panel owns while (true) { Form[] ownedForms = form.OwnedForms; if (ownedForms.Length == 0) { Log.Debug(form.Name + ": No more owned forms. Breaking"); break; } Log.Debug("Removing owned form from list. " + ownedForms[0].Name); form.RemoveOwnedForm(ownedForms[0]); Log.Debug("Calling close on " + ownedForms[0].Name); Windows.CloseForm(ownedForms[0]); } Log.Debug("form Name: " + form.Name + ", type: " + form.GetType()); // Exit the application if instructed to do so. if (Context.AppQuit) { if (!_appCloseNotifed) { _appCloseNotifed = true; Context.AppPanelManager.NotifyQuitApplication(); Application.ExitThread(); } } else if (parentForm != null) { // Resume the parent if it is prudent to do so. Log.Debug("parent Form is " + parentForm.Name); IPanel parentPanel = (IPanel)parentForm; if (parentPanel.SyncObj.IsClosing()) { Log.Debug("*** Parent is closing. Will not call OnResume"); } else { Log.Debug("parentform is not closing. Setting _currentPanel to " + parentForm.Name + ", type: " + parentForm.GetType()); _currentPanel = parentForm; _currentForm = parentForm; Log.Debug("Calling OnResume on parentForm " + parentForm.Name); parentPanel.OnResume(); //_currentPanel = parentForm; // moved up //_currentForm = parentForm; // moved up auditLogScannerEvent(parentForm, "show"); } } else { Log.Debug("parentform is null"); _currentPanel = null; _currentForm = null; } var panelClass = (form is IScannerPanel) ? ((IScannerPanel)form).PanelClass : PanelClasses.None; if (!PanelConfigMap.AreEqual(panelClass, PanelClasses.None)) { Log.Debug("Calling AppAgentMgr.OnPanelClosed for " + panelClass); Context.AppAgentMgr.OnPanelClosed(panelClass); } if (EvtScannerClosed != null) { Log.Debug("Calling evetscannerclosed for " + form.Name); EvtScannerClosed(this, new ScannerCloseEventArg(form as IPanel)); } else { Log.Debug("EvtScannerClosed is NULL"); } // (form as IPanel).SyncObj.Status = SyncLock.StatusValues.Closed; // moved this up Log.Debug("Exit " + form.Name); }
/// <summary> /// A scanner closed. If this panel has child windows (scanners) /// close them as well. If there is a parent, Resume it. /// </summary> /// <param name="sender">event sender</param> /// <param name="e">event args</param> private void panel_FormClosed(object sender, FormClosedEventArgs e) { var form = (Form)sender; Log.Debug("Enter (" + form.Name + ")"); IPanel panel = form as IPanel; if (panel.SyncObj.Status == SyncLock.StatusValues.Closed) { Log.Debug("Form is already closed. Returning " + form.Name); return; } form.FormClosed -= panel_FormClosed; Form parentForm = form.Owner; String panelClass = PanelClasses.None; Form[] array = form.OwnedForms; auditLogScannerEvent(form, "close"); Log.Debug("number of owned forms: " + array.Length); // close all the forms this panel owns while (true) { Form[] a = form.OwnedForms; if (a.Length == 0) { Log.Debug(form.Name + ": No more owned forms. Breaking"); break; } Log.Debug("Removing owned form from list. " + a[0].Name); form.RemoveOwnedForm(a[0]); Log.Debug("Calling close on " + a[0].Name); Windows.CloseForm(a[0]); } Log.Debug("form Name: " + form.Name + ", type: " + form.GetType()); if (_currentPanel is IScannerPanel) { panelClass = ((IScannerPanel)_currentPanel).PanelClass; } // Exit the application if instructed to do so. if (Context.AppQuit) { Application.ExitThread(); } else if (parentForm != null) { // Resume the parent if it is prudent to do so. Log.Debug("parent Form is " + parentForm.Name); IPanel parentPanel = (IPanel)parentForm; if (parentPanel.SyncObj.IsClosing()) { Log.Debug("*** Parent is closing. Will not call OnResume"); } else { Log.Debug("Calling OnResume on parentForm " + parentForm.Name); parentPanel.OnResume(); Log.Debug("parentform is not null. Setting _currentPanel to " + parentForm.Name + ", type: " + parentForm.GetType()); _currentPanel = parentForm; _currentForm = parentForm; auditLogScannerEvent(parentForm, "show"); } } else { Log.Debug("parentform is null"); } // Inform the AgentManager that a scanner just closed if (!PanelConfigMap.AreEqual(panelClass, PanelClasses.None)) { Log.Debug("Calling OnPanelClosed for " + panelClass); Context.AppAgentMgr.OnPanelClosed(panelClass); } Log.Debug("Setting CLOSED for " + form.Name); (form as IPanel).SyncObj.Status = SyncLock.StatusValues.Closed; Log.Debug("Exit " + form.Name); }