我需要开发一个用于在visio中创建图表对象的插件。我能够创建顶部形状而不是其派生类型。 对于EG 我能够使用c#在visio中创建Start事件,但无法创建消息类型的Start Event或其他
在上图中我有3个开始事件,添加了BPMN开始事件并且其属性触发/结果选项已更改
开始活动 - 多个
开始活动 - 消息
开始活动 - 无
但以上3种形状均来自Start Event。如何创建Message start事件或Multiple start evet等。
我正在使用
在visio中创建形状 Visio.Master shapetodrop = Masters.get_ItemU(@"Start Event");
Visio.Shape DropShape = ActivePage.Drop(shapetodrop, x, y);
DropShape.Name = name;
DropShape.Text = name;
但这只会创建启动事件,如何创建消息启动事件,多启动事件等
答案 0 :(得分: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;
}
}
我可以获得Message start事件。像这个值可以分配形状的所有属性。
答案 1 :(得分:0)
我会在VBA中向您展示答案,并期望您可以转换为C#?
微软以他们的智慧为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