彩票走势图

logo DevExpress WinForm中文手册
文档彩票走势图>>DevExpress WinForm中文手册>>如何:本地化条形和带状皮肤项目

如何:本地化条形和带状皮肤项目


立即下载DevExpress WinForms

可以利用Localizer对象自定义皮肤菜单替代遍历每个条形皮肤子菜单项和带状皮肤图库项容器来手动修改项目,这种方法允许您一次性自定义所有现有的栏子菜单和带状画廊中的皮肤项目。

1.创建一个类的子类,并覆盖它的虚拟方法。

C#:

public class MyBarLocalizer : BarLocalizer {
public override string GetLocalizedString(BarString id) {
if(id == BarString.SkinCaptions) {
string defaultSkinCaptions = base.GetLocalizedString(id);
string newSkinCaptions = defaultSkinCaptions.Replace("|DevExpress Style|", "|Default Skin|");
newSkinCaptions = newSkinCaptions.Replace("|DevExpress Dark Style|", "|Default Dark Skin|");
return newSkinCaptions;
}
return base.GetLocalizedString(id);
}
}

VB.NET:

Public Class MyBarLocalizer
Inherits BarLocalizer

Public Overrides Function GetLocalizedString(ByVal id As BarString) As String
If id Is BarString.SkinCaptions Then
Dim defaultSkinCaptions As String = MyBase.GetLocalizedString(id)
Dim newSkinCaptions As String = defaultSkinCaptions.Replace("|DevExpress Style|", "|Default Skin|")
newSkinCaptions = newSkinCaptions.Replace("|DevExpress Dark Style|", "|Default Dark Skin|")
Return newSkinCaptions
End If
Return MyBase.GetLocalizedString(id)
End Function
End Class

2.使用静态BarLocalizerActive属性设置一个自定义类的新实例作为当前栏的本地化程序,在Application.Run方法调用之前在Program类中调用此方法,如下所示。

C#:

static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
BonusSkins.Register();
SkinManager.EnableFormSkins();
BarLocalizer.Active = new MyBarLocalizer();
Application.Run(new Form1());
}
}

VB.NET:

Friend NotInheritable Class Program

Private Sub New()
End Sub

''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread>
Shared Sub Main()
BonusSkins.Register()
SkinManager.EnableFormSkins()
BarLocalizer.Active = New MyBarLocalizer()
Application.Run(New Form1())
End Sub
End Class

3.运行应用程序来查看结果。

运行程序

注意:如果自定义本地化程序是在工具条皮肤子项之后分配的,或者如果Ribbon皮肤图库已经初始化(例如,在Load事件上),皮肤项目将显示默认标题。在这种情况下,调用静态SkinHelper.InitSkinPopupMenu和SkinHelpber.InitSkinGallery 方法来再次初始化皮肤项目并激活本地化器。

C#:

void ucBar_Load(object sender, EventArgs e) {
BarLocalizer.Active = new MyBarLocalizer();
//refresh bar sub-item links
skinBarSubItem1.ClearLinks();
SkinHelper.InitSkinPopupMenu(skinBarSubItem1);
//refresh Ribbon gallery links
SkinHelper.InitSkinGallery(skinRibbonGalleryBarItem1);
}

VB.NET:

Private Sub ucBar_Load(ByVal sender As Object, ByVal e As EventArgs)
BarLocalizer.Active = New MyBarLocalizer()
'refresh bar sub-item links
skinBarSubItem1.ClearLinks()
SkinHelper.InitSkinPopupMenu(skinBarSubItem1)
'refresh ribbon gallery links
SkinHelper.InitSkinGallery(skinRibbonGalleryBarItem1)
End Sub
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP