Example #1
0
        /// <summary>
        /// Returns a list of values in the Label Cell of the Shape Data Section
        /// for all rows with a prefix that match the rowNamePrefix. Results are
        /// stripped of the rowNamePrefix.
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="rowNamePrefix"></param>
        /// <returns></returns>
        public static HashSet <string> getDSLabelCells(Visio.Shape shape, string rowNamePrefix)
        {
            HashSet <string> labelCellsList = new HashSet <string>();

            // All operation rows are stored in the form:
            // op_[operation_name]_[operation_property] in the Label Cell
            short numRows = shape.get_RowCount(CaseTypes.SHAPE_DATA_SECTION);

            for (short r = 0; r < numRows; ++r)
            {
                Visio.Cell labelCell = shape.get_CellsSRC(CaseTypes.SHAPE_DATA_SECTION,
                                                          r, CaseTypes.DS_LABEL_CELL);

                string labelCellValue = labelCell.get_ResultStr(Visio.VisUnitCodes.visUnitsString);

                // we are only interested in rows with prefix
                if (labelCellValue.StartsWith(rowNamePrefix))
                {
                    // we are only interested in the Label Cell value without
                    // prefix and any postfix
                    int    startIndex = labelCellValue.IndexOf('_') + 1;
                    int    endIndex   = labelCellValue.LastIndexOf('_');
                    int    opNameLen  = endIndex - startIndex;
                    string opName     = labelCellValue.Substring(startIndex, opNameLen);

                    labelCellsList.Add(Utilities.underscoreToSpace(opName));
                }
            }

            return(labelCellsList);
        }
Example #2
0
        private void loadCObjectName()
        {
            // Get number of rows in shape data section of object
            short numRows = ownerShape.get_RowCount(CaseTypes.SHAPE_DATA_SECTION);
            // Initialize an empty string
            string cName = "";

            // Loop created to search through each row of shape data section
            for (short r = 0; r < numRows; ++r)
            {
                // Initialize shape data cell
                Visio.Cell labelCell = ownerShape.get_CellsSRC(CaseTypes.SHAPE_DATA_SECTION,
                                                               r, CaseTypes.DS_LABEL_CELL);
                // Get string from shape data row label
                string labelCellValue = labelCell.get_ResultStr(Visio.VisUnitCodes.visUnitsString);
                // We are only interested in c object name
                if (labelCellValue.StartsWith("c_"))
                {
                    // We are only interested in the object name
                    // Get start index of c object name
                    int startIndex = labelCellValue.IndexOf('_') + 1;
                    // Get end index of c object name
                    int endIndex = labelCellValue.LastIndexOf('_');
                    // Get length of c object name
                    int cNameLen = endIndex - startIndex;
                    // Get c object name
                    cName = labelCellValue.Substring(startIndex, cNameLen);
                }
            }
            // Update c object name in c object editor
            cObjectNameText.Text = cName;
            // Update c object name
            ownerShape.Text = cName;
        }
