原創|使用教程|編輯:郝浩|2013-05-31 17:43:40.000|閱讀 834 次
概述:FlowChart.NET是一個通用的流程圖控件,提供了用于創建或編輯圖表的直觀的用戶交互模型。本教程展示在FlowChart.NET如何創建自定義節點類型。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
FlowChart.NET是一個通用的流程圖控件,提供了用于創建或編輯圖表的直觀的用戶交互模型。本教程展示在FlowChart.NET如何創建自定義節點類型。
1、定義一個自定義節點類
DiagramNode定義自定義節點類(本教程中使用的名稱IconNode )。
C#
public class IconNode : DiagramNode { }
Visual Basic
Public Class IconNode Inherits DiagramNode End Class
2、定義一個靜態構造函數
頂一個靜態構造函數來初始化類的靜態成員。
C#
static IconNode() { defaultIcon = new Bitmap(48, 48); Graphics graphics = Graphics.FromImage(defaultIcon); Font font = new Font("Arial", 48, FontStyle.Bold, GraphicsUnit.Pixel); graphics.FillRectangle(Brushes.Transparent, 0, 0, 48, 48); graphics.DrawString("?", font, Brushes.Black, 0, 0); font.Dispose(); graphics.Dispose(); }
Visual Basic
Shared Sub New() defaultIcon = New Bitmap(48, 48) Dim graphics As Graphics = graphics.FromImage(defaultIcon) Dim font As Font = New Font("Arial", 48, FontStyle.Bold, GraphicsUnit.Pixel) graphics.FillRectangle(Brushes.Transparent, 0, 0, 48, 48) graphics.DrawString("?", font, Brushes.Black, 0, 0) font.Dispose() graphics.Dispose() End Sub
3、定義一個公共的構造函數
定義構造函數來初始化實例成員。
C#
public IconNode(Diagram diagram) : base(diagram) { icon = defaultIcon; label = "Label"; format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; Bounds = new RectangleF(Bounds.Location, CalculateSize()); }
Visual Basic
Sub New(ByVal diagram As Diagram) MyBase.New(diagram) fIcon = defaultIcon fLabel = "Label" format = New StringFormat format.Alignment = StringAlignment.Center format.LineAlignment = StringAlignment.Center Bounds = New RectangleF(Bounds.Location, CalculateSize()) End Sub
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件