原創(chuàng)|使用教程|編輯:郝浩|2013-06-08 14:33:38.000|閱讀 541 次
概述:業(yè)務(wù)流程圖控件FlowChart.NET提供了用于創(chuàng)建或編輯圖表的直觀的用戶交互模型。在本文中將會給出一部分內(nèi)容關(guān)于創(chuàng)建一個自定義的CompositeNode 類,用于顯示在組織中的獨(dú)立信息,如名稱、 說明和圖像。節(jié)點(diǎn)將會通過各種公開的屬性進(jìn)行自定義。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
業(yè)務(wù)流程圖控件FlowChart.NET提供了用于創(chuàng)建或編輯圖表的直觀的用戶交互模型。在前面的教程中,探討了如何創(chuàng)建復(fù)合節(jié)點(diǎn)和組件。在本文中將會給出一部分內(nèi)容關(guān)于創(chuàng)建一個自定義的CompositeNode 類,用于顯示在組織中的獨(dú)立信息,如名稱、 說明和圖像。節(jié)點(diǎn)將會通過各種公開的屬性進(jìn)行自定義。
創(chuàng)建一個從CompositeNode 類派生的自定義復(fù)合節(jié)點(diǎn),需要先進(jìn)行聲明:
C#
public class OrgChartNode : CompositeNode { }
Visual Basic
Public Class OrgChartNode Inherits CompositeNode End Class
可應(yīng)用在不同的方案中創(chuàng)建一個自定義節(jié)點(diǎn),比如,如果你想要定義在XML中的節(jié)點(diǎn)的內(nèi)容,還想要聲明對于不同組件的事件處理程序,或是你想要應(yīng)用自定義組件安排邏輯或是自定義呈現(xiàn)。
添加一個單獨(dú)的構(gòu)造函數(shù)到新創(chuàng)建的節(jié)點(diǎn)類,將會使用到下面的內(nèi)容:
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 ...
現(xiàn)在節(jié)點(diǎn)的內(nèi)容已經(jīng)定義好和導(dǎo)入了,將添加幾個字段到指定到感興趣的不同組件的類上,添加下面的字段到類的最后:
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
要初始化引用相應(yīng)組件的字段,可以使用CompositeNode 類的FindComponent方法。在組件太能極愛到節(jié)點(diǎn)的組件連接之后,這個方法將會成功的運(yùn)行。在組件連接到復(fù)合節(jié)點(diǎn)之后,在函數(shù)中添加下面的代碼:
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) ...
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件