今天有空,下班前补齐解析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. Echarts在JavaWeb中与后台的交互实现

    本Web系统后台框架是:Spring+SpringMVC+Mybatis+Shiro+Maven.完整系统搭建的配置过程见上一篇文章:基于Spring+SpringMVC+Mybatis的Web系统搭 ...

  2. zabbix完整安装

    一.nginx安装 1.必要软件准备: 为了支持rewrite功能,我们需要安装pcre: yum install pcre-* 需要ssl的支持,如果不需要ssl支持,请跳过这一步: yum ins ...

  3. 安装wampserver时提示丢失MSVCR110.dll(在windows server上可用)

    对于32位系统,安装Wampserver 后启动的时候提示系统错误:MSVCR110.dll丢失. 于是卸载原来的WAMPSERVER .安装vcredist_x86.exe,重新安装WAMPSERV ...

  4. 【转】[fix] Wireshark error: There are no interfaces on which a capture can be done. on Mac OS X

    I got the following error message when trying to open a network interface for capture using Wireshar ...

  5. 表单元素——checkbox样式美化

    一.背景 设计狮童鞋总是会设计各种高大上的效果图,比如下面这个土豪金的效果. 该图中“已阅读并同意相关服务条款”前面的复选框有一个金色的边框,打钩时是一个金色的对勾.接下来说说怎样实现该效果. 二.解 ...

  6. 破解 Windows 下Markdown 编辑器 MarkdownPad 2

    MarkdownPad 是 Windows 平台下一款优秀的 Markdown 编辑器,本文简单介绍 Markdown 以及使用一种方法破解 MarkdownPad 使其升级到专业版.该方法仅限于教育 ...

  7. j2ee之Filter使用实例(页面跳转)

    javax.servlet.Filter类中主要有三个方法. public void destroy(); //销毁对象 public void doFilter(ServletRequest req ...

  8. spring3 DI基础

    Spring IOC容器的依赖有两层含义:Bean依赖容器和容器注入Bean的依赖资源: Bean依赖容器:bean要依赖于容器,这里的依赖是指容器负责创建Bean并管理bean的生命周期.正是由于由 ...

  9. php调接口

    浏览器直接访问接口时会弹出账号密码框 当用程序调用时需要加入    curl_setopt($ch, CURLOPT_USERPWD, "$username:$password") ...

  10. [LeetCode] Total Hamming Distance 全部汉明距离

    The Hamming distance between two integers is the number of positions at which the corresponding bits ...