2015-10-07 19 views
5

Hi ho bisogno di sviluppare un addin per la creazione di oggetti diagramma in visio.Io sono in grado di creare la forma superiore ma non i suoi tipi derivati. per EG sono in grado di creat Inizio evento in Visio utilizzando C#, ma non ha potuto creare Inizio Evento di tipo di messaggio o altri enter image description hereCreazione di forme in visio utilizzando C#

Nella foto sopra ho 3 dell'evento di avvio, bene l'Evento avviamento BPMN era aggiunto e il suo trigger proprietà /conseguenza opzione è stata modificata

Inizio evento - multipla

Inizio evento - Messaggio

Evento Start - Nessuno

ma tutte le 3 forme precedenti sono da Evento Start. Come creare l'evento di avvio del messaggio o avviare più evet ecc

sto creando forme in Visio utilizzando

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

ma questo crea solo Inizio Evento, come creare un messaggio di inizio dell'evento, multipla Inizio Evento ecc

risposta

3

per l'iterazione attraverso ogni proprietà di una forma 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; 

         } 
} 

e posso ricevere l'evento di inizio messaggio. Come questo valore per tutte le proprietà di una forma può essere assegnato.

0

Ti mostrerò la risposta in VBA e prevedi che puoi convertire in C#?

Microsoft nella loro saggezza creato forme abbastanza complesse per BPMN, quindi, una volta impostato l'EventType, la lista per l'eventuale TriggerOrResult viene aggiornato ...

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

Grazie per la risposta :) :) – Arshad