Inheritance: Microsoft.Office.Tools.Excel.WorkbookBase
コード例 #1
0
    //*************************************************************************
    //  Constructor: ImportDataUserSettingsDialog()
    //
    /// <summary>
    /// Initializes a new instance of the <see
    /// cref="ImportDataUserSettingsDialog" /> class.
    /// </summary>
    ///
    /// <param name="importDataUserSettings">
    /// The object being edited.
    /// </param>
    ///
    /// <param name="plugInUserSettings">
    /// The object being edited.
    /// </param>
    ///
    /// <param name="thisWorkbook">
    /// Workbook containing the graph contents.
    /// </param>
    //*************************************************************************

    public ImportDataUserSettingsDialog
    (
        ImportDataUserSettings importDataUserSettings,
        PlugInUserSettings plugInUserSettings,
        ThisWorkbook thisWorkbook
    )
    {
        Debug.Assert(importDataUserSettings != null);
        importDataUserSettings.AssertValid();
        Debug.Assert(thisWorkbook != null);

        m_oImportDataUserSettings = importDataUserSettings;
		m_oPlugInUserSettings = plugInUserSettings;
        m_oThisWorkbook = thisWorkbook;

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

        m_oImportDataUserSettingsDialogUserSettings =
            new ImportDataUserSettingsDialogUserSettings(this);

        InitializeComponent();
        DoDataExchange(false);

        AssertValid();
    }
コード例 #2
0
    //*************************************************************************
    //  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();
    }
コード例 #3
0
    //*************************************************************************
    //  Constructor: TaskPane()
    //
    /// <summary>
    /// Initializes a new instance of the <see cref="TaskPane" /> class.
    /// </summary>
    ///
    /// <param name="thisWorkbook">
    /// The workbook.
    /// </param>
    ///
    /// <param name="ribbon">
    /// The application's ribbon.
    /// </param>
    //*************************************************************************

    public TaskPane
    (
        ThisWorkbook thisWorkbook,
        Ribbon ribbon
    )
    {
        Debug.Assert(thisWorkbook != null);
        Debug.Assert(ribbon != null);

        InitializeComponent();
        InitializeSplashScreen();

        m_oThisWorkbook = thisWorkbook;
        m_oWorkbook = thisWorkbook.InnerObject;
        m_oRibbon = ribbon;

        // The WpfImageUtil uses the screen DPI in its image handling.

        Graphics oGraphics = this.CreateGraphics();
        WpfImageUtil.ScreenDpi = oGraphics.DpiX;
        oGraphics.Dispose();

        // Get the template version from the per-workbook settings.

        PerWorkbookSettings oPerWorkbookSettings =
            this.PerWorkbookSettings;

        m_iTemplateVersion = oPerWorkbookSettings.TemplateVersion;

        m_bHandlingLayoutChanged = false;
        m_iEnableGraphControlsCount = 0;
        m_oEdgeRowIDDictionary = null;
        m_oVertexRowIDDictionary = null;
        m_oSaveGraphImageFileDialog = null;
        m_oDynamicFilterDialog = null;
        m_oReadabilityMetricsDialog = null;

        GeneralUserSettings oGeneralUserSettings = new GeneralUserSettings();
        LayoutUserSettings oLayoutUserSettings = new LayoutUserSettings();

        LayoutType eInitialLayout = oLayoutUserSettings.Layout;

        // Instantiate an object that populates the tssbLayout
        // ToolStripSplitButton and handles its LayoutChanged event.

        m_oLayoutManagerForToolStripSplitButton =
            new LayoutManagerForToolStripSplitButton();

        m_oLayoutManagerForToolStripSplitButton.AddItems(this.tssbLayout);
        m_oLayoutManagerForToolStripSplitButton.Layout = eInitialLayout;

        // Instantiate an object that populates the msiContextLayout
        // context menu and handles the Clicked events on the child menu items.

        m_oLayoutManagerForContextMenu = new LayoutManagerForMenu();
        m_oLayoutManagerForContextMenu.AddMenuItems(this.msiContextLayout);
        m_oLayoutManagerForContextMenu.Layout = eInitialLayout;

        m_oLayoutManagerForToolStripSplitButton.LayoutChanged +=
            new EventHandler(
                this.LayoutManagerForToolStripSplitButton_LayoutChanged);

        m_oLayoutManagerForContextMenu.LayoutChanged +=
            new EventHandler(this.LayoutManagerForContextMenu_LayoutChanged);

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

        MenuUtil.EnableToolStripMenuItems(
            m_iTemplateVersion > GroupManager.MinimumTemplateVersionForGroups,
            msiContextGroups);

        thisWorkbook.VisualAttributeSetInWorkbook +=
            new EventHandler(ThisWorkbook_VisualAttributeSetInWorkbook);

        thisWorkbook.WorksheetContextMenuManager.RequestVertexCommandEnable +=
            new RequestVertexCommandEnableEventHandler(
                WorksheetContextMenuManager_RequestVertexCommandEnable);

        thisWorkbook.WorksheetContextMenuManager.RequestEdgeCommandEnable +=
            new RequestEdgeCommandEnableEventHandler(
                WorksheetContextMenuManager_RequestEdgeCommandEnable);

        m_oRibbon.Layout = eInitialLayout;

        CreateNodeXLControl();
        CreateGraphZoomAndScaleControl();

        ApplyGeneralUserSettings(oGeneralUserSettings);
        ApplyLayoutUserSettings(oLayoutUserSettings);

        // Don't show the legend now.  If it is supposed to be shown, the
        // Ribbon, which is responsible for maintaining the visibility of the
        // legend, will send a NoParamCommand.ShowGraphLegend command to the
        // TaskPane later.

        this.ShowGraphLegend = false;

        UpdateAutoFillResultsLegend(oPerWorkbookSettings);
        UpdateDynamicFiltersLegend();
        UpdateAxes(oPerWorkbookSettings);

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

        AssertValid();
    }
