在c#中以编程方式更改颜色Visio形状

问题描述 投票:0回答:6

我想通过代码更改Visio中BPMN-Shape的颜色。到目前为止我所做的是使用以下代码片段更改Visio中ShapeSheet的“LineColor”单元格的值:

 _startShape.CellsU["LineColor"].FormulaForceU = "=RGB(255,0,0)";

但是,我自己绘制的形状并没有改变颜色。 ShapeSheet-Cell中的信息/值正在变化,但颜色仍然不可见。我读到了保护细胞的GUARD功能,但是FormulaForceU应该忽略GUARD。

导入的形状正在按预期变化!只是自绘不会变为红色(RGB(255,0,0)。

我无法弄清楚为什么!有谁经历过同样的经历?

提前致谢!

c# colors cell visio bpmn
6个回答
2
投票

如果形状是一个组,那么您还需要更改子形状。


1
投票

选择任何形状,单击鼠标右键。查找组下拉列表,如果Ungroup选项未显示为灰色,则选中的形状为组

select any shape, click by right mouse button. Find **Group** drop-list, if there **Ungroup** option then selected shape is group


1
投票

您还可以通过绘图资源管理器窗口查看“形状解剖”,您可以在功能区上的“开发人员”选项卡上激活此窗口

Drawing explorer window


0
投票

尝试使用visio默认系统颜色常量 - vbRed或2 - VisDefaultColors Enumeration (Visio)

_startShape.CellsU [“LineColor”]。FormulaForceU = 2;


0
投票

我发现这个建议(使用CellsSRC语法)在俄罗斯stackoverflow发布Change text color in Visio

Visio.Cell colorCell = shape.get_CellsSRC((短)Visio.VisSectionIndices.visSectionCharacter,(简称)Visio.VisRowIndices.visRowCharacter,(简称)Visio.VisCellIndices.visCharacterColor); colorCell.FormulaForceU =“RGB(0,255,255)”;


0
投票

我有适合我的解决方案。我不相信这是最好的,因为Surrogate指出你可以潜入形状解剖,并准确看看你需要改变什么。但是,如果没有这种迭代方法,我仍然无法弄清楚如何精确地获得需要改变的形状。此代码正在更改形状线条颜色而没有副作用。

public static void HighlightShape(Shape shape)
{
    if (shape == null) {
        return;
    }

    var processList = new Queue<Shape>();
    processList.Enqueue(shape);

    var allShapes = new List<Shape>();
    allShapes.Add(shape);

    while (processList.Count > 0) 
    {
        var s = processList.Dequeue();
        allShapes.Add(s);
        if (s.Shapes != null) {
            foreach (Shape subshape in s.Shapes) {
                processList.Enqueue(subshape);
            }
        }
    }

    foreach (Shape s in allShapes) 
    {
        s.CellsU["LineColor"].FormulaForceU = "THEMEGUARD(RGB(255,255,0))";
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.