27-04-16, 02:21 PM
يوجد خطأ
تأكد رحم الله والديك
تأكد رحم الله والديك
كود :
Imports System.Windows.Forms.Form
Public Class ControlFormStyle
#Region "قلب الادوات من اليمين الى اليسار"
Public Shared Sub changeFormLayoutRTL(ByVal setRTL_Par As Boolean, ByVal frm_par As Form)
If frm_par.RightToLeftLayout = True And setRTL_Par = True Then Exit Sub
If frm_par.RightToLeftLayout = False And setRTL_Par = False Then Exit Sub
frm_par.Visible = False
frm_par.RightToLeft = IIf(setRTL_Par = True, Windows.Forms.RightToLeft.Yes, Windows.Forms.RightToLeft.No)
frm_par.RightToLeftLayout = setRTL_Par
ApplyRTL(setRTL_Par, frm_par)
frm_par.Visible = True
End Sub
Private Shared Sub ApplyRTL(ByVal yes As Boolean, ByVal startControl As Control)
If (TypeOf startControl Is Panel) OrElse (TypeOf startControl Is GroupBox) Then
For Each control As Control In startControl.Controls
control.Location = CalculateRTL(control.Location, startControl.Size, control.Size)
Next
End If
If (TypeOf startControl Is PictureBox) Then
Dim targetPictureBox As PictureBox = CType(startControl, PictureBox)
If Not targetPictureBox.Image Is Nothing Then targetPictureBox.Image.RotateFlip(RotateFlipType.Rotate180FlipY)
End If
For Each control As Control In startControl.Controls
ApplyRTL(yes, control)
Next
End Sub
Private Shared Function CalculateRTL(ByVal currentPoint As Point, ByVal parentSize As Size, ByVal currentSize As Size) As Point
Return New Point(parentSize.Width - currentSize.Width - currentPoint.X, currentPoint.Y)
End Function
#End Region
End Class
