2015-10-07 15 views
5

Hi tôi cần phải phát triển một addin để tạo các đối tượng sơ đồ trong visio.I có thể tạo ra hình dạng hàng đầu nhưng không phải là các kiểu có nguồn gốc của nó. cho EG i am có thể tạo sự kiện Start trong Visio sử dụng C#, nhưng không thể tạo Bắt đầu tổ chức sự kiện của loại tin nhắn hoặc những người khác enter image description hereTạo hình dạng trong Visio bằng cách sử dụng C#

Trong hình ở trên tôi có 3 sự kiện bắt đầu, tốt BPMN Bắt đầu sự kiện là bổ sung và tài sản kích hoạt của nó/quả tùy chọn được thay đổi

Bắt đầu tổ chức sự kiện - Nhiều

Bắt đầu tổ chức sự kiện - tin nhắn

Sự kiện bắt đầu - Không có

nhưng tất cả 3 hình dạng trên là từ Sự kiện bắt đầu. Làm thế nào để tạo ra các sự kiện tin nhắn bắt đầu hoặc bắt đầu Nhiều evet, vv

tôi đang tạo ra hình dạng trong Visio sử dụng

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

nhưng điều này chỉ tạo ra Bắt đầu tổ chức sự kiện, làm thế nào để tạo ra tin nhắn bắt đầu sự kiện, Nhiều Bắt đầu tổ chức sự kiện vv

Trả lời

3

Đối lặp qua từng tài sản của một hình dạng 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; 

         } 
} 

và tôi có thể nhận sự kiện bắt đầu tin nhắn. Giống như giá trị này cho tất cả các thuộc tính của một hình dạng có thể được chỉ định.

0

Tôi sẽ cho bạn thấy câu trả lời trong VBA, và mong rằng bạn có thể chuyển đổi thành C#?

Microsoft trong sự khôn ngoan của họ tạo ra hình dạng khá phức tạp đối với BPMN, vì vậy, một khi bạn đã thiết lập các eventType, danh sách cho TriggerOrResult có thể được cập nhật ...

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

Cảm ơn bạn đã trả lời :) :) – Arshad

Các vấn đề liên quan