原創(chuàng)|使用教程|編輯:郝浩|2013-05-29 15:32:46.000|閱讀 4507 次
概述:在FlowChart.NET中,通過使用樣式和主題,用了一個(gè)一致的方法來定制流程圖和項(xiàng)目的外觀。今天來看一下如何設(shè)置圖表樣式和主題。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
在業(yè)務(wù)流程圖控件FlowChart.NET中,通過使用樣式和主題,用了一個(gè)一致的方法來定制流程圖和項(xiàng)目的外觀,而且在整個(gè)的流程圖中的外觀和感覺也會更加的流暢,想要改變外觀和主題可以通過簡單的替換當(dāng)前的主題。
主題編輯器為主題創(chuàng)建和修改提供了簡單易于操作的的視覺環(huán)境,通過左邊的屬性網(wǎng)格提供了示例圖,里面包含了項(xiàng)目各種類型、可用的內(nèi)置圖列表、項(xiàng)目樣式等。在網(wǎng)格中的對于樣式的任何修改將會立即映射到圖上,如果這個(gè)主題應(yīng)用到圖表上,這個(gè)預(yù)覽將會反應(yīng)改變的效果。這個(gè)主題可以在任何時(shí)間通過保存菜單進(jìn)行保存。現(xiàn)有的主題也可以打開和更改。
下圖顯示了主題編輯器的操作:
下面的部分描述了如何啟用自定義項(xiàng)目類的樣式屬性,要使用樣式,需要?jiǎng)?chuàng)建一個(gè)自定義的樣式類,可以通過從最接近的現(xiàn)有類型派生出來。比如,對于一個(gè)自定義ShapeNode,自定義樣式需要從ShapeNodeStyle繼承:
C#
public class MyNodeStyle : ShapeNodeStyle { }
Visual Basic
Public Class MyNodeStyle Inherits ShapeNodeStyle End Class
對于在MyNode中的每個(gè)屬性都需要定義樣式,用一樣的名稱來定義屬性,通過下面的模式鍵入MyNodeStyle類。比如要是MyNode包含一個(gè)輸入筆刷的MyBrush屬性,下面的代碼定義了器相應(yīng)的樣式屬性:
C#
public class MyNodeStyle : ShapeNodeStyle { public MyNodeStyle() { myBrushProperty = RegisterProperty("MyBrush"); } public Brush MyBrush { get { return (Brush)GetValue(myBrushProperty); } set { SetValue(myBrushProperty, value); } } private object myBrushProperty; }
Visual Basic
Public Class MyNodeStyle Inherits ShapeNodeStyle Public Sub New() myBrushProperty = RegisterProperty("MyBrush") End Sub Public Property MyBrush() As Brush Get Return DirectCast(GetValue(myBrushProperty), Brush) End Get Set SetValue(myBrushProperty, value) End Set End Property Private myBrushProperty As Object End Class
現(xiàn)在,在定制MyNode類中,定義一個(gè)新屬性,EffectiveMyBrush,它將返回MyBrush的實(shí)際值:
C#
public Brush EffectiveMyBrush
{
get
{
// Checking for local value
if (MyBrush != null)
return MyBrush;
// Querying the property value through the style system
return (Brush)GetValue("MyBrush");
}
}
Visual Basic
Public ReadOnly Property EffectiveMyBrush() As Brush
Get
' Checking for local value
If MyBrush IsNot Nothing Then
Return MyBrush
End If
' Querying the property value through the style system
Return DirectCast(GetValue("MyBrush"), Brush)
End Get
End Property
記得對序列化注冊的樣式類,以及定制節(jié)點(diǎn)類:
C#
Diagram.RegisterClass(typeof(MyNode), "MyNode", 1); Diagram.RegisterClass(typeof(MyNodeStyle), "MyNodeStyle", 1);
Visual Basic
Diagram.RegisterClass(GetType(MyNode), "MyNode", 1)
Diagram.RegisterClass(GetType(MyNodeStyle), "MyNodeStyle", 1)
現(xiàn)在你可以風(fēng)格和主題自定義節(jié)點(diǎn):
C#
Theme theme = new Theme(); MyNodeStyle myNodeStyle = new MyNodeStyle(); myNodeStyle.MyBrush = new SolidBrush(Color.PaleGoldenrod); theme.RegisterStyle(typeof(MyNode), myNodeStyle); diagram.Theme = theme;
Visual Basic
Dim theme As New Theme()
Dim myNodeStyle As New MyNodeStyle()
myNodeStyle.MyBrush = New SolidBrush(Color.PaleGoldenrod)
theme.RegisterStyle(GetType(MyNode), myNodeStyle)
diagram.Theme = theme
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件