السلام عليكم
هذا الموضوع استكمال لدورة الاكواد الشاملة
'39-جعل خلفية فورم بطريقة متدرجة
كود PHP:
Public Class Form1
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim grbrush As System.Drawing. _
Drawing2D.LinearGradientBrush
grbrush = New System.Drawing.Drawing2D. _
LinearGradientBrush(New Point(0, 0), _
New Point(Me.Width, Me.Height), _
Color.Gold, Color.Blue)
Me.CreateGraphics.FillRectangle _
(grbrush, New Rectangle(0, 0, Me.Width, Me.Height))
End Sub
End Class
'39-جعل خلفية فورم بطريقة متدرجة
'40-وضع لون متدرج بطريقة اخرى
كود PHP:
Public Class Form1
Private Sub DrawGradient(ByVal color1 As _
Color, ByVal color2 As Color, ByVal mode As _
System.Drawing.Drawing2D.LinearGradientMode)
Dim a As New Drawing2D.LinearGradientBrush _
(New RectangleF(0, 0, Me.Width, Me.Height), _
color1, color2, mode)
Dim g As Graphics = Me.CreateGraphics
g.FillRectangle(a, New RectangleF _
(0, 0, Me.Width, Me.Height))
g.Dispose()
End Sub
Protected Overrides Sub OnPaint _
(ByVal pe As PaintEventArgs)
DrawGradient(Color.Aqua, Color.Blue, _
Drawing.Drawing2D.LinearGradientMode.Vertical)
End Sub
End Class
'40-وضع لون متدرج بطريقة اخرى
'41-طريقة اخرى لوضع لون متدرج لخلفية الفورم
كود PHP:
Imports System.Drawing.Drawing2D
Public Class Form1
Protected Overrides Sub OnPaint _
(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
Dim g As Graphics = e.Graphics
g.SmoothingMode = SmoothingMode.HighQuality
Dim gPath As GraphicsPath = New GraphicsPath
Dim r As Rectangle = New Rectangle _
(0, 0, Me.Width, Me.Height)
gPath.AddRectangle(r)
Dim lb As LinearGradientBrush = _
New LinearGradientBrush _
(r, Color.White, Color.Blue, _
LinearGradientMode.Vertical)
g.FillPath(lb, gPath)
End Sub
End Class
'41-طريقة اخرى لوضع لون متدرج لخلفية الفورم
'42-عمل تدرج لوني بطريقة مبسطة
كود PHP:
Imports System.Drawing.Drawing2D
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim rect As New Rectangle(0, 0, Me.Width, Me.Height)
Dim gc As Graphics = Me.CreateGraphics
Dim gradientBrush As New LinearGradientBrush(rect, _
Color.Blue, Color.Black, LinearGradientMode.Horizontal)
gc.FillRectangle(gradientBrush, rect)
End Sub
End Class
'42-عمل تدرج لوني بطريقة مبسطة