コード例 #4
0
    //*************************************************************************
    //  Constructor: SelectionCoordinator()
    //
    /// <summary>
    /// Initializes a new instance of the <see cref="SelectionCoordinator" />
    /// class.
    /// </summary>
    ///
    /// <param name="thisWorkbook">
    /// The Excel workbook.
    /// </param>
    ///
    /// <param name="edgeWorksheet">
    /// The edge worksheet in the Excel workbook.
    /// </param>
    ///
    /// <param name="edgeTable">
    /// The edge table on the edge worksheet.
    /// </param>
    ///
    /// <param name="vertexWorksheet">
    /// The vertex worksheet in the Excel workbook.
    /// </param>
    ///
    /// <param name="vertexTable">
    /// The vertex table on the vertex worksheet.
    /// </param>
    ///
    /// <param name="groupWorksheet">
    /// The group worksheet in the Excel workbook.
    /// </param>
    ///
    /// <param name="groupTable">
    /// The group table on the group worksheet.
    /// </param>
    ///
    /// <param name="groupVertexWorksheet">
    /// The group-vertex worksheet in the Excel workbook.
    /// </param>
    ///
    /// <param name="taskPane">
    /// The TaskPane.
    /// </param>
    //*************************************************************************

    public SelectionCoordinator
    (
        ThisWorkbook thisWorkbook,
        Sheet1 edgeWorksheet,
        Microsoft.Office.Tools.Excel.ListObject edgeTable,
        Sheet2 vertexWorksheet,
        Microsoft.Office.Tools.Excel.ListObject vertexTable,
        Sheet5 groupWorksheet,
        Microsoft.Office.Tools.Excel.ListObject groupTable,
        Sheet6 groupVertexWorksheet,
        TaskPane taskPane
    )
    {
        Debug.Assert(thisWorkbook != null);
        Debug.Assert(edgeWorksheet != null);
        Debug.Assert(edgeTable != null);
        Debug.Assert(vertexWorksheet != null);
        Debug.Assert(vertexTable != null);
        Debug.Assert(groupWorksheet != null);
        Debug.Assert(groupTable != null);
        Debug.Assert(groupVertexWorksheet != null);
        Debug.Assert(taskPane != null);

        m_oThisWorkbook = thisWorkbook;
        m_oEdgeWorksheet = edgeWorksheet;
        m_oVertexWorksheet = vertexWorksheet;
        m_oGroupWorksheet = groupWorksheet;
        m_oGroupTable = groupTable;
        m_oGroupVertexWorksheet = groupVertexWorksheet;
        m_oTaskPane = taskPane;

        m_bIgnoreSelectionEvents = false;
        m_bUpdateVertexSelectionOnActivation = false;
        m_bUpdateEdgeSelectionOnActivation = false;
        m_bUpdateGroupSelectionOnActivation = false;


        edgeTable.SelectionChange += new DocEvents_SelectionChangeEventHandler(
            EdgeTable_SelectionChange);

        edgeTable.Deselected += new DocEvents_SelectionChangeEventHandler(
            EdgeTable_Deselected);

        m_oEdgeWorksheet.ActivateEvent += new DocEvents_ActivateEventHandler(
            EdgeWorksheet_ActivateEvent);


        vertexTable.SelectionChange +=
            new DocEvents_SelectionChangeEventHandler(
                VertexTable_SelectionChange);

        vertexTable.Deselected += new DocEvents_SelectionChangeEventHandler(
            VertexTable_Deselected);

        m_oVertexWorksheet.ActivateEvent += new DocEvents_ActivateEventHandler(
            VertexWorksheet_ActivateEvent);


        m_oGroupTable.SelectionChange +=
            new DocEvents_SelectionChangeEventHandler(
                GroupTable_SelectionChange);

        m_oGroupTable.Deselected += new DocEvents_SelectionChangeEventHandler(
            GroupTable_Deselected);

        m_oGroupWorksheet.ActivateEvent += new DocEvents_ActivateEventHandler(
            GroupWorksheet_ActivateEvent);


        m_oTaskPane.SelectionChangedInGraph +=
            new EventHandler<EventArgs>(this.TaskPane_SelectionChangedInGraph);
    }
