SendCommand() public static méthode

public static SendCommand ( Object sender, RunCommandEventArgs runCommandEventArgs ) : void
sender Object
runCommandEventArgs RunCommandEventArgs
Résultat void
Exemple #1
0
        RunEditableCommand
        (
            RunEditableCommandEventArgs oRunEditableCommandEventArgs,
            ThisWorkbook oThisWorkbook
        )
        {
            Debug.Assert(oRunEditableCommandEventArgs != null);
            Debug.Assert(oThisWorkbook != null);

            // Arbitrarily use the workbook as the sender here.  TaskAutomator
            // can't be used, because it's static.

            CommandDispatcher.SendCommand(oThisWorkbook,
                                          oRunEditableCommandEventArgs);

            return(oRunEditableCommandEventArgs.CommandSuccessfullyRun);
        }
Exemple #2
0
        btnOK_Click
        (
            object sender,
            System.EventArgs e
        )
        {
            if (!DoDataExchange(true))
            {
                return;
            }

            m_oAutomateTasksUserSettings.Save();

            try
            {
                if (m_eMode == DialogMode.EditOnly)
                {
                    // (Just close the dialog.)
                }
                else if (m_oAutomateTasksUserSettings.AutomateThisWorkbookOnly)
                {
                    Debug.Assert(m_oNodeXLControl != null);

                    TaskAutomator.AutomateOneWorkbook(m_oThisWorkbook,
                                                      m_oNodeXLControl, m_oAutomateTasksUserSettings.TasksToRun,
                                                      m_oAutomateTasksUserSettings.FolderToSaveWorkbookTo);
                }
                else
                {
                    // The user settings for this workbook will be used for and
                    // stored in each workbook in the specified folder.

                    CommandDispatcher.SendCommand(this,
                                                  new RunNoParamCommandEventArgs(
                                                      NoParamCommand.SaveUserSettings));

                    String sWorkbookSettings = (new PerWorkbookSettings(
                                                    m_oThisWorkbook.InnerObject)).WorkbookSettings;

                    TaskAutomator.AutomateFolder(
                        m_oAutomateTasksUserSettings.FolderToAutomate,
                        sWorkbookSettings);
                }
            }
            catch (UnauthorizedAccessException oUnauthorizedAccessException)
            {
                // This occurs when a workbook is read-only.

                this.ShowWarning(
                    "A problem occurred while running tasks.  Details:"
                    + "\r\n\r\n"
                    + oUnauthorizedAccessException.Message
                    );

                return;
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }