Bonsoir,
je voudrais savoir comment orienter vertical ou Horizontal d'un rectangle dans un classe. j'arrive pas a orienter en vertical mon rectangle. pouvez-vous m'aider à orienter le rectangle en verticale.
mon code :
merci de votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 Imports System.Drawing.Drawing2D Public Class RotationRectangle Inherits Control Private _Orientation As position Property Orientation As position Get Return _Orientation End Get Set(ByVal value As position) _Orientation = value Invalidate() End Set End Property Public Sub New() SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _ ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True) Me.Size = New Size(200, 20) Me.DoubleBuffered = True End Sub Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) Dim rect As New Rectangle(0, 0, Width - 1, Height - 1) With e.Graphics .SmoothingMode = SmoothingMode.HighQuality Select Case _Orientation Case position.Horizontal e.Graphics.ResetTransform() Exit Select Case position.Vertical e.Graphics.TranslateTransform(0, rect.Height) e.Graphics.RotateTransform(-90) Exit Select End Select .DrawRectangle(New Pen(New SolidBrush(Color.Black)), rect) End With End Sub Enum position Horizontal = 0 Vertical = 1 End Enum End Class
Partager