コード例 #5
0
    AutomateOneWorkbook
    (
        ThisWorkbook thisWorkbook,
        NodeXLControl nodeXLControl,
        AutomationTasks tasksToRun,
        String folderToSaveWorkbookTo
    )
    {
        Debug.Assert(thisWorkbook != null);
        Debug.Assert(nodeXLControl != null);

        CheckTasksToRunArgument(ref tasksToRun);

        Microsoft.Office.Interop.Excel.Workbook oWorkbook =
            thisWorkbook.InnerObject;

        if
        (
            (
                ShouldRunTask(tasksToRun, AutomationTasks.MergeDuplicateEdges)
                &&
                !TryMergeDuplicateEdges(thisWorkbook)
            )
            ||
            (
                ShouldRunTask(tasksToRun, AutomationTasks.CalculateClusters)
                &&
                !TryCalculateClusters(thisWorkbook)
            )
            ||
            (
                ShouldRunTask(tasksToRun,
                    AutomationTasks.CalculateGraphMetrics)
                &&
                !TryCalculateGraphMetrics(oWorkbook)
            )
            ||
            (
                ShouldRunTask(tasksToRun, AutomationTasks.AutoFillWorkbook)
                &&
                !TryAutoFillWorkbook(thisWorkbook)
            )
            ||
            (
                ShouldRunTask(tasksToRun, AutomationTasks.CreateSubgraphImages)
                &&
                !TryCreateSubgraphImages(thisWorkbook)
            )
        )
        {
            return;
        }

        RunReadWorkbookTasks(thisWorkbook, nodeXLControl, tasksToRun,
            folderToSaveWorkbookTo);
    }
