03-01-16, 09:49 PM
(آخر تعديل لهذه المشاركة : 04-01-16, 12:17 AM {2} بواسطة الشاكي لله.)
PHP كود :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'FormScaleMinimize()
FormScaleMaximize()
End Sub
#Region "Form scale"
Private Sub FormScaleMinimize()
Me.AutoScaleMode = AutoScaleMode.Font
For i = Me.Font.Size To 4 Step -1
Me.Font = New Font(Me.Font.FontFamily, i, Me.Font.Style)
If Me.Width < Screen.PrimaryScreen.WorkingArea.Width And Me.Height < Screen.PrimaryScreen.WorkingArea.Height Then
Exit For
End If
Next
Array.ForEach(GetAllControls(Me).ToArray, Sub(ctrl As Control) ctrl.Font = Me.Font)
If Me.Right > Screen.PrimaryScreen.WorkingArea.Width Or Me.Bottom > Screen.PrimaryScreen.WorkingArea.Height Then
Me.Location = New Point(0, 0)
End If
End Sub
Private Sub FormScaleMaximize()
Me.AutoScaleMode = AutoScaleMode.Font
For i = 4 To 100
Me.Font = New Font(Me.Font.FontFamily, i, Me.Font.Style)
If Me.Width > Screen.PrimaryScreen.WorkingArea.Width Or Me.Height > Screen.PrimaryScreen.WorkingArea.Height Then
Me.Font = New Font(Me.Font.FontFamily, i - 1, Me.Font.Style)
Exit For
End If
Next
Array.ForEach(GetAllControls(Me).ToArray, Sub(ctrl As Control) ctrl.Font = Me.Font)
If Me.Right > Screen.PrimaryScreen.WorkingArea.Width Or Me.Bottom > Screen.PrimaryScreen.WorkingArea.Height Then
Me.Location = New Point(0, 0)
End If
End Sub
Private Function GetAllControls(ByVal control As Control) As IEnumerable(Of Control)
Dim controls = control.Controls.Cast(Of Control)()
Return controls.SelectMany(Function(ctrl) GetAllControls(ctrl)).Concat(controls)
End Function
#End Region
End Class
