Наследование: NodeXLApplicationSettingsBase
    //*************************************************************************
    //  Constructor: AutomateTasksDialog()
    //
    /// <summary>
    /// Initializes a new instance of the <see cref="AutomateTasksDialog" />
    /// class.
    /// </summary>
    ///
    /// <param name="mode">
    /// Indicates the mode in which the dialog is being used.
    /// </param>
    ///
    /// <param name="thisWorkbook">
    /// Workbook containing the graph contents.
    /// </param>
    ///
    /// <param name="nodeXLControl">
    /// The NodeXLControl object.  This can be null if <paramref name="mode" />
    /// is <see cref="DialogMode.EditOnly" />.
    /// </param>
    //*************************************************************************

    public AutomateTasksDialog
    (
        DialogMode mode,
        ThisWorkbook thisWorkbook,
        NodeXLControl nodeXLControl
    )
    {
        Debug.Assert(thisWorkbook != null);
        Debug.Assert(nodeXLControl != null || mode == DialogMode.EditOnly);

        m_eMode = mode;
        m_oAutomateTasksUserSettings = new AutomateTasksUserSettings();
        m_oThisWorkbook = thisWorkbook;
        m_oNodeXLControl = nodeXLControl;
        m_bIgnoreItemCheckEvents = false;

        InitializeComponent();

        if (m_eMode == DialogMode.EditOnly)
        {
            this.Text += " Options";
            btnOK.Text = "OK";
        }

        // Instantiate an object that saves and retrieves the user settings for
        // this dialog.  Note that the object automatically saves the settings
        // when the form closes.

        m_oAutomateTasksDialogUserSettings =
            new AutomateTasksDialogUserSettings(this);

        PopulateTasksToRun();

        DoDataExchange(false);

        AssertValid();
    }
Пример #2
0
    AutomateThisWorkbook()
    {
        AssertValid();

        AutomateTasksUserSettings oAutomateTasksUserSettings =
            new AutomateTasksUserSettings();

        TaskAutomator.AutomateOneWorkbook(m_oThisWorkbook, oNodeXLControl,
            oAutomateTasksUserSettings.TasksToRun,
            oAutomateTasksUserSettings.FolderToSaveWorkbookTo);
    }
    GetWorkbookSettings
    (
        Microsoft.Office.Interop.Excel.Workbook oWorkbook
    )
    {
        Debug.Assert(oWorkbook != null);
        AssertValid();

        // Temporarily change some settings.

        AutomateTasksUserSettings oAutomateTasksUserSettings =
            new AutomateTasksUserSettings();

        AutomationTasks eOriginalTasksToRun =
            oAutomateTasksUserSettings.TasksToRun;

        oAutomateTasksUserSettings.TasksToRun =
            AutomationTasks.CalculateGraphMetrics;

        oAutomateTasksUserSettings.Save();

        GraphMetricUserSettings oGraphMetricUserSettings =
            new GraphMetricUserSettings();

        GraphMetrics eOriginalGraphMetricsToCalculate =
            oGraphMetricUserSettings.GraphMetricsToCalculate;

        oGraphMetricUserSettings.GraphMetricsToCalculate =
            GraphMetrics.OverallMetrics;

        oGraphMetricUserSettings.Save();

        // Get the workbook settings that include the temporary changes.

        String sWorkbookSettings =
            ( new PerWorkbookSettings(oWorkbook) ).WorkbookSettings;

        // Restore the original settings.

        oAutomateTasksUserSettings.TasksToRun = eOriginalTasksToRun;

        oAutomateTasksUserSettings.Save();

        oGraphMetricUserSettings.GraphMetricsToCalculate =
            eOriginalGraphMetricsToCalculate;

        oGraphMetricUserSettings.Save();

        return (sWorkbookSettings);
    }