اكملت منظومة من عدة ايام ولكن كانت DevexpressXtraMessageBox تظهر الرسائل ومربعات الحوار بالانجليزية
مثل موافق تظهرها OK او نعم تظهرها Yes وطبعا لانني متشدد في هذا الجانب ولا اظهر اي لغة الا العربية بحتث عن الحل وكان الحل في هذه الفئة
تقوم بانشاء هذه الفئة تم تستدعيها كما بالشكل التالي:
لاحظ في الفئة السابقة اغير نوعية الخط من خلال السطر التالي:
ايضا لدينا الاداة XtraGrid الخاصة بنفس الشركة يمكن تعريف ما فيها من اوامر ونصوص بهذه الفئة
كل ما تحتاجه هو استبدال الجملة باللغة العربية فقط في الاسفل مثلا انا غيرتها من الانجليزية الى الفرنسية
تحتاج الى استيراد مجال الاسماء التالي:
ثم في حدث التحميل تضع السطر التالي:
وسوف تتغير اسماء الاوامر من لصق وترتيب وفلترة وبحث وكل شئ الى اللغة التي كتبتها
مثل موافق تظهرها OK او نعم تظهرها Yes وطبعا لانني متشدد في هذا الجانب ولا اظهر اي لغة الا العربية بحتث عن الحل وكان الحل في هذه الفئة
كود :
Imports DevExpress.LookAndFeel
Imports System.ComponentModel
Imports DevExpress.XtraEditors
Imports DevExpress.Utils
Public NotInheritable Class MyXtraMessageBox
Private Sub New()
End Sub
Const DefaultCaption As String = ""
'Const DefaultOwner As IWin32Window = Nothing
Const DefaultButtons As MessageBoxButtons = MessageBoxButtons.OK
Const DefaultIcon As MessageBoxIcon = MessageBoxIcon.None
Const DefaultDefButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1
Public Shared Function Show(text As String) As DialogResult
Return Show(CType(Nothing, IWin32Window), text, DefaultCaption, DefaultButtons, DefaultIcon, DefaultDefButton)
End Function
Public Shared Function Show(owner As IWin32Window, text As String) As DialogResult
Return Show(owner, text, DefaultCaption, DefaultButtons, DefaultIcon, DefaultDefButton)
End Function
Public Shared Function Show(text As String, caption As String) As DialogResult
Return Show(CType(Nothing, IWin32Window), text, caption, DefaultButtons, DefaultIcon, DefaultDefButton)
End Function
Public Shared Function Show(owner As IWin32Window, text As String, caption As String) As DialogResult
Return Show(owner, text, caption, DefaultButtons, DefaultIcon, DefaultDefButton)
End Function
Public Shared Function Show(text As String, caption As String, buttons As MessageBoxButtons) As DialogResult
Return Show(CType(Nothing, IWin32Window), text, caption, buttons, DefaultIcon, DefaultDefButton)
End Function
Public Shared Function Show(owner As IWin32Window, text As String, caption As String, buttons As MessageBoxButtons) As DialogResult
Return Show(owner, text, caption, buttons, DefaultIcon, DefaultDefButton)
End Function
Public Shared Function Show(text As String, caption As String, buttons As MessageBoxButtons, icon As MessageBoxIcon) As DialogResult
Return Show(CType(Nothing, IWin32Window), text, caption, buttons, icon, DefaultDefButton)
End Function
Public Shared Function Show(owner As IWin32Window, text As String, caption As String, buttons As MessageBoxButtons, icon As MessageBoxIcon) As DialogResult
Return Show(owner, text, caption, buttons, icon, DefaultDefButton)
End Function
Public Shared Function Show(text As String, caption As String, buttons As MessageBoxButtons, icon As MessageBoxIcon, defaultButton As MessageBoxDefaultButton) As DialogResult
Return Show(CType(Nothing, IWin32Window), text, caption, buttons, icon, defaultButton)
End Function
Public Shared Function Show(owner As IWin32Window, text As String, caption As String, buttons As MessageBoxButtons, icon As MessageBoxIcon, defaultButton As MessageBoxDefaultButton) As DialogResult
Return Show(owner, text, caption, MessageBoxButtonsToDialogResults(buttons), MessageBoxIconToIcon(icon), MessageBoxDefaultButtonToInt(defaultButton), _
icon)
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, text As String) As DialogResult
Return Show(lookAndFeel, CType(Nothing, IWin32Window), text, DefaultCaption, DefaultButtons, DefaultIcon, _
DefaultDefButton)
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, owner As IWin32Window, text As String) As DialogResult
Return Show(lookAndFeel, owner, text, DefaultCaption, DefaultButtons, DefaultIcon, _
DefaultDefButton)
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, text As String, caption As String) As DialogResult
Return Show(lookAndFeel, CType(Nothing, IWin32Window), text, caption, DefaultButtons, DefaultIcon, _
DefaultDefButton)
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, owner As IWin32Window, text As String, caption As String) As DialogResult
Return Show(lookAndFeel, owner, text, caption, DefaultButtons, DefaultIcon, _
DefaultDefButton)
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, text As String, caption As String, buttons As MessageBoxButtons) As DialogResult
Return Show(lookAndFeel, CType(Nothing, IWin32Window), text, caption, buttons, DefaultIcon, _
DefaultDefButton)
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, owner As IWin32Window, text As String, caption As String, buttons As MessageBoxButtons) As DialogResult
Return Show(lookAndFeel, owner, text, caption, buttons, DefaultIcon, _
DefaultDefButton)
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, text As String, caption As String, buttons As MessageBoxButtons, icon As MessageBoxIcon) As DialogResult
Return Show(lookAndFeel, CType(Nothing, IWin32Window), text, caption, buttons, icon, _
DefaultDefButton)
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, owner As IWin32Window, text As String, caption As String, buttons As MessageBoxButtons, icon As MessageBoxIcon) As DialogResult
Return Show(lookAndFeel, owner, text, caption, buttons, icon, _
DefaultDefButton)
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, text As String, caption As String, buttons As MessageBoxButtons, icon As MessageBoxIcon, defaultButton As MessageBoxDefaultButton) As DialogResult
Return Show(lookAndFeel, CType(Nothing, IWin32Window), text, caption, buttons, icon, _
defaultButton)
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, owner As IWin32Window, text As String, caption As String, buttons As MessageBoxButtons, icon As MessageBoxIcon, _
defaultButton As MessageBoxDefaultButton) As DialogResult
Return Show(lookAndFeel, owner, text, caption, MessageBoxButtonsToDialogResults(buttons), MessageBoxIconToIcon(icon), _
MessageBoxDefaultButtonToInt(defaultButton), icon)
End Function
Private Shared Function MessageBoxButtonsToDialogResults(buttons As MessageBoxButtons) As DialogResult()
If Not [Enum].IsDefined(GetType(MessageBoxButtons), buttons) Then
Throw New InvalidEnumArgumentException("buttons", CInt(buttons), GetType(DialogResult))
End If
Select Case buttons
Case MessageBoxButtons.OK
Return New DialogResult() {DialogResult.OK}
Case MessageBoxButtons.OKCancel
Return New DialogResult() {DialogResult.OK, DialogResult.Cancel}
Case MessageBoxButtons.AbortRetryIgnore
Return New DialogResult() {DialogResult.Abort, DialogResult.Retry, DialogResult.Ignore}
Case MessageBoxButtons.RetryCancel
Return New DialogResult() {DialogResult.Retry, DialogResult.Cancel}
Case MessageBoxButtons.YesNo
Return New DialogResult() {DialogResult.Yes, DialogResult.No}
Case MessageBoxButtons.YesNoCancel
Return New DialogResult() {DialogResult.Yes, DialogResult.No, DialogResult.Cancel}
Case Else
Throw New ArgumentException("buttons")
End Select
End Function
Private Shared Function MessageBoxIconToIcon(icon As MessageBoxIcon) As Icon
If Not [Enum].IsDefined(GetType(MessageBoxIcon), icon) Then
Throw New InvalidEnumArgumentException("icon", CInt(icon), GetType(DialogResult))
End If
Select Case icon
Case MessageBoxIcon.None
Return Nothing
Case MessageBoxIcon.[Error]
Return SystemIcons.[Error]
Case MessageBoxIcon.Exclamation
Return SystemIcons.Exclamation
Case MessageBoxIcon.Information
Return SystemIcons.Information
Case MessageBoxIcon.Question
Return SystemIcons.Question
Case Else
Throw New ArgumentException("icon")
End Select
End Function
Private Shared Function MessageBoxDefaultButtonToInt(defButton As MessageBoxDefaultButton) As Integer
If Not [Enum].IsDefined(GetType(MessageBoxDefaultButton), defButton) Then
Throw New InvalidEnumArgumentException("defaultButton", CInt(defButton), GetType(DialogResult))
End If
Select Case defButton
Case MessageBoxDefaultButton.Button1
Return 0
Case MessageBoxDefaultButton.Button2
Return 1
Case MessageBoxDefaultButton.Button3
Return 2
Case Else
Throw New ArgumentException("defaultButton")
End Select
End Function
Public Shared Function Show(lookAndFeel As UserLookAndFeel, owner As IWin32Window, text As String, caption As String, buttons As DialogResult(), icon As Icon, _
defaultButton As Integer, messageBeepSound As MessageBoxIcon) As DialogResult
Dim form As New XtraMessageBoxForm()
'Dim defaultFont As Font = AppearanceObject.DefaultFont
'AppearanceObject.DefaultFont = New Font("Khalid Art bold", 12, FontStyle.Bold)
form.Appearance.Font = MessageFont
form.AssignButtonsFont = True
Return form.ShowMessageBoxDialog(New XtraMessageBoxArgs(lookAndFeel, owner, text, caption, buttons, icon, _
defaultButton))
End Function
Public Shared Function Show(owner As IWin32Window, text As String, caption As String, buttons As DialogResult(), icon As Icon, defaultButton As Integer, _
messageBeepSound As MessageBoxIcon) As DialogResult
Return Show(Nothing, owner, text, caption, buttons, icon, _
defaultButton, messageBeepSound)
End Function
Shared _AllowCustomLookAndFeel As Boolean = False
Public Shared Property AllowCustomLookAndFeel() As Boolean
Get
Return _AllowCustomLookAndFeel
End Get
Set(value As Boolean)
_AllowCustomLookAndFeel = value
End Set
End Property
Private Shared _MessageFont As Font = New Font("Khalid Art bold", 12) ' AppearanceObject.DefaultFont
Public Shared Property MessageFont() As Font
Get
Return _MessageFont
End Get
Set(value As Font)
_MessageFont = value
End Set
End Property
End Class
تقوم بانشاء هذه الفئة تم تستدعيها كما بالشكل التالي:
كود :
MyXtraMessageBox.Show("غير مسموح لك القيام بهذه العملية راجع المسؤول عن المنظومة", "صلاحيات", MessageBoxButtons.OK)
لاحظ في الفئة السابقة اغير نوعية الخط من خلال السطر التالي:
كود :
'AppearanceObject.DefaultFont = New Font("Khalid Art bold", 12, FontStyle.Bold)
ايضا لدينا الاداة XtraGrid الخاصة بنفس الشركة يمكن تعريف ما فيها من اوامر ونصوص بهذه الفئة
كود :
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraGrid.Localization
Public NotInheritable Class MyLocalizer
Inherits Localizer
Public Overrides Function GetLocalizedString(ByVal id As StringId) As String
Select Case (id)
Case StringId.XtraMessageBoxYesButtonText
Return "نعم"
Case StringId.XtraMessageBoxOkButtonText
Return "موافق"
Case StringId.XtraMessageBoxNoButtonText
Return "لا"
Case StringId.XtraMessageBoxCancelButtonText
Return "الغاء"
Case Else
Return MyBase.GetLocalizedString(id)
End Select
'End the switch() statement
End Function
End Class
Public Class GermanGridLocalizer
Inherits GridLocalizer
Public Overrides ReadOnly Property Language() As String
Get
Return "Deutsch"
End Get
End Property
Public Overrides Function GetLocalizedString(id As GridStringId) As String
Dim ret As String = ""
Select Case id
' ...
Case GridStringId.GridGroupPanelText
Return "Ziehen Sie eine Spaltenüberschrift in diesen Bereich, um nach dieser zu gruppieren"
Case GridStringId.MenuColumnClearSorting
Return "Sortierung entfernen"
Case GridStringId.MenuGroupPanelHide
Return "Gruppierungsfeld ausblenden"
Case GridStringId.MenuColumnRemoveColumn
Return "Spalte entfernen"
Case GridStringId.MenuColumnFilterEditor
Return "Filter &bearbeiten"
Case GridStringId.MenuColumnFindFilterShow
Return "Suche einblenden"
Case GridStringId.MenuColumnAutoFilterRowShow
Return "Zeige Auto Filterzeile"
Case GridStringId.MenuColumnSortAscending
Return "Aufsteigend sortieren"
Case GridStringId.MenuColumnSortDescending
Return "Absteigend sortieren"
Case GridStringId.MenuColumnGroup
Return "Gruppieren fur dieses Feld"
Case GridStringId.MenuColumnUnGroup
Return "Gruppierung aufheben"
Case GridStringId.MenuColumnColumnCustomization
Return "Laufzeit benutzerdefinierte Spalte"
Case GridStringId.MenuColumnBestFit
Return "Optimale Breite"
Case GridStringId.MenuColumnFilter
Return "Kann gruppieren"
Case GridStringId.MenuColumnClearFilter
Return "Filter aufheben"
Case GridStringId.MenuColumnBestFitAllColumns
Return "Optimale Breite (alle Spalten)"
Case Else
' ...
ret = MyBase.GetLocalizedString(id)
Exit Select
End Select
Return ret
End Function
End Class
كل ما تحتاجه هو استبدال الجملة باللغة العربية فقط في الاسفل مثلا انا غيرتها من الانجليزية الى الفرنسية
تحتاج الى استيراد مجال الاسماء التالي:
كود :
Imports DevExpress.XtraGrid.Localization
ثم في حدث التحميل تضع السطر التالي:
كود :
Localizer.Active = New MyLocalizer()
وسوف تتغير اسماء الاوامر من لصق وترتيب وفلترة وبحث وكل شئ الى اللغة التي كتبتها