コード例 #6
0
    RunReadWorkbookTasks
    (
        ThisWorkbook oThisWorkbook,
        NodeXLControl oNodeXLControl,
        AutomationTasks eTasksToRun,
        String sFolderToSaveWorkbookTo
    )
    {
        Debug.Assert(oThisWorkbook != null);
        Debug.Assert(oNodeXLControl != null);

        Boolean bReadWorkbook = ShouldRunTask(
            eTasksToRun, AutomationTasks.ReadWorkbook);

        Boolean bSaveWorkbookIfNeverSaved = ShouldRunTask(
            eTasksToRun, AutomationTasks.SaveWorkbookIfNeverSaved);

        Boolean bSaveGraphImageFile = ShouldRunTask(
            eTasksToRun, AutomationTasks.SaveGraphImageFile);

        Boolean bExportToNodeXLGraphGallery = ShouldRunTask(
            eTasksToRun, AutomationTasks.ExportToNodeXLGraphGallery);

        Boolean bExportToEmail = ShouldRunTask(
            eTasksToRun, AutomationTasks.ExportToEmail);

        Microsoft.Office.Interop.Excel.Workbook oWorkbook =
            oThisWorkbook.InnerObject;

        if (bReadWorkbook)
        {
            // If the vertex X and Y columns were autofilled, the layout type
            // was set to LayoutType.Null.  This will cause
            // TaskPane.ReadWorkbook() to display a warning.  Temporarily turn
            // the warning off.

            Boolean bLayoutTypeIsNullNotificationsWereEnabled =
                EnableLayoutTypeIsNullNotifications(false);

            if (
                bSaveWorkbookIfNeverSaved
                ||
                bSaveGraphImageFile
                ||
                bExportToNodeXLGraphGallery
                ||
                bExportToEmail
                )
            {
                // These tasks need to wait until the workbook is read and the
                // graph is laid out.

                EventHandler<GraphLaidOutEventArgs> oGraphLaidOutEventHandler =
                    null;

                oGraphLaidOutEventHandler =
                    delegate(Object sender, GraphLaidOutEventArgs e)
                {
                    // This delegate remains forever, even when the dialog
                    // class is destroyed.  Prevent it from being called again.

                    oThisWorkbook.GraphLaidOut -= oGraphLaidOutEventHandler;

                    if (bSaveWorkbookIfNeverSaved)
                    {
                        if ( !TrySaveWorkbookIfNeverSaved(oWorkbook,
                            sFolderToSaveWorkbookTo) )
                        {
                            return;
                        }
                    }

                    if (bSaveGraphImageFile)
                    {
                        Debug.Assert( !String.IsNullOrEmpty(
                            oThisWorkbook.Path) );

                        SaveGraphImageFile(e.NodeXLControl, e.LegendControls,
                            oThisWorkbook.FullName);
                    }

                    if (bExportToNodeXLGraphGallery)
                    {
                        if ( !TryExportToNodeXLGraphGallery(
                            oThisWorkbook.InnerObject, oNodeXLControl) )
                        {
                            return;
                        }
                    }

                    if (bExportToEmail)
                    {
                        if ( !TryExportToEmail(
                            oThisWorkbook.InnerObject, oNodeXLControl) )
                        {
                            return;
                        }
                    }
                };

                oThisWorkbook.GraphLaidOut += oGraphLaidOutEventHandler;
            }

            // Read the workbook and lay out the graph.

            CommandDispatcher.SendNoParamCommand(oThisWorkbook,
                NoParamCommand.ShowGraphAndReadWorkbook);

            EnableLayoutTypeIsNullNotifications(
                bLayoutTypeIsNullNotificationsWereEnabled);
        }
        else
        {
            if (bSaveWorkbookIfNeverSaved)
            {
                if ( !TrySaveWorkbookIfNeverSaved(oWorkbook,
                    sFolderToSaveWorkbookTo) )
                {
                    return;
                }
            }
        }
    }
コード例 #7
0
    TryCreateSubgraphImages
    (
        ThisWorkbook oThisWorkbook
    )
    {
        Debug.Assert(oThisWorkbook != null);

        oThisWorkbook.CreateSubgraphImages(
            CreateSubgraphImagesDialog.DialogMode.Automate);

        return (true);
    }
コード例 #8
0
    TryAutoFillWorkbook
    (
        ThisWorkbook oThisWorkbook
    )
    {
        Debug.Assert(oThisWorkbook != null);

        try
        {
            WorkbookAutoFiller.AutoFillWorkbook(
                oThisWorkbook.InnerObject, new AutoFillUserSettings() );

            oThisWorkbook.OnWorkbookAutoFilled(false);

            return (true);
        }
        catch (Exception oException)
        {
            ErrorUtil.OnException(oException);
            return (false);
        }
    }
コード例 #9
0
    TryCalculateClusters
    (
        ThisWorkbook oThisWorkbook
    )
    {
        Debug.Assert(oThisWorkbook != null);

        return ( RunEditableCommand(
            new RunGroupByClusterCommandEventArgs(false), oThisWorkbook) );
    }
コード例 #10
0
    TryMergeDuplicateEdges
    (
        ThisWorkbook oThisWorkbook
    )
    {
        Debug.Assert(oThisWorkbook != null);

        return ( RunEditableCommand(
            new RunMergeDuplicateEdgesCommandEventArgs(false),
            oThisWorkbook) );
    }
コード例 #11
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);
    }