Example #1
0
        TryRemoveSelectedGroups
        (
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            Sheet5 oGroupWorksheet
        )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oGroupWorksheet != null);

            ICollection <String> oSelectedGroupNames =
                oGroupWorksheet.GetSelectedGroupNames();

            ExcelUtil.RemoveTableRowsByStringColumnValues(oWorkbook,
                                                          WorksheetNames.Groups, TableNames.Groups,
                                                          GroupTableColumnNames.Name, oSelectedGroupNames);

            ExcelUtil.RemoveTableRowsByStringColumnValues(oWorkbook,
                                                          WorksheetNames.GroupVertices, TableNames.GroupVertices,
                                                          GroupVertexTableColumnNames.GroupName, oSelectedGroupNames);

            return(true);
        }
Example #2
0
        TrySelectGroupsWithSelectedVertices
        (
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            Sheet2 oVertexWorksheet,
            Sheet5 oGroupWorksheet
        )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oVertexWorksheet != null);
            Debug.Assert(oGroupWorksheet != null);

            // For each selected vertex, get the vertex's group name from the
            // group-vertex worksheet and select that group in the group worksheet.

            ICollection <String> oSelectedVertexNames =
                oVertexWorksheet.GetSelectedVertexNames();

            oGroupWorksheet.SelectGroups(
                NodeXLWorkbookUtil.GetGroupNamesByVertexName(oWorkbook,
                                                             oSelectedVertexNames));

            return(true);
        }
Example #3
0
        //*************************************************************************
        //  Method: TrySelectGroupsWithSelectedVertices()
        //
        /// <summary>
        /// Attempts to select the groups containing the selected vertices in the
        /// workbook.
        /// </summary>
        ///
        /// <param name="oWorkbook">
        /// NodeXL workbook.
        /// </param>
        ///
        /// <param name="oVertexWorksheet">
        /// The vertex worksheet in the NodeXL workbook.
        /// </param>
        ///
        /// <param name="oGroupWorksheet">
        /// The group worksheet in the NodeXL workbook.
        /// </param>
        ///
        /// <returns>
        /// true if successful.
        /// </returns>
        ///
        /// <remarks>
        /// This method activates the group worksheet.
        /// </remarks>
        //*************************************************************************
        private static Boolean TrySelectGroupsWithSelectedVertices(
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            Sheet2 oVertexWorksheet,
            Sheet5 oGroupWorksheet
            )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oVertexWorksheet != null);
            Debug.Assert(oGroupWorksheet != null);

            // For each selected vertex, get the vertex's group name from the
            // group-vertex worksheet and select that group in the group worksheet.

            ICollection<String> oSelectedVertexNames =
            oVertexWorksheet.GetSelectedVertexNames();

            oGroupWorksheet.SelectGroups(
            NodeXLWorkbookUtil.GetGroupNamesByVertexName(oWorkbook,
                oSelectedVertexNames) );

            return (true);
        }
Example #4
0
        //*************************************************************************
        //  Method: TryRemoveSelectedGroups()
        //
        /// <summary>
        /// Attempts to remove the selected groups from the workbook.
        /// </summary>
        ///
        /// <param name="oWorkbook">
        /// NodeXL workbook.
        /// </param>
        ///
        /// <param name="oGroupWorksheet">
        /// The group worksheet in the NodeXL workbook.
        /// </param>
        ///
        /// <returns>
        /// true if successful.
        /// </returns>
        //*************************************************************************
        private static Boolean TryRemoveSelectedGroups(
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            Sheet5 oGroupWorksheet
            )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oGroupWorksheet != null);

            ICollection<String> oSelectedGroupNames =
            oGroupWorksheet.GetSelectedGroupNames();

            ExcelUtil.RemoveTableRowsByStringColumnValues(oWorkbook,
            WorksheetNames.Groups, TableNames.Groups,
            GroupTableColumnNames.Name, oSelectedGroupNames);

            ExcelUtil.RemoveTableRowsByStringColumnValues(oWorkbook,
            WorksheetNames.GroupVertices, TableNames.GroupVertices,
            GroupVertexTableColumnNames.GroupName, oSelectedGroupNames);

            return (true);
        }
Example #5
0
        //*************************************************************************
        //  Method: TryRunGroupCommand()
        //
        /// <summary>
        /// Attempts to run a group command.
        /// </summary>
        ///
        /// <param name="groupCommand">
        /// One of the flags in the <see cref="GroupCommands" /> enumeration.
        /// </param>
        ///
        /// <param name="workbook">
        /// NodeXL workbook.
        /// </param>
        ///
        /// <param name="vertexWorksheet">
        /// The vertex worksheet in the NodeXL workbook.
        /// </param>
        ///
        /// <param name="groupWorksheet">
        /// The group worksheet in the NodeXL workbook.
        /// </param>
        ///
        /// <returns>
        /// true if successful.
        /// </returns>
        ///
        /// <remarks>
        /// This method may modify the contents of the workbook.  It does not
        /// interact with the TaskPane, which contains the graph created from the
        /// workbook.  It is the responsibility of the caller to communicate
        /// group changes to the TaskPane when necessary.
        ///
        /// <para>
        /// This method activates various worksheets to read their selection and
        /// write their contents.  It is the responsibility of the caller to save
        /// the active worksheet state before calling this method and restore it
        /// afterward.
        /// </para>
        ///
        /// </remarks>
        //*************************************************************************
        public static Boolean TryRunGroupCommand(
            GroupCommands groupCommand,
            Microsoft.Office.Interop.Excel.Workbook workbook,
            Sheet2 vertexWorksheet,
            Sheet5 groupWorksheet
            )
        {
            Debug.Assert(workbook != null);
            Debug.Assert(vertexWorksheet != null);
            Debug.Assert(groupWorksheet != null);

            switch (groupCommand)
            {
            case GroupCommands.None:

                return (true);

            case GroupCommands.CollapseSelectedGroups:

                return ( TryCollapseOrExpandSelectedGroups(workbook, true) );

            case GroupCommands.ExpandSelectedGroups:

                return ( TryCollapseOrExpandSelectedGroups(workbook, false) );

            case GroupCommands.CollapseAllGroups:

                return ( TryCollapseOrExpandAllGroups(workbook, true) );

            case GroupCommands.ExpandAllGroups:

                return ( TryCollapseOrExpandAllGroups(workbook, false) );

            case GroupCommands.SelectGroupsWithSelectedVertices:

                return ( TrySelectGroupsWithSelectedVertices(workbook,
                    vertexWorksheet, groupWorksheet) );

            case GroupCommands.SelectAllGroups:

                return ( TrySelectAllGroups(workbook) );

            case GroupCommands.AddSelectedVerticesToGroup:

                return ( TryAddSelectedVerticesToGroup(workbook,
                    vertexWorksheet) );

            case GroupCommands.RemoveSelectedVerticesFromGroups:

                ICollection<String> oSelectedVertexNames;

                return ( TryRemoveSelectedVerticesFromGroups(workbook,
                    vertexWorksheet, out oSelectedVertexNames) );

            case GroupCommands.RemoveSelectedGroups:

                return ( TryRemoveSelectedGroups(workbook, groupWorksheet) );

            case GroupCommands.RemoveAllGroups:

                return ( TryRemoveAllGroups(workbook) );

            default:

                Debug.Assert(false);
                return (false);
            }
        }
Example #6
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(this.TaskPane_SelectionChangedInGraph);
        }
Example #7
0
        TryRunGroupCommand
        (
            GroupCommands groupCommand,
            Microsoft.Office.Interop.Excel.Workbook workbook,
            Sheet2 vertexWorksheet,
            Sheet5 groupWorksheet
        )
        {
            Debug.Assert(workbook != null);
            Debug.Assert(vertexWorksheet != null);
            Debug.Assert(groupWorksheet != null);

            switch (groupCommand)
            {
            case GroupCommands.None:

                return(true);

            case GroupCommands.CollapseSelectedGroups:

                return(TryCollapseOrExpandSelectedGroups(workbook, true));

            case GroupCommands.ExpandSelectedGroups:

                return(TryCollapseOrExpandSelectedGroups(workbook, false));

            case GroupCommands.CollapseAllGroups:

                return(TryCollapseOrExpandAllGroups(workbook, true));

            case GroupCommands.ExpandAllGroups:

                return(TryCollapseOrExpandAllGroups(workbook, false));

            case GroupCommands.SelectGroupsWithSelectedVertices:

                return(TrySelectGroupsWithSelectedVertices(workbook,
                                                           vertexWorksheet, groupWorksheet));

            case GroupCommands.SelectAllGroups:

                return(TrySelectAllGroups(workbook));

            case GroupCommands.AddSelectedVerticesToGroup:

                return(TryAddSelectedVerticesToGroup(workbook,
                                                     vertexWorksheet));

            case GroupCommands.RemoveSelectedVerticesFromGroups:

                ICollection <String> oSelectedVertexNames;

                return(TryRemoveSelectedVerticesFromGroups(workbook,
                                                           vertexWorksheet, out oSelectedVertexNames));

            case GroupCommands.RemoveSelectedGroups:

                return(TryRemoveSelectedGroups(workbook, groupWorksheet));

            case GroupCommands.RemoveAllGroups:

                return(TryRemoveAllGroups(workbook));

            default:

                Debug.Assert(false);
                return(false);
            }
        }