今天有空,下班前补齐解析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. [笔记]linux用户与用户组

    sudo useradd -m john 自动建立主目录 sudo passwd john sudo useradd -g groupusers mike sudo useradd -s /bin/b ...

  2. 用nginx一分钟实现文件服务器

    在局域网内和同事共享文件的好方法 1 安装nginx sudo apt-get install nginx 2 创建conf文件 sudo gedit /etc/nginx/conf.d/file_s ...

  3. Ubuntu 15.1 unity在顶部面板显示系统CPU/内存/网络速度

    全部的文件:http://files.cnblogs.com/files/xiaobo-Linux/ubuntu%E6%98%BE%E7%A4%BA%E7%B3%BB%E7%BB%9F%E7%BD%9 ...

  4. NGUI裁剪模型和粒子

    效果预览 注:Cube上附着的绿色是我添加的粒子效果. 软件环境 NGUI 3.9.x Unity 5.1 x64 相关知识 RenderTexture RenderTexture是一种特殊的纹理,它 ...

  5. IOS错误Could not produce class with ID

    运行环境 Unity 5.3.5f1 (IL2CPP)编译IOS版本 XCode Version 7.2.1 (7C1002) Mac OS X 10.11.3 (15D21) (Mac mini) ...

  6. ActiveMQ笔记(6):消息延时投递

    在开发业务系统时,某些业务场景需要消息定时发送或延时发送(类似:飞信的短信定时发送需求),这时候就需要用到activemq的消息延时投递,详细的文档可参考官网说明,本文只介绍二种常用的用法: 注:本文 ...

  7. [LeetCode] Nested List Weight Sum II 嵌套链表权重和之二

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  8. [LeetCode] Palindrome Partitioning II 拆分回文串之二

    Given a string s, partition s such that every substring of the partition is a palindrome. Return the ...

  9. [LeetCode] N-Queens II N皇后问题之二

    Follow up for N-Queens problem. Now, instead outputting board configurations, return the total numbe ...

  10. Apache问题处理服务器访问不了

    1. 查看apache的错误日志 我的apache日志文件目录 /var/log/httpd/error.log [Sun Nov 20 21:17:24 2016] [error] server r ...