原創|使用教程|編輯:郝浩|2013-05-29 15:32:46.000|閱讀 4507 次
概述:在FlowChart.NET中,通過使用樣式和主題,用了一個一致的方法來定制流程圖和項目的外觀。今天來看一下如何設置圖表樣式和主題。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
在業務流程圖控件FlowChart.NET中,通過使用樣式和主題,用了一個一致的方法來定制流程圖和項目的外觀,而且在整個的流程圖中的外觀和感覺也會更加的流暢,想要改變外觀和主題可以通過簡單的替換當前的主題。
主題編輯器為主題創建和修改提供了簡單易于操作的的視覺環境,通過左邊的屬性網格提供了示例圖,里面包含了項目各種類型、可用的內置圖列表、項目樣式等。在網格中的對于樣式的任何修改將會立即映射到圖上,如果這個主題應用到圖表上,這個預覽將會反應改變的效果。這個主題可以在任何時間通過保存菜單進行保存?,F有的主題也可以打開和更改。
下圖顯示了主題編輯器的操作:
下面的部分描述了如何啟用自定義項目類的樣式屬性,要使用樣式,需要創建一個自定義的樣式類,可以通過從最接近的現有類型派生出來。比如,對于一個自定義ShapeNode,自定義樣式需要從ShapeNodeStyle繼承:
C#
public class MyNodeStyle : ShapeNodeStyle { }
Visual Basic
Public Class MyNodeStyle Inherits ShapeNodeStyle End Class
對于在MyNode中的每個屬性都需要定義樣式,用一樣的名稱來定義屬性,通過下面的模式鍵入MyNodeStyle類。比如要是MyNode包含一個輸入筆刷的MyBrush屬性,下面的代碼定義了器相應的樣式屬性:
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
現在,在定制MyNode類中,定義一個新屬性,EffectiveMyBrush,它將返回MyBrush的實際值:
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
記得對序列化注冊的樣式類,以及定制節點類:
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)
現在你可以風格和主題自定義節點:
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
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件