コード例 #1
0
ファイル: PanelStack.cs プロジェクト: zezo010/acat
        /// <summary>
        /// Shows 'panel'.  'parent' is the form making the call to show.
        /// If 'showAsDialog' is true, shows panel as the Dialog with 'parent'
        /// as the parent form. Else, just shows 'panel'. Also Pauses the parent
        /// scanner.  It will be Resumed when the panel is closed.
        /// </summary>
        /// <param name="parent">parent panel</param>
        /// <param name="panel">panel to show</param>
        /// <param name="displayMode">how to display the panel</param>
        /// <returns>true on success</returns>
        private bool show(IPanel parent, IPanel panel, DisplayModeTypes displayMode)
        {
            Form panelForm  = (Form)panel;
            Form parentForm = (Form)parent;

            Log.Debug("parentForm: " + ((parentForm != null) ? parentForm.Name : " null") +
                      ".  panel: " + panelForm.Name);

            panelForm.FormClosed += panel_FormClosed;

            _currentForm = panelForm;

            PreShowPanel            = panel;
            PreShowPanelDisplayMode = displayMode;

            if (parent != null)
            {
                parent.OnPause();

                if (displayMode == DisplayModeTypes.Dialog)
                {
                    Log.Debug("Showing Dialog" + panelForm.Name + " with parent " + parentForm.Name);

                    auditLogScannerEvent(panelForm, "show");
                    Context.AppPanelManager.NotifyPanelPreShow(new PanelPreShowEventArg(panel, displayMode));
                    Windows.ShowDialog(parentForm, panelForm);
                }
                else
                {
                    Log.Debug("Showing " + panelForm.Name);

                    Log.Debug("parent is not null. Setting _currentPanel to " + panelForm.Name +
                              ", type: " + panelForm.GetType());
                    _currentPanel = panelForm;
                    auditLogScannerEvent(panelForm, "show");

                    Context.AppPanelManager.NotifyPanelPreShow(new PanelPreShowEventArg(panel, displayMode));

                    Windows.Show(parentForm, panelForm);
                }
            }
            else
            {
                Log.Debug("showing " + panelForm.Name + ", parent is null");
                Log.Debug("parent is null. Setting _currentPanel to " + panelForm.Name +
                          ", type: " + panelForm.GetType());

                _currentPanel = panelForm;

                auditLogScannerEvent(panelForm, "show");
                if (displayMode == DisplayModeTypes.Dialog)
                {
                    Context.AppPanelManager.NotifyPanelPreShow(new PanelPreShowEventArg(panel, displayMode));

                    panelForm.ShowDialog();
                }
                else
                {
                    Context.AppPanelManager.NotifyPanelPreShow(new PanelPreShowEventArg(panel, displayMode));

                    Windows.ShowForm(panelForm);
                }
            }

            PreShowPanel            = null;
            PreShowPanelDisplayMode = DisplayModeTypes.None;

            return(true);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 /// <param name="panel">scanner being shown</param>
 public PanelPreShowEventArg(IPanel panel, DisplayModeTypes dislayMode)
 {
     Panel       = panel;
     DisplayMode = dislayMode;
 }