Example #3
0
        /// <summary>
        /// Retrieves the value of the Value Cell in a Shape's Data Section.
        /// </summary>
        /// <param name="Shape">Shape to get cell value for.</param>
        /// <param name="rowName">Name of the row to find the Value Cell.</param>
        /// <returns></returns>
        public static string getDataSectionValueCell(Visio.Shape Shape, string rowName)
        {
            string cellName = "Prop." + spaceToUnderscore(rowName) + ".Value";

            Visio.Cell valueCell = Shape.get_Cells(cellName);

            return(valueCell.get_ResultStr(Visio.VisUnitCodes.visUnitsString));
        }
        private void loadObject()
        {
            HashSet <string> operationSet = new HashSet <string>();
            short            numRows      = ownerShape.get_RowCount(CaseTypes.SHAPE_DATA_SECTION);

            for (short r = 0; r < numRows; ++r)
            {
                Visio.Cell labelCell = ownerShape.get_CellsSRC(CaseTypes.SHAPE_DATA_SECTION,
                                                               r, CaseTypes.DS_LABEL_CELL);

                string labelCellValue = labelCell.get_ResultStr(Visio.VisUnitCodes.visUnitsString);

                if (labelCellValue.StartsWith("adt_"))
                {
                    int    startIndex = labelCellValue.IndexOf('_') + 1;
                    int    endIndex   = labelCellValue.LastIndexOf('_');
                    int    opNameLen  = endIndex - startIndex;
                    string adtObjName = labelCellValue.Substring(startIndex, opNameLen);
                    adtObjectNameTextBox.Text = adtObjName;
                }
                if (labelCellValue.EndsWith("name"))
                {
                    int       startIndex = labelCellValue.IndexOf('_') + 1;
                    int       endIndex   = labelCellValue.LastIndexOf('_');
                    int       opNameLen  = endIndex - startIndex;
                    string    opName     = labelCellValue.Substring(startIndex, opNameLen);
                    Operation opObj      = new Operation();
                    string    rowName    = "op_" + opName + "_";
                    opObj.name    = Utilities.getDataSectionValueCell(ownerShape, rowName + "name");
                    opObj.domain  = Utilities.getDataSectionValueCell(ownerShape, rowName + "domain");
                    opObj.range   = Utilities.getDataSectionValueCell(ownerShape, rowName + "range");
                    opObj.purpose = Utilities.getDataSectionValueCell(ownerShape, rowName + "purpose");
                    opObj.effects = Utilities.getDataSectionValueCell(ownerShape, rowName + "effects");
                    if (Utilities.getDataSectionValueCell(ownerShape, rowName + "exceptions_list").Any())
                    {
                        opObj.exceptions = Utilities.getDataSectionValueCell(ownerShape, rowName + "exceptions_list").Split(',').Select(a => a.Trim()).ToList();
                    }
                    this.operationList.Add(opObj);
                    operationListBox.Items.Add(opObj.name);
                }
                if (labelCellValue.StartsWith("axiom"))
                {
                    string rowName = "axiom_list";
                    axiomList = Utilities.getDataSectionValueCell(ownerShape, rowName).Split(',').Select(a => a.Trim()).ToList();
                    axiomListBox.DataSource = axiomList;
                }
            }
            //operationListBox.Items.AddRange(operationSet.ToArray());
        }
Example #5
0
        /// <summary>
        /// Delete all rows in the Data Section that starts with the given row name.
        /// </summary>
        /// <param name="Shape">
        /// The Shape to delete the row(s) from.
        /// </param>
        /// <param name="rowName">The name of the row to delete.</param>
        public static void deleteDataSectionRow(Visio.Shape Shape, string rowName)
        {
            short numRows = Shape.get_RowCount(CaseTypes.SHAPE_DATA_SECTION);

            rowName = Utilities.spaceToUnderscore(rowName);

            // Iterate through the list of Data Section rows in reverse (since upon
            // deletion of a row, all row indexes after the deleted row gets shifted
            // up by 1) to safely delete any row that starts with the given rowName.
            short startIndex = --numRows;

            for (short r = startIndex; r >= 0; --r)
            {
                Visio.Cell labelCell = Shape.get_CellsSRC(CaseTypes.SHAPE_DATA_SECTION, r, CaseTypes.DS_LABEL_CELL);

                string labelValue = labelCell.get_ResultStr(Visio.VisUnitCodes.visUnitsString);
                if (labelValue.StartsWith(rowName))
                {
                    Shape.DeleteRow(CaseTypes.SHAPE_DATA_SECTION, r);
                }
            }
        }
Example #6
0
        private void loadAttributeNameList()
        {
            // Initialize empty HashSet
            HashSet <string> attributeSet = new HashSet <string>();
            // All attribute rows are stored in the form:
            // at_[attribute_name]_[attribute_property] in the Label Cell
            // Get number of rows in c object shape data section
            short numRows = ownerShape.get_RowCount(CaseTypes.SHAPE_DATA_SECTION);

            // Loop through each row of shape data section
            for (short r = 0; r < numRows; ++r)
            {
                // Initialize shape data label cell
                Visio.Cell labelCell = ownerShape.get_CellsSRC(CaseTypes.SHAPE_DATA_SECTION,
                                                               r, CaseTypes.DS_LABEL_CELL);
                // Get shape data label cell value
                string labelCellValue = labelCell.get_ResultStr(Visio.VisUnitCodes.visUnitsString);
                // Ee are only interested in attribute-related rows
                if (labelCellValue.StartsWith("at_"))
                {
                    // We are only interested in the attribute name
                    // Get start index of attribute name
                    int startIndex = labelCellValue.IndexOf('_') + 1;
                    // Get end index of attribute name
                    int endIndex = labelCellValue.LastIndexOf('_');
                    // Get length of attribute name
                    int atNameLen = endIndex - startIndex;
                    // Get attribute name
                    string atName = labelCellValue.Substring(startIndex, atNameLen);
                    // And add it to HashSet
                    attributeSet.Add(Utilities.underscoreToSpace(atName));
                }
            }
            // Add attribute names to attribute list box of c object editor
            attributeListBox.Items.AddRange(attributeSet.ToArray());
        }