Esempio n. 1
0
        /// <summary>
        /// This method will be called is this project form is closed or when
        /// the main form is closed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ProjectForm2_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            bool theMainFormIsClosing = true;

            // We don't know if calling of this method this is a consequence of closing this project form or
            // as a consequence of closing the main form.
            // The following code is needed to find this out (see the Form class Closing event in MSDN)
            if (((MainForm)ParentForm)._IsClosing)
            {
                // Closing is done through the Exit menu item.
                theMainFormIsClosing = true;
            }
            else
            {
                // The position of the cursor in screen coordinates.
                Point theCursorPosition = Cursor.Position;

                if ((ParentForm.Top + SystemInformation.CaptionHeight) < theCursorPosition.Y)
                {
                    theMainFormIsClosing = false;
                }
                else
                {
                    theMainFormIsClosing = true;
                }
            }

            // Close if allowed.
            if (theMainFormIsClosing)
            {
                // Don't do anything.
                // The Main form will also receive a closing event and handle the closing of the application.
            }
            else
            {
                e.Cancel = false;
                MainForm theMainForm = (MainForm)ParentForm;
                DialogResult theDialogResult;

                if (IsExecuting())
                {
                    // Ask the user if execution needs to be stopped.
                    theDialogResult = MessageBox.Show("Executing is still going on.\nStop execution?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                    if (theDialogResult == DialogResult.Yes)
                    {
                        // Stop the execution.
                        Notify(new StopExecution(this));

                        // Because execution is performed in a different thread, wait some
                        // time to enable the execution to stop. Also give feedback to the user
                        // of this waiting by showing a form stating this.
                        TimerMessageForm theTimerMessageForm = new TimerMessageForm();

                        theTimerMessageForm.ShowDialogSpecifiedTime("Stopping execution...", 3000);

                        // Find out if execution really has stopped.
                        if (IsExecuting())
                        {
                            theDialogResult = MessageBox.Show("Failed to stop execution.\n This form will not be closed.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            e.Cancel = true;
                        }
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                }

                if (ParentForm.MdiChildren.Length == 1)
                {
                    // This is the last project form that is being closed,
                    // so the project needs to be closed.
                    if (!e.Cancel)
                    {
                        // e.Cancel is false, so no execution takes place any more.
                        // Close the project.
                        // If unsaved changes exist, give the user the possibility to save them.
                        if (projectApp.AreProjectOrSessionsChanged())
                        {
                            _MainForm.Save(true);
                        }

                        if (projectApp.HasUserCancelledLastOperation())
                        {
                            // The user has cancelled the close operation.
                            // Cancel the closing of this last project form.
                            e.Cancel = true;
                        }
                        else
                        {
                            // The user has not cancelled the close operation.
                            projectApp.Close(true);
                            projectApp = null;
                            Notify(new ProjectClosed());
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="theProject"></param>
        /// <param name="theMainForm"></param>
        public ProjectForm2(DvtkApplicationLayer.Project theProject, MainForm theMainForm)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.userControlSessionTree.projectApp = theProject;
            userControlSessionTree.ProjectForm = this;
            _ActivityReportEventHandler = new Dvtk.Events.ActivityReportEventHandler(TCM_OnActivityReportEvent);
            projectApp = theProject;
            _MainForm = theMainForm;
            ListBoxSecuritySettings.SelectedIndex = 0;
            _SopClassesManager = new SopClassesManager(this, DataGridSpecifySopClasses, ComboBoxSpecifySopClassesAeTitle, ListBoxSpecifySopClassesDefinitionFileDirectories, RichTextBoxSpecifySopClassesInfo, userControlSessionTree, ButtonSpecifySopClassesRemoveDirectory);
            _TCM_ValidationResultsBrowser = new ValidationResultsManager(webBrowserValResult);
            //_TCM_ValidationResultsManagerBrowser = new ValidationResultsManager(webBrowserResultMgr);

            // Because the webbrowser navigation is "cancelled" when browsing to an .xml file
            // first another html file has to be shown to make this work under Windows 2000.
            _TCM_ValidationResultsBrowser.ShowHtml("about:blank");
            _TCM_AppendTextToActivityLogging_ThreadSafe_Delegate = new TCM_AppendTextToActivityLogging_ThreadSafe_Delegate(this.TCM_AppendTextToActivityLogging_ThreadSafe);

            resultProjectXml  = projectApp.ProjectFileName + ".xml";
        }