Smrf.NodeXL.ExcelTemplate.Ribbon.Ribbon_Load C# (CSharp) Method

Ribbon_Load() private method

private Ribbon_Load ( object sender, RibbonUIEventArgs e ) : void
sender object
e RibbonUIEventArgs
return void
    Ribbon_Load
    (
        object sender,
        RibbonUIEventArgs e
    )
    {
        AssertValid();

        CommandDispatcher.CommandSent +=
            new RunCommandEventHandler(this.CommandDispatcher_CommandSent);

        SendLoadUserSettingsCommand();

        // The graph directedness RibbonDropDown should be enabled only if the
        // template the workbook is based on supports changing the
        // directedness.
        //
        // This is done here rather than in the constructor because a
        // PerWorkbookSettings object can't be created until this.ThisWorkbook
        // is available, which doesn't happen until the Ribbon is fully loaded.
        //
        // The order of workbook/task pane/ribbon events is:
        //
        // 1. ThisWorkbook_Startup.
        //
        // 2. TaskPane gets created from the ThisWorkbook_Startup handler.
        //
        // 3. ThisWorkbook_ActivateEvent.
        //
        // 4. Ribbon_Load.

        PerWorkbookSettings oPerWorkbookSettings = GetPerWorkbookSettings();

        Int32 iTemplateVersion = oPerWorkbookSettings.TemplateVersion;

        rddGraphDirectedness.Enabled = (iTemplateVersion >= 51);

        // The menu for groups should be enabled only if the template supports
        // groups.

        mnuGroups.Enabled =
            (iTemplateVersion >= GroupManager.MinimumTemplateVersionForGroups);

        // Should the layout automatically be set and the workbook read?  (This
        // feature was added in January 2010 for the Microsoft Biology
        // Foundation project, which "drives" the NodeXL template
        // programatically and needs to be able to set the layout and read the
        // workbook by writing to workbook cells.  It may be useful for other
        // purposes as well.)

        Nullable<LayoutType> oAutoLayoutOnOpen =
            oPerWorkbookSettings.AutoLayoutOnOpen;

        if (oAutoLayoutOnOpen.HasValue)
        {
            // Yes.

            this.Layout = oAutoLayoutOnOpen.Value;

            // Unfortunately, there is no way to programatically click a
            // RibbonButton.  Simulate a click.

            SendNoParamCommand(NoParamCommand.ShowGraphAndReadWorkbook);
        }

        // Should task automation be run on the workbook when it is opened?

        if (oPerWorkbookSettings.AutomateTasksOnOpen)
        {
            // Yes.

            AutomateTasksOnOpen();
        }
    }