예제 #1
0
        /// <summary>
        /// Handle selection of panels to display, including updating buttons.
        /// </summary>
        /// <param name="mainForm"></param>
        /// <param name="sender"></param>
        /// <param name="containerPanel"></param>
        /// <param name="panelToActivate">New panel</param>
        /// <param name="panelNarrativeText">Text pulled from RTF to display as header</param>
        /// <param name="clickOption"></param>
        public static void ActivateActionPanel(FrmQreMain mainForm, Button sender, Panel containerPanel,
                                               UserControl panelToActivate, string panelNarrativeText,
                                               ApButtonClickOption clickOption = ApButtonClickOption.PerformClick)
        {
            mainForm.SuspendLayout();
            try
            {
                var panelThatOwnsCaller = (Panel)sender.Parent;
                containerPanel.Controls.Clear();
                if (panelThatOwnsCaller != null)
                {
                    UiStateRoutines.UnselectButtons(panelThatOwnsCaller);
                }

                UiStateRoutines.UnselectButtons(containerPanel);
                sender.ForeColor = Color.Green;

                // Clear unneeded controls
                foreach (Control thisControl in containerPanel.Controls)
                {
                    if (thisControl is Button)
                    {
                        containerPanel.Controls.Remove(thisControl);
                    }
                }

                panelToActivate.Dock = DockStyle.Fill;
                containerPanel.Controls.Add(panelToActivate);
                ActiveScreen.lblActionNarrative.Text = panelNarrativeText;
                if (clickOption == ApButtonClickOption.PerformClick)
                {
                    var firstButton = QuickFunctions.GetTopButton(panelToActivate, ChildNavOptions.NavigateChildren);
                    if (firstButton != null)
                    {
                        firstButton.PerformClick();
                    }
                    else
                    {
                        MessageBox.Show(@"Cannot perform click for the " + panelToActivate.GetType().Name +
                                        @" action panel because it contains no buttons.");
                    }
                }
            }
            finally
            {
                mainForm.ResumeLayout();
            }
        }
예제 #2
0
        public static void SetContentScreen(Button caller, UserControl controlToUse)
        {
            UiStateRoutines.UnselectButtons(caller.Parent);

            controlToUse.Dock = DockStyle.Fill;
            var cpParent = new ContentPanel();

            FrmQreMain.UpdateControls(cpParent);

            cpParent.Dock         = DockStyle.Fill;
            cpParent.ChildControl = controlToUse;
            _mActiveContentPanel  = (IQraBaseNotify)controlToUse;

            caller.ForeColor = Color.Green;
            _mActiveContentPanel.Notify_LoadComplete();
        }
예제 #3
0
        private void btnConsequenceModels_Click(object sender, EventArgs e)
        {
            try
            {
                UiStateRoutines.UnselectButtons(this);
                var actionsNarrative = "Output";
                ResultsActionPanel = new ApOutputNavigator();
                ActivateActionPanel(this, (Button)sender, pnlActionButtons, ResultsActionPanel, actionsNarrative,
                                    ApButtonClickOption.NoClick);

                ActionUtils.SetContentScreen((Button)sender, new CpConsequenceModels());
            }
            catch (Exception ex)
            {
                Trace.TraceError(Environment.StackTrace);
                MessageBox.Show(genericNavErrorMsg + ex.Message);
            }
        }
예제 #4
0
        /// <summary>
        /// Display result panels
        /// </summary>
        private void btnSystemDescription_Click(object sender, EventArgs e)
        {
            try
            {
                UiStateRoutines.UnselectButtons(this);

                var actionsNarrative = "Output";
                ActivateActionPanel(this, (Button)sender, pnlActionButtons, new ApOutputNavigator(),
                                    actionsNarrative, ApButtonClickOption.NoClick);

                UserControl newControl = new CpSystemDescription();
                ActionUtils.SetContentScreen((Button)sender, newControl);
            }
            catch (Exception ex)
            {
                Trace.TraceError(Environment.StackTrace);
                MessageBox.Show(genericNavErrorMsg + ex.Message);
            }
        }
예제 #5
0
        /// <summary>
        ///     Set up progress screen and execute analysis task.
        ///     Callback will be called once analysis is complete.
        /// </summary>
        /// <param name="sender"></param>
        private void PrepForAnalysis(Button sender)
        {
            try
            {
                UiStateRoutines.UnselectButtons(FindForm());
                _progressCp = new ProgressDisplay();
                ActionUtils.SetContentScreen(sender, _progressCp);

                FrmQreMain.ActiveScreen.DisableNavigation(); // ugly way to ensure user can't navigate away
                _analysisToken = new CancellationTokenSource();
                //var StartTime = DateTime.Now;
                var task = Task.Factory.StartNew(ConductAnalysis, _analysisToken.Token);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                MessageBox.Show("Action failed with this error: " + ex.Message);
            }
        }
예제 #6
0
        private void ChangePanel(string actionsNarrative, object sender, UserControl nextControl)
        {
            try
            {
                // Track displayed control and free up resources when it changes
                if (_currentControl != null)
                {
                    _currentControl.Dispose();
                }
                _currentControl = nextControl;

                UiStateRoutines.UnselectButtons(this);
                ResultsActionPanel = new ApOutputNavigator();
                ActivateActionPanel(this, (Button)sender, pnlActionButtons, ResultsActionPanel, actionsNarrative,
                                    ApButtonClickOption.NoClick);
                ActionUtils.SetContentScreen((Button)sender, nextControl);
            }
            catch (Exception ex)
            {
                Trace.TraceError(Environment.StackTrace);
                MessageBox.Show(genericNavErrorMsg + ex.Message);
            }
        }