程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C#進行Visio二次開發之雞毛蒜皮(一)(3)

C#進行Visio二次開發之雞毛蒜皮(一)(3)

編輯:關於C語言

3. 獲取圖元的屬性集合

我們 知道,每個圖元Shape甚至Page對象都有很多自定義屬性,你可以通過在Visio的 開發模式中查看ShapeSheet查看到。而所有這些屬性中,每行又代表一個屬性的 各種定義信息,如Label是什麼,Prompt(提示)是什麼,Value(值)是什麼, Type(類型)是什麼,這就有點類似於我們在數據庫定義一個字段,需要指定字段 的名稱,類型等等,那如果我們需要把這些信息保存下來,我們該如何獲取呢? 下面舉例說明:

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++)
        {
          if (shape.get_CellsSRCExists(shortSectionProp, i, (short)VisCellIndices.visCustPropsLabel, 0) != 0)
           {
            propertyInfo = new StencilPropertyInfo();

            shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short) VisCellIndices.visCustPropsLabel);
             propertyInfo.Name = VisioUtility.FormulaStringToString (shapeCell.RowNameU);

            shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short) VisCellIndices.visCustPropsPrompt);
             propertyInfo.Prompt = VisioUtility.FormulaStringToString (shapeCell.FormulaU);

            shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short) VisCellIndices.visCustPropsFormat);
             propertyInfo.Format = VisioUtility.FormulaStringToString (shapeCell.FormulaU);

            shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short) VisCellIndices.visCustPropsValue);
             propertyInfo.Value = VisioUtility.FormulaStringToString (shapeCell.FormulaU);

            shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short) VisCellIndices.visCustPropsSortKey);
             propertyInfo.SortKey = VisioUtility.FormulaStringToString (shapeCell.FormulaU);

            shapeCell = shape.get_CellsSRC(shortSectionProp, i, (short) VisCellIndices.visCustPropsType);
             propertyInfo.PropType = (PropType)shapeCell.get_ResultInt((short) VisUnitCodes.visNumber, 0);

             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;

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved