You can utilize a Localizer object to customize skin menus, instead of iterating through each Bar skin sub-menu item and Ribbon skin gallery item container to manually modify the items. This approach allows you to customize skin items in all existing bar sub-menus and Ribbon galleries at once.
Create a BarLocalizer class descendant and override its virtual XtraLocalizer<T>.GetLocalizedString method.
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);
}
}
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
Use the static BarLocalizer.Active property to set a new instance of your custom class as the current bar localizer. Call this method in the Program class before the Application.Run method call, as shown below.
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());
}
}
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
Run the application to see the result.
Important
If the custom localizer is assigned after a bar skin sub item, or if the Ribbon skin gallery is already initialized (e.g., on the Load event), skin items will display default captions. In this case, call static SkinHelper.InitSkinPopupMenu and SkinHelpber.InitSkinGallery methods to initialize skin items again and activate the localizer.
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);
}
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
See Also