dexpress 流程图_流程图控件FlowChart.NET使用教程:设置图表样式和主题

在流程图和项目的外观,而且在整个的流程图中的外观和感觉也会更加的流畅,想要改变外观和主题可以通过简单的替换当前的主题。

主题编辑器

主题编辑器为主题创建和修改提供了简单易于操作的的视觉环境,通过左边的属性网格提供了示例图,里面包含了项目各种类型、可用的内置图列表、项目样式等。在网格中的对于样式的任何修改将会立即映射到图上,如果这个主题应用到图表上,这个预览将会反应改变的效果。这个主题可以在任何时间通过保存菜单进行保存。现有的主题也可以打开和更改。

下图显示了主题编辑器的操作:

自定义样式:

下面的部分描述了如何启用自定义项目类的样式属性,要使用样式,需要创建一个自定义的样式类,可以通过从最接近的现有类型派生出来。比如,对于一个自定义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

标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,尊重他人劳动成果

文章转载自:慧都控件

1

好文不易,鼓励一下吧!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值