我将Visio形状添加到Shape Array中。 我试图按其大小列出Visio形状。如何在升序/降序中订购?
Shape[] VisioShape = new Shape[0];
int Count = 0
foreach (Shape shape in VisioPage.Shapes)
{
if (shape.OneD != 0)
{
VisioShape[Count] = shape;
Count++;
}
}
答案 0 :(得分:0)
一些LINQ怎么样?以下是我在LinqPad中写的一个快速片段(根据这篇文章:http://visualsignals.typepad.co.uk/vislog/2015/12/getting-started-with-c-in-linqpad-with-visio.html)
void Main()
{
var vApp = MyExtensions.GetRunningVisio();
Visio.Page vPag = vApp.ActivePage;
var q = from s in vPag.Shapes.Cast<Visio.Shape>()
where s.OneD == 0
orderby s.CellsU["Height"].ResultIU
select s.Text;
q.Dump();
}
考虑到这样的形状:
Linqpad返回此信息:
如果您想在另一个方向订购,只需在orderby行的末尾添加descending
:
orderby s.CellsU["Height"].ResultIU descending