5

嗨,我需要开发一个插件来在 visio 中创建图表对象。我能够创建顶部形状,但不能创建其派生类型。对于 EG,我可以使用 c# 在 vi​​sio 中创建开始事件,但无法创建消息类型或其他类型的开始事件 在此处输入图像描述

在上图中,我有 3 个启动事件,添加了 BPMN 启动事件并更改了其属性Trigger/Result选项

开始事件 - 多个

开始事件 - 消息

开始事件 - 无

但以上 3 个形状均来自 Start Event。如何创建消息启动事件或多启动事件等。

我正在使用 visio 创建形状

            Visio.Master shapetodrop = Masters.get_ItemU(@"Start Event");
            Visio.Shape DropShape = ActivePage.Drop(shapetodrop, x, y);
            DropShape.Name = name;
            DropShape.Text = name;

但这只会创建 Start Event ,如何创建 Message Start EVent , Multiple Start Event 等

4

2 回答 2

3

用于遍历 visio 中形状的每个属性

  short iRow = (short)Visio.VisRowIndices.visRowFirst;
            while (shape.get_CellsSRCExists((short)Visio.VisSectionIndices.visSectionProp, iRow, (short)Visio.VisCellIndices.visCustPropsValue, (short)Visio.VisExistsFlags.visExistsAnywhere) != 0)
            {
                Visio.Cell c = shape.get_CellsSRC((short)Visio.VisSectionIndices.visSectionProp, iRow, (short)Visio.VisCellIndices.visCustPropsValue);
                         switch (c.Name)
                        {
                            case "Prop.BpmnTriggerOrResult":
                                shape.Cells[c.Name].FormulaU = "\"" + "Message" + "\"";
                                break;

                        }
}

我可以得到消息开始事件。可以为形状的所有属性分配此值。

于 2015-10-13T11:04:30.130 回答
0

我将在 VBA 中向您展示答案,并期望您可以转换为 C#?

Microsoft 在他们的智慧中为 BPMN 创建了相当复杂的形状,因此,一旦您设置了 EventType,可能的 TriggerOrResult 的列表就会更新......

Public Sub DropEventShape()
On Error GoTo errHandler

'EventType is one of the following : "Start;Start (Non-Interrupting);Intermediate;Intermediate (Non-Interrupting);Intermediate (Throwing);End"

Const mstName As String = "Start Event"
Const eventType As String = "Start"
Const triggerOrResult As String = "Multiple"

Dim doc As Visio.Document
Dim stn As Visio.Document
Dim mst As Visio.Master

    For Each doc In Application.Documents
        If doc.Title = "BPMN Shapes" Then
            Set stn = doc
            Exit For
        End If
    Next
    If stn Is Nothing Then
        GoTo exitHere
    End If

    Set mst = stn.Masters(mstName)

Dim shp As Visio.Shape
Dim x As Double
Dim y As Double
    x = Application.ActivePage.PageSheet.Cells("PageWidth").ResultIU * 0.5
    y = Application.ActivePage.PageSheet.Cells("PageHeight").ResultIU * 0.5

    Set shp = Application.ActivePage.Drop(mst, x, y)

Dim iEventType As Integer
Dim aryEventTypes() As String

    aryEventTypes = Split(shp.Cells("Prop.BPMNEventType.Format").ResultStr(""), ";")
    For iEventType = 0 To UBound(aryEventTypes)
        If aryEventTypes(iEventType) = eventType Then
            Exit For
        End If
    Next
    shp.Cells("Prop.BPMNEventType").Formula = "=INDEX(" & iEventType & ",Prop.BPMNEventType.Format)"

Dim iTriggerOrResult As Integer
Dim aryTriggerOrResults() As String
    aryTriggerOrResults = Split(shp.Cells("Prop.BpmnTriggerOrResult.Format").ResultStr(""), ";")
    For iTriggerOrResult = 0 To UBound(aryTriggerOrResults)
        If aryTriggerOrResults(iTriggerOrResult) = triggerOrResult Then
            Exit For
        End If
    Next

    shp.Cells("Prop.BpmnTriggerOrResult").Formula = "=INDEX(" & iTriggerOrResult & ",Prop.BpmnTriggerOrResult.Format)"

exitHere:
    Exit Sub
errHandler:
    MsgBox Err.Description
    Resume exitHere
End Sub
于 2015-10-13T10:59:15.937 回答