• <menu id="w2i4a"></menu>
  • logo DevExpress WinForm中文手冊

    文檔首頁>>DevExpress WinForm中文手冊>>如何:本地化條形和帶狀皮膚項目

    如何:本地化條形和帶狀皮膚項目


    立即下載DevExpress WinForms

    可以利用Localizer對象自定義皮膚菜單替代遍歷每個條形皮膚子菜單項和帶狀皮膚圖庫項容器來手動修改項目,這種方法允許您一次性自定義所有現(xiàn)有的欄子菜單和帶狀畫廊中的皮膚項目。

    1.創(chuàng)建一個BarLocalizer類的子類,并覆蓋它的虛擬XtraLocalizer<T>.GetLocalizedString方法。

    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.使用靜態(tài)BarLocalizerActive屬性設(shè)置一個自定義類的新實例作為當前欄的本地化程序,在Application.Run方法調(diào)用之前在Program類中調(diào)用此方法,如下所示。

    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.運行應(yīng)用程序來查看結(jié)果。

    運行程序

    注意:如果自定義本地化程序是在工具條皮膚子項之后分配的,或者如果Ribbon皮膚圖庫已經(jīng)初始化(例如,在Load事件上),皮膚項目將顯示默認標題。在這種情況下,調(diào)用靜態(tài)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
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();