今天有空,下班前补齐解析visio图形形状的方法,包含图形背景色、字体颜色、备注信息、形状数据取值。

 /// <summary>
/// 设置形状的选择属性
/// </summary>
/******************************************************
* 0 仅选择组合形状。
* 1 首先选择组合形状
* 2 首先选择组合的组成部分
******************************************************/
public static void SetGroupSelectMode(Shape targetShape, int selectMode)
{
targetShape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowGroup,
(short)VisCellIndices.visGroupSelectMode).FormulaU = selectMode.ToString();
}

设置打开组合的器件,然后开始取数据:

               if (sp.Shapes.Count > )//组合类型
{
missDevice = false;
ShapeInfo spG = new ShapeInfo();
spG.Type = "器件";
spG.DeviceName = sp.Name.Split('.')[];
spG.DeviceDetail = "形状数据名:"+sp.Name+";";
addGroup(sp,spG); //拆分组合 SetGroupSelectMode(sp, );
spG.DeviceDetail += GetShapeCellProp(sp);
spG.Position = GetShaplocationInfo(sp);
spG.DeviceType = getTypeByBgColor(sp); if (spG.DeviceName != "")
{
visioInfoDic[PageName].Add(spG);
}
}
addGroup方法:
 private void addGroup(Shape sp,ShapeInfo spi)
{
foreach (Shape childSP in sp.Shapes)
{
/*线类型*/
if (childSP.Connects.Count > )
{
ShapeLine spL = new ShapeLine();
spL.LPosition = GetShaplocationInfo(sp); //位置信息
addLine(sp, spL, true);
spi.DeviceName = "";
visioLineDic[PageName].Add(spL);
break;
}
/*器件类型*/
ShapeInfo spchild = new ShapeInfo();
SetGroupSelectMode(childSP, );
if (childSP.Shapes.Count > )
addGroup(childSP, spi);
SetGroupSelectMode(childSP, ); /* 根据颜色判断*/
if(spi.DeviceType==null||spi.DeviceType=="")
spi.DeviceType = getTypeByBgColor(childSP);
if(childSP.Text.Contains("dB"))
getDWordColor(childSP,childSP.Text,spi); if (childSP.Text.Contains("F"))
{
spi.DeviceNum = childSP.Text.Split('/')[];
}
spchild.DeviceName = childSP.Text;
if (spchild.DeviceName != "")
{
spi.Label = (spi.Label == "") ? spchild.DeviceName : spi.Label + ";" + spchild.DeviceName;
}
} }
GetShapeCellProp读取形状数据的信息:
  /// <summary>
/// 获取图形属性
/// </summary>
private static string GetShapeCellProp(Shape shapeTarget)
{
string info = "";
for (int i = ; i < shapeTarget.get_RowCount((short)VisSectionIndices.visSectionProp); i++)
{
Cell cellKey = shapeTarget.get_CellsSRC((short)VisSectionIndices.visSectionProp, (short)i, (short));
Cell cellValue = shapeTarget.get_CellsSRC((short)VisSectionIndices.visSectionProp, (short)i, (short)VisCellIndices.visUserValue);
if (i > )
info += ";";
info += FormulaForString(cellKey.Formula) + ":" + FormulaForString(cellValue.Formula);
}
return info;
}
GetShaplocationInfo读取位置信息,前一篇已经给出。

获取文字颜色:
  if (sp.get_RowCount((short)VisSectionIndices.visSectionCharacter) == )
{
/*一个文本单个单颜色*/
Cell wordCell = sp.get_CellsSRC((short)VisSectionIndices.visSectionCharacter, , (short)VisCellIndices.visCharacterColor);
wordColor = wordCell.Formula;
deviceType(si, wordColor,power.Replace("/",""));
}
//多种颜色则循环取出
for (short i = ; i < sp.get_RowCount((short)VisSectionIndices.visSectionCharacter); i++)
{
Cell wordCells = sp.get_CellsSRC((short)VisSectionIndices.visSectionCharacter, i, (short)VisCellIndices.visCharacterColor);
if (wordCells.Formula.Contains("THEMEVAL()") && ((sp.get_RowCount((short)VisSectionIndices.visSectionCharacter) - ) == i))
{
break;
}
if (i > )
wordColor += "|";
wordColor += wordCells.Formula;
}

图形背景色:

Cell color = sp.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowFill, (short)VisCellIndices.visFillForegnd);
string strColor = color.Formula;

  大多数据都可以通过像取背景色一样,将形状的属性取出,比如线段粗细、字体、字体大小等等,有兴趣的继续研究。

 
 
 

