コード例 #1
0
        /// <summary>
        /// Aktiviert eine Aufgabe.
        /// </summary>
        /// <param name="sender">Wird ignoriert.</param>
        /// <param name="e">Wird ignoriert.</param>
        private void cmdFinish_Click(object sender, EventArgs e)
        {
            // We are active
            if (m_Running)
            {
                // Not again
                cmdFinish.Enabled = false;

                // Remember
                m_Cancelled = true;

                // Leave
                return;
            }

            // Be safe
            try
            {
                // Are we allowed to do this
                if (!CurrentStep.CanStartOperation())
                {
                    return;
                }

                // Forward
                bool finished = CurrentStep.StartOperation();

                // Set flags
                m_Cancelled = false;
                m_Running   = true;

                // We are now runnig
                cmdNext.Enabled = false;
                cmdPrev.Enabled = false;

                // See if we can cancel
                if (CurrentStep.CanCancel)
                {
                    cmdFinish.Text = Properties.Resources.Button_Cancel;
                }
                else
                {
                    cmdFinish.Enabled = false;
                }

                // Auto terminate for synchronous operations
                if (finished)
                {
                    ((IPlugInUISite)this).OperationDone();
                }
            }
            catch (Exception ex)
            {
                // Report
                MessageBox.Show(this, ex.Message, Text);
            }
        }