每個形狀/頁面在 ShapeSheet 的 Property 區包含多列屬性定義,每列含 Label、Prompt、Value、Format、Type、SortKey、Invisible 等欄位。需將所有資訊完整讀出並封裝為物件集合。
Dictionary<string, StencilPropertyInfo> list = new Dictionary<string, StencilPropertyInfo>();
StencilPropertyInfo propertyInfo;
Visio.Cell shapeCell;
short shortSectionProp = (short)VisSectionIndices.visSectionProp;
if (shape != null)
{
for (short i = 0; i < shape.get_RowCount(shortSectionProp); i++)
{
// 檢查 Label 儲存格是否存在(標記該列為有效屬性行)
if (shape.get_CellsSRCExists(shortSectionProp, i, (short)VisCellIndices.visCustPropsLabel, 0) != 0)
{
propertyInfo = new StencilPropertyInfo();
// Name (Label)
shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short)VisCellIndices.visCustPropsLabel);
propertyInfo.Name = VisioUtility.FormulaStringToString(shapeCell.RowNameU);
// Prompt
shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short)VisCellIndices.visCustPropsPrompt);
propertyInfo.Prompt = VisioUtility.FormulaStringToString(shapeCell.FormulaU);
// Format
shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short)VisCellIndices.visCustPropsFormat);
propertyInfo.Format = VisioUtility.FormulaStringToString(shapeCell.FormulaU);
// Value
shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short)VisCellIndices.visCustPropsValue);
propertyInfo.Value = VisioUtility.FormulaStringToString(shapeCell.FormulaU);
// SortKey
shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short)VisCellIndices.visCustPropsSortKey);
propertyInfo.SortKey = VisioUtility.FormulaStringToString(shapeCell.FormulaU);
// PropType
shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short)VisCellIndices.visCustPropsType);
propertyInfo.PropType = (PropType)shapeCell.get_ResultInt((short)VisUnitCodes.visNumber, 0);
// Invisible
shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short)VisCellIndices.visCustPropsInvis);
if ("True".Equals(VisioUtility.FormulaStringToString(shapeCell.FormulaU), StringComparison.OrdinalIgnoreCase))
propertyInfo.InVisible = true;
propertyInfo.PropRowID = i;
if (!list.ContainsKey(propertyInfo.Name))
list.Add(propertyInfo.Name, propertyInfo);
}
}
}
return list;