今天有空,下班前补齐解析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. 5-2 bash 脚本编程之一 变量、变量类型等

    1. bash变量类型 1. 环境变量 2. 本地变量(局部变量) 3. 位置变量 4. 特殊变量 2. 本地变量 VARNAME=VALUE, 整个bash进程 3. 环境变量 作用域为当前shel ...

  2. linux几种快速清空文件内容的方法

    linux几种快速清空文件内容的方法 几种快速清空文件内容的方法: $ : > filename #其中的 : 是一个占位符, 不产生任何输出. $ > filename $ echo & ...

  3. hibernate三种状态

    转自:http://www.cnblogs.com/xiaoluo501395377/p/3380270.html 学过hibernate的人都可能都知道hibernate有三种状态,transien ...

  4. 代码管理工具 --- git的学习笔记一《git的个人开发》

    重点摘要: 创建了一个文件后首先先通过git add . 添加到暂缓区,然后通过git commit -m "提交的名字" 提交到本地仓库,最后才可能push到远程仓库. 1. 个 ...

  5. JAVA中使用FTPClient实现文件上传下载实例代码

    一.上传文件 原理就不介绍了,大家直接看代码吧 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ...

  6. liunx关闭防火墙

    Redirecting to /bin/systemctl stop iptables.service systemctl stop iptables.service ?????? centos从7开 ...

  7. Redis的使用场景 by 杨卫华

    转载自新浪微博架构师杨卫华的博客 http://timyang.net/tag/redis/,省略了部分内容 按:杨卫华在2010年就已经测试了Redis的性能,并给出了初步的结论:“Redis性能惊 ...

  8. 浏览器控制台命令调试——console

    控制台命令调试时通过浏览器开发工具中的控制台命令嵌入到JavaScript中,输出特定的信息或日志,从而达到调试的目的. 我们常用的Chrome和FireFox,都可以通过F12来打开开发工具. 下面 ...

  9. h5面试题集合

    一.闭包的理解: 使用闭包主要是为了设计私有的方法和变量.闭包的优点是可以避免全局变量的污染,缺点是闭包会常驻内存,会增大内存使用量,使用不当很容易造成内存泄露. 闭包三个特性: 1.函数嵌套函数 ; ...

  10. 【编码】_C#中编码名称(Name)与页面标识(CodePage)的关系_编码gb2312的获取

    在写C#代码时,发现VS提供没有直接提供gb2312的中文编码, 所以,需要找到对应编码名称的codepage来调用想要的编码方式. 下面是微软编程提供的所有编码信息,包括编码名称,编码代码页标识符, ...