visio二次开发——图纸解析之形状的更多相关文章

  1. visio二次开发——图纸解析之线段

    多写博客,其实还是蛮好的习惯的,当初大学的时候导师就叫我写,但是就是懒,大学的时候,谁不是魔兽或者LOL呢,是吧,哈哈哈. 好了,接着上一篇visio二次开发——图纸解析,我继续写. 摘要: (转发请 ...

  2. visio二次开发——图纸解析

    (转发请注明来源:http://www.cnblogs.com/EminemJK/) visio二次开发的案例或者教程,国内真的非常少,这个项目也是花了不少时间来研究visio的相关知识,困难之所以难 ...

  3. C#进行Visio二次开发之文件导出及另存Web页面

    在我前面很多关于Visio的开发过程中,介绍了各种Visio的C#开发应用场景,包括对Visio的文档.模具文档.形状.属性数据.各种事件等相关的基础处理,以及Visio本身的整体项目应用,虽然时间过 ...

  4. visio二次开发初始化问题

    (转发请注明来源:http://www.cnblogs.com/EminemJK/) 问题: axDrawingControl1初始化失败((System.ComponentModel.ISuppor ...

  5. (5)微信二次开发 之 XML格式数据解析

    1.首先理解一下html html的全名是:HyperText Transfer markup language 超级文本标记语言,html本质上是一门标记(符合)语言,在html里,这些标记是事先定 ...

  6. java微信开发API解析(二)-获取消息和回复消息

    java微信开发API解析(二)-获取消息和回复消息 说明 * 本演示样例依据微信开发文档:http://mp.weixin.qq.com/wiki/home/index.html最新版(4/3/20 ...

  7. ECMALL模板解析机制.MVC架构分析及文件目录说明.二次开发指南手册(转)

    ECMALL模板解析语法与机制 http://www.nowamagic.net/architecture/archt_TemplateSyntaxAndAnalysis.php ECMALL模块开发 ...

  8. 解析大型.NET ERP系统 窗体、查询、报表二次开发

    详细介绍Enterprise Solution 二次开发的流程步骤,主要包括数据输入窗体(Entry Form),查询(Query/Enquiry),报表(Report)三个重要的二次开发项目. 数据 ...

  9. 转:二十一、详细解析Java中抽象类和接口的区别

    转:二十一.详细解析Java中抽象类和接口的区别 http://blog.csdn.net/liujun13579/article/details/7737670 在Java语言中, abstract ...

随机推荐

  1. how2heap分析系列:2_fastbin_dup

    源码 #include <stdio.h> #include <stdlib.h> int main() { printf("This file demonstrat ...

  2. linux文件系统体系结构 和 虚拟文件系统(VFS)

    图 1. Linux 文件系统组件的体系结构 用户空间包含一些应用程序(例如,文件系统的使用者)和 GNU C 库(glibc),它们为文件系统调用(打开.读取.写和关闭)提供用户接口.系统调用接口的 ...

  3. ASP.NET之纠错

    甘特图是:计划项目的时间安排和资源平衡 IoC容器会自动判断javabean和某些数据类型是否建立起依赖关系(装配是否成功),主要用在自动装配中. 通过设置属性<bean id="&q ...

  4. JDBC中的Statement和PreparedStatement的区别

    JDBC中的Statement和PreparedStatement的区别  

  5. CentOS 7搭建SVN服务器

    安装步骤如下: 1.yum install subversion 2.查看安装版本 svnserve --version 3.创建SVN版本库目录 mkdir -p /var/svn/svnrepos ...

  6. Basic EEG waves 四种常见EEG波形

    Source: https://www.medicine.mcgill.ca/physio/vlab/biomed_signals/eeg_n.htm The electroencephalogram ...

  7. SQL函数汇总【精选篇】

    1.绝对值   SQL:select abs(-1) value  O:select abs(-1) value from dual  2.取整(大)   S:select ceiling(-1.00 ...

  8. 从2G到5G, 基站天线过去与未来

    在蜂窝移动通信系统中,天线是电路信号与空间辐射电磁波的转换器,是移动通信系统的末梢关键组成部分. 从2G到4G,移动基站天线经历了全向天线.定向单极化天线.定向双极化天线.电调单极化天线.电调双极化天 ...

  9. 初探Socket

    使用Socket Socket是两台主机之间的一个连接,它可以完成7个操作. 连接远程机器 发送数据 接收数据 关闭连接 绑定端口 监听入站数据 在绑定端口上接受来自远程机器的连接 Java中的Soc ...

  10. 在html中添加script脚本的方法和注意事项

    在html中添加script脚本有两种方法,直接将javascript代码添加到html中与添加外部js文件,这两种方法都比较常用,大家可以根据自己需要自由选择 在html中添加<script& ...