コード例 #1
0
ファイル: GroupManager.cs プロジェクト: haisreekanth/NetMap
        //*************************************************************************
        //  Method: TryAddSelectedVerticesToGroup()
        //
        /// <summary>
        /// Attempts to add the selected vertices to a new or existing group.
        /// </summary>
        ///
        /// <param name="oWorkbook">
        /// NodeXL workbook.
        /// </param>
        ///
        /// <param name="oVertexWorksheet">
        /// The vertex worksheet in the NodeXL workbook.
        /// </param>
        ///
        /// <returns>
        /// true if successful.
        /// </returns>
        //*************************************************************************
        private static Boolean TryAddSelectedVerticesToGroup(
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            Sheet2 oVertexWorksheet
            )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oVertexWorksheet != null);

            AddSelectedVerticesToGroupDialog oAddSelectedVerticesToGroupDialog =
            new AddSelectedVerticesToGroupDialog(oWorkbook);

            if (oAddSelectedVerticesToGroupDialog.ShowDialog() !=
            DialogResult.OK)
            {
            return (false);
            }

            // First, remove the selected vertices from any groups they belong to.

            ListObject oGroupTable, oGroupVertexTable;
            ICollection<String> oSelectedVertexNames;

            if (
            !TryRemoveSelectedVerticesFromGroups(oWorkbook, oVertexWorksheet,
                out oSelectedVertexNames)
            ||
            !ExcelUtil.TryGetTable(oWorkbook, WorksheetNames.Groups,
                TableNames.Groups, out oGroupTable)
            ||
            !ExcelUtil.TryGetTable(oWorkbook, WorksheetNames.GroupVertices,
                TableNames.GroupVertices, out oGroupVertexTable)
            )
            {
            return (false);
            }

            String sGroupName = oAddSelectedVerticesToGroupDialog.GroupName;

            if (oAddSelectedVerticesToGroupDialog.IsNewGroup)
            {
            // Add the new group to the group table.

            ExcelUtil.TryAddTableRow(oGroupTable,

                GroupTableColumnNames.Name,
                sGroupName
                );

            SetVertexAttributesForAllGroups(oGroupTable);
            }

            // Add the selected vertices to the group-vertex table.

            foreach (String sSelectedVertexName in oSelectedVertexNames)
            {
            ExcelUtil.TryAddTableRow(oGroupVertexTable,

                GroupVertexTableColumnNames.GroupName,
                sGroupName,

                GroupVertexTableColumnNames.VertexName,
                sSelectedVertexName,

                GroupVertexTableColumnNames.VertexID,
                GetExcelFormulaForVertexID()
                );
            }

            return (true);
        }
コード例 #2
0
ファイル: GroupManager.cs プロジェクト: yesbb12/NetMap
        TryAddSelectedVerticesToGroup
        (
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            Sheet2 oVertexWorksheet
        )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oVertexWorksheet != null);

            AddSelectedVerticesToGroupDialog oAddSelectedVerticesToGroupDialog =
                new AddSelectedVerticesToGroupDialog(oWorkbook);

            if (oAddSelectedVerticesToGroupDialog.ShowDialog() !=
                DialogResult.OK)
            {
                return(false);
            }

            // First, remove the selected vertices from any groups they belong to.

            ListObject           oGroupTable, oGroupVertexTable;
            ICollection <String> oSelectedVertexNames;

            if (
                !TryRemoveSelectedVerticesFromGroups(oWorkbook, oVertexWorksheet,
                                                     out oSelectedVertexNames)
                ||
                !ExcelUtil.TryGetTable(oWorkbook, WorksheetNames.Groups,
                                       TableNames.Groups, out oGroupTable)
                ||
                !ExcelUtil.TryGetTable(oWorkbook, WorksheetNames.GroupVertices,
                                       TableNames.GroupVertices, out oGroupVertexTable)
                )
            {
                return(false);
            }

            String sGroupName = oAddSelectedVerticesToGroupDialog.GroupName;

            if (oAddSelectedVerticesToGroupDialog.IsNewGroup)
            {
                // Add the new group to the group table.

                ExcelUtil.TryAddTableRow(oGroupTable,

                                         GroupTableColumnNames.Name,
                                         sGroupName
                                         );

                SetVertexAttributesForAllGroups(oGroupTable);
            }

            // Add the selected vertices to the group-vertex table.

            foreach (String sSelectedVertexName in oSelectedVertexNames)
            {
                ExcelUtil.TryAddTableRow(oGroupVertexTable,

                                         GroupVertexTableColumnNames.GroupName,
                                         sGroupName,

                                         GroupVertexTableColumnNames.VertexName,
                                         sSelectedVertexName,

                                         GroupVertexTableColumnNames.VertexID,
                                         GetExcelFormulaForVertexID()
                                         );
            }

            return(true);
        }