原創|使用教程|編輯:郝浩|2013-06-08 14:33:38.000|閱讀 541 次
概述:業務流程圖控件FlowChart.NET提供了用于創建或編輯圖表的直觀的用戶交互模型。在本文中將會給出一部分內容關于創建一個自定義的CompositeNode 類,用于顯示在組織中的獨立信息,如名稱、 說明和圖像。節點將會通過各種公開的屬性進行自定義。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
業務流程圖控件FlowChart.NET提供了用于創建或編輯圖表的直觀的用戶交互模型。在前面的教程中,探討了如何創建復合節點和組件。在本文中將會給出一部分內容關于創建一個自定義的CompositeNode 類,用于顯示在組織中的獨立信息,如名稱、 說明和圖像。節點將會通過各種公開的屬性進行自定義。
創建一個從CompositeNode 類派生的自定義復合節點,需要先進行聲明:
C#
public class OrgChartNode : CompositeNode { }
Visual Basic
Public Class OrgChartNode Inherits CompositeNode End Class
可應用在不同的方案中創建一個自定義節點,比如,如果你想要定義在XML中的節點的內容,還想要聲明對于不同組件的事件處理程序,或是你想要應用自定義組件安排邏輯或是自定義呈現。
添加一個單獨的構造函數到新創建的節點類,將會使用到下面的內容:
C#
... public OrgChartNode(Diagram diagram) : base(diagram) { string content = @" <SimplePanel> <Shape Name=""Shape"" Shape=""Rectangle"" /> <Border Padding=""2""> <GridPanel> <GridPanel.Columns> <GridColumn Width=""30"" /> <GridColumn /> </GridPanel.Columns> <GridPanel.Rows> <GridRow /> </GridPanel.Rows> <Image Name=""Image"" ImageAlign=""Fit"" /> <StackPanel Orientation=""Vertical"" GridColumn=""1""> <Text Name=""Title"" Font=""Arial, 12pt, style=Bold"" TextAlignment=""Near"" /> <Text Name=""FullName"" TextColor=""Blue"" TextAlignment=""Near"" /> <Text Name=""Text"" Font=""Arial, 8pt"" TextAlignment=""Near"" /> </StackPanel> </GridPanel> </Border> </SimplePanel>"; Components.Add(XmlLoader.Load(content, null, null)); } ...
Visual Basic
... Public Sub New(ByVal diagram As Diagram) MyBase.new(diagram) Dim content As String = _ "<SimplePanel>" & _ "" & _ " <Shape Name=""Shape"" Shape=""Rectangle"" />" & _ "" & _ " <Border Padding=""2"">" & _ " <GridPanel>" & _ " <GridPanel.Columns>" & _ " <GridColumn Width=""30"" />" & _ " <GridColumn />" & _ " </GridPanel.Columns>" & _ " <GridPanel.Rows>" & _ " <GridRow />" & _ " </GridPanel.Rows>" & _ "" & _ " <Image Name=""Image"" ImageAlign=""Fit"" />" & _ "" & _ " <StackPanel Orientation=""Vertical"" GridColumn=""1"">" & _ " <Text Name=""Title"" Font=""Arial, 12pt, style=Bold"" TextAlignment=""Near"" />" & _ " <Text Name=""FullName"" TextColor=""Blue"" TextAlignment=""Near"" />" & _ " <Text Name=""Text"" Font=""Arial, 8pt"" TextAlignment=""Near"" />" & _ " </StackPanel>" & _ " </GridPanel>" & _ " </Border>" & _ "" & _ "</SimplePanel>" Components.Add(XmlLoader.Load(content, Nothing, Nothing)) End Sub ...
現在節點的內容已經定義好和導入了,將添加幾個字段到指定到感興趣的不同組件的類上,添加下面的字段到類的最后:
C#
private ShapeComponent shape; private ImageComponent image; private TextComponent title; private TextComponent fullName; private TextComponent text;
Visual Basic
Private _shape As ShapeComponent Private _image As ImageComponent Private _title As TextComponent Private _fullName As TextComponent Private _text As TextComponent
要初始化引用相應組件的字段,可以使用CompositeNode 類的FindComponent方法。在組件太能極愛到節點的組件連接之后,這個方法將會成功的運行。在組件連接到復合節點之后,在函數中添加下面的代碼:
C#
... Components.Add(XmlLoader.Load(content, null, null)); shape = FindComponent("Shape") as ShapeComponent; image = FindComponent("Image") as ImageComponent; title = FindComponent("Title") as TextComponent; fullName = FindComponent("FullName") as TextComponent; text = FindComponent("Text") as TextComponent; ...
Visual Basic
... Components.Add(XmlLoader.Load(content, Nothing, Nothing)) _shape = CType(FindComponent("Shape"), ShapeComponent) _image = CType(FindComponent("Image"), ImageComponent) _title = CType(FindComponent("Title"), TextComponent) _fullName = CType(FindComponent("FullName"), TextComponent) _text = CType(FindComponent("Text"), TextComponent) ...
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件