首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Visio中设置形状、字体和预测颜色

如何在Visio中设置形状、字体和预测颜色
EN

Stack Overflow用户
提问于 2014-02-12 05:03:53
回答 1查看 4.7K关注 0票数 0

我需要在Visio文件中添加一个矩形,并要设置字体和文本颜色,如何做到这一点?

代码语言:javascript
运行
复制
visio.Application app = new visio.Application();
visio.Document doc;
doc = app.Documents.Open(processPath);

visio.Page page = doc.Pages[1];
CreateVisio vis = new CreateVisio();
visio.Shape edit = page.DrawRectangle(3.2d, 6.9d, 4.9d, 7.9d);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-09 12:05:23

如何创建新的VISIO文档

代码语言:javascript
运行
复制
Microsoft.Office.Interop.Visio.Application application = 
        new Microsoft.Office.Interop.Visio.Application();  
application.Visible = false; 
Microsoft.Office.Interop.Visio.Document doc = application.Documents.Add(templatePath);
Microsoft.Office.Interop.Visio.Page page = application.Documents[1].Pages[1];

如何获取您正在处理的工作表的宽度和高度

代码语言:javascript
运行
复制
double xPosition = page.PageSheet.get_CellsU("PageWidth").ResultIU;
double yPosition = page.PageSheet.get_CellsU("PageHeight").ResultIU; 

我们正在使用有关纸张宽度和高度的信息来知道放在哪里的盒子。我们把根框放在纸的中间,把纸的宽度除以根的数目。另外,我们从yPosition中减去电平数,这样,增加电平数的框将在图表上得到一个较低的位置。

如何创建形状并将其放置在图表(拖放)

代码语言:javascript
运行
复制
//creating the type of shape in the organizational chart it could be: "Position", 
//"Executive", "Manager",  "Assistant" and others according 
//to what you have in your stencil. 
Microsoft.Office.Interop.Visio.Master position = doc.Masters.get_ItemU("Position"); 
//placing the shape in the xPosition and yPosition coordinates
Microsoft.Office.Interop.Visio.Shape shape = page.Drop(position, xPosition, yPosition);  

如何设置形状属性

代码语言:javascript
运行
复制
//set the text
shape.Text = box.Name;

//set hyperlink
if (!String.IsNullOrEmpty(box.HyperLink.Trim()))
{
     Hyperlink link = shape.Hyperlinks.Add();
     link.Address = box.HyperLink;
}

//set the shape width
shape.get_CellsSRC(
                (short)Microsoft.Office.Interop.Visio.VisSectionIndices.
                visSectionObject,
                (short)Microsoft.Office.Interop.Visio.VisRowIndices.
                visRowXFormIn,
                (short)Microsoft.Office.Interop.Visio.VisCellIndices.
                visXFormWidth).ResultIU = box.Width;

//set the shape height
shape.get_CellsSRC(
               (short)Microsoft.Office.Interop.Visio.VisSectionIndices.
               visSectionObject,
               (short)Microsoft.Office.Interop.Visio.VisRowIndices.
               visRowXFormIn,
               (short)Microsoft.Office.Interop.Visio.VisCellIndices.
               visXFormHeight).ResultIU = box.Height;

//set the shape fore color
shape.Characters.set_CharProps(
                (short)Microsoft.Office.Interop.Visio.
                    VisCellIndices.visCharacterColor,
                (short)Utilities.GetVisioColor(box.ForeColor));

//set the shape back color
shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
         (short)VisRowIndices.visRowFill, 
    (short)VisCellIndices.visFillForegnd).FormulaU = 
    "RGB(" + box.BackColor.R.ToString() + "," + box.BackColor.G.ToString() + "," 
    + box.BackColor.B.ToString() + ")"; 

连接形状使用connectWithDynamicGlueAndConnector()方法完成。此方法接受两个参数,即父形状和childShape,并将在两个参数之间创建连接器。此方法正是VISIO中找到的方法。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21719120

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档