Creating shapes in visio using c #

Hi, I need to develop addin to create diagram objects in visio. I can create a top form, but not its derived types. for EG I can create an initial event in visio using C #, but could not create an initial event like a message or other enter image description here

In the above figure, I have 3 start events, well, a BPMN start event has been added, and its Trigger / Result property has been changed

The start of the event is several

Event Start - Message

Start Event - No

but all of the above 3 forms are taken from the Start Event. How to create a message trigger event or evet multiple trigger, etc.

I create shapes in visio using

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

but this only creates a Start Event, how to create a Message Start EVENT, Multiple Start Event, etc.

+5
source share
2 answers

Iterate through each form property in 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; } } 

and I can get the message start event. Like this value, you can assign a form property to the whole property.

+3
source

Will I show you the answer in VBA and expect that you can convert to C #?

Microsoft in its wisdom created quite complex forms for BPMN, so once you have installed EventType, the list for a possible TriggerOrResult is updated ...

 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 
0
source

Source: https://habr.com/ru/post/1233136/


All Articles