منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : ممكن رسم سهم بهذا الكود
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
الصفحات : 1 2
Imports System

   Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
Dim g As Graphics = e.Graphics
Dim pointF As New PointF(CSng(Me.Width) / 2F, CSng(Me.Height) / 2F)
Dim num1 As Single = Math.Min(pointF.X, pointF.Y)
Dim num2 As Single = CSng(CDbl(num1) * 65.0 / 100.0)
Dim num3 As Single = CSng(CDbl(num1) * 55.0 / 100.0)
Dim num4 As Single = CSng(CDbl(num1) * 45.0 / 100.0)
Dim _Brush As Brush = CType(New LinearGradientBrush(New Point(CInt(Math.Truncate(CDbl(pointF.X) - CDbl(num2))), CInt(Math.Truncate(CDbl(pointF.Y) - CDbl(num2)))), New Point(CInt(Math.Truncate(CDbl(pointF.X) + CDbl(num2))), CInt(Math.Truncate(CDbl(pointF.Y) + CDbl(num2)))), Color.WhiteSmoke, SystemColors.ControlDarkDark), Brush)
g.FillEllipse(_Brush, pointF.X - num2, pointF.Y - num2, 2F * num2, 2F * num2)
_Brush.Dispose()
If Me._Value Then
Dim path As New GraphicsPath()
path.AddEllipse(pointF.X - num1, pointF.Y - num1, num1 * 2F, num1 * 2F)
Dim pathGradientBrush As New PathGradientBrush(path)
pathGradientBrush.CenterColor = Color.FromArgb(150, CInt(Math.Truncate(Me.OnColor.R)), CInt(Math.Truncate(Me.OnColor.G)), CInt(Math.Truncate(Me.OnColor.B)))
Dim colorArray() As Color = { Color.FromArgb(1, CInt(Math.Truncate(Me.OnColor.R)), CInt(Math.Truncate(Me.OnColor.G)), CInt(Math.Truncate(Me.OnColor.B))) }
pathGradientBrush.SurroundColors = colorArray
g.FillEllipse(CType(pathGradientBrush, Brush), pointF.X - num1, pointF.Y - num1, num1 * 2F, num1 * 2F)
path.Dispose()
pathGradientBrush.Dispose()
End If
Dim brush2 As Brush = CType(New LinearGradientBrush(New Point(CInt(Math.Truncate(CDbl(pointF.X) - CDbl(num3))), CInt(Math.Truncate(CDbl(pointF.Y) - CDbl(num3)))), New Point(CInt(Math.Truncate(CDbl(pointF.X) + CDbl(num3))), CInt(Math.Truncate(CDbl(pointF.Y) + CDbl(num2)))), SystemColors.ControlDarkDark, Color.WhiteSmoke), Brush)
g.FillEllipse(brush2, pointF.X - num3, pointF.Y - num3, 2F * num3, 2F * num3)
_Brush.Dispose()
Dim gp As New GraphicsPath()
gp.AddEllipse(pointF.X - num4, pointF.Y - num4, 2F * num4, 2F * num4)
If Me._Value Then
Dim pathGradientBrush As New PathGradientBrush(gp)
pathGradientBrush.CenterColor = Color.WhiteSmoke
Dim colorArray() As Color = { Me.OnColor }
pathGradientBrush.SurroundColors = colorArray
pathGradientBrush.CenterPoint = New PointF(pointF.X - num4 / 2F, pointF.Y - num4 / 2F)
g.FillEllipse(CType(pathGradientBrush, Brush), pointF.X - num4, pointF.Y - num4, 2F * num4, 2F * num4)
pathGradientBrush.Dispose()
Else
Dim pathGradientBrush As New PathGradientBrush(gp)
pathGradientBrush.CenterColor = Color.WhiteSmoke
Dim colorArray() As Color = { Me.OffColor }
pathGradientBrush.SurroundColors = colorArray
pathGradientBrush.CenterPoint = New PointF(pointF.X - num4 / 2F, pointF.Y - num4 / 2F)
g.FillEllipse(CType(pathGradientBrush, Brush), pointF.X - num4, pointF.Y - num4, 2F * num4, 2F * num4)
pathGradientBrush.Dispose()
End If
gp.Dispose()
   End Sub

كما فى هذا الفيديو




هذا الكود رسم lad كيف احولة لرسم السهم كما فى الفيديو 

شكرااا
رسم السهم لا يحتاج كل هذا الكود
بس حدد لي شكل السهم علي الصورة اعلاه بمربع لونه أحمر
لأن اللي انا فاهمه من الصورة انك تريد رسم شئ مثل سهم تشغيل الفيديو
ياريت توضحي لي أكتر
(23-04-17, 08:28 PM)abdalamask كتب : [ -> ]Imports System

   Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
Dim g As Graphics = e.Graphics
Dim pointF As New PointF(CSng(Me.Width) / 2F, CSng(Me.Height) / 2F)
Dim num1 As Single = Math.Min(pointF.X, pointF.Y)
Dim num2 As Single = CSng(CDbl(num1) * 65.0 / 100.0)
Dim num3 As Single = CSng(CDbl(num1) * 55.0 / 100.0)
Dim num4 As Single = CSng(CDbl(num1) * 45.0 / 100.0)
Dim _Brush As Brush = CType(New LinearGradientBrush(New Point(CInt(Math.Truncate(CDbl(pointF.X) - CDbl(num2))), CInt(Math.Truncate(CDbl(pointF.Y) - CDbl(num2)))), New Point(CInt(Math.Truncate(CDbl(pointF.X) + CDbl(num2))), CInt(Math.Truncate(CDbl(pointF.Y) + CDbl(num2)))), Color.WhiteSmoke, SystemColors.ControlDarkDark), Brush)
g.FillEllipse(_Brush, pointF.X - num2, pointF.Y - num2, 2F * num2, 2F * num2)
_Brush.Dispose()
If Me._Value Then
Dim path As New GraphicsPath()
path.AddEllipse(pointF.X - num1, pointF.Y - num1, num1 * 2F, num1 * 2F)
Dim pathGradientBrush As New PathGradientBrush(path)
pathGradientBrush.CenterColor = Color.FromArgb(150, CInt(Math.Truncate(Me.OnColor.R)), CInt(Math.Truncate(Me.OnColor.G)), CInt(Math.Truncate(Me.OnColor.B)))
Dim colorArray() As Color = { Color.FromArgb(1, CInt(Math.Truncate(Me.OnColor.R)), CInt(Math.Truncate(Me.OnColor.G)), CInt(Math.Truncate(Me.OnColor.B))) }
pathGradientBrush.SurroundColors = colorArray
g.FillEllipse(CType(pathGradientBrush, Brush), pointF.X - num1, pointF.Y - num1, num1 * 2F, num1 * 2F)
path.Dispose()
pathGradientBrush.Dispose()
End If
Dim brush2 As Brush = CType(New LinearGradientBrush(New Point(CInt(Math.Truncate(CDbl(pointF.X) - CDbl(num3))), CInt(Math.Truncate(CDbl(pointF.Y) - CDbl(num3)))), New Point(CInt(Math.Truncate(CDbl(pointF.X) + CDbl(num3))), CInt(Math.Truncate(CDbl(pointF.Y) + CDbl(num2)))), SystemColors.ControlDarkDark, Color.WhiteSmoke), Brush)
g.FillEllipse(brush2, pointF.X - num3, pointF.Y - num3, 2F * num3, 2F * num3)
_Brush.Dispose()
Dim gp As New GraphicsPath()
gp.AddEllipse(pointF.X - num4, pointF.Y - num4, 2F * num4, 2F * num4)
If Me._Value Then
Dim pathGradientBrush As New PathGradientBrush(gp)
pathGradientBrush.CenterColor = Color.WhiteSmoke
Dim colorArray() As Color = { Me.OnColor }
pathGradientBrush.SurroundColors = colorArray
pathGradientBrush.CenterPoint = New PointF(pointF.X - num4 / 2F, pointF.Y - num4 / 2F)
g.FillEllipse(CType(pathGradientBrush, Brush), pointF.X - num4, pointF.Y - num4, 2F * num4, 2F * num4)
pathGradientBrush.Dispose()
Else
Dim pathGradientBrush As New PathGradientBrush(gp)
pathGradientBrush.CenterColor = Color.WhiteSmoke
Dim colorArray() As Color = { Me.OffColor }
pathGradientBrush.SurroundColors = colorArray
pathGradientBrush.CenterPoint = New PointF(pointF.X - num4 / 2F, pointF.Y - num4 / 2F)
g.FillEllipse(CType(pathGradientBrush, Brush), pointF.X - num4, pointF.Y - num4, 2F * num4, 2F * num4)
pathGradientBrush.Dispose()
End If
gp.Dispose()
   End Sub

كما فى هذا الفيديو




هذا الكود رسم lad كيف احولة لرسم السهم كما فى الفيديو 

شكرااا
لقد ارفقت صورة محدد فيها السهم المحددشكرا على الاهتمام
جرب هذا الكود
PHP كود :
Private Sub Form1_Paint(sender As ObjectAs PaintEventArgsHandles Me.Paint

    Dim p 
As New Pen(Brushes.Green20With {.EndCap Drawing2D.LineCap.ArrowAnchor}
    
e.Graphics.DrawLine(p, New Point(50100), New Point(250100))

End Sub 
شكرا ولكن اريدة بالشكل فى الصور

الكود الاعلى فى اول الموضوع هو للدوائر فى الصورة ولكن كيف احول الكود لرسم سهم مع امكنية تكبير اوتصغير

فيديو ل lad 






نفذ الكود هذا في مشروع منفصل حتي تتضح لك الفكرة

وعندما توضح لي مكان رسم السهم بالظبط
سوف أوضح لك كيف تدمج الكود الخاص بي مع الكود الخاص بك
إن أردت ان تتخلص من ذيل السهم عليك ان تجعل القيمة 0.3F = 0.7F او العكس

PHP كود :
Public Class Form1

    Private Sub GetArrowPath
(path As Drawing2D.GraphicsPathrect As Rectangledirection As Directions)
 
       Dim rectF As RectangleF RectangleF.Inflate(rect, -4.0F, -4.0F)
 
       Dim x As Single = (rectF.rectF.Width 2.0F)
 
       Dim y As Single = (rectF.rectF.Height 2.0F)
 
       path.StartFigure()
 
       path.AddLines(New PointF() {
 
                     New PointF(xrectF.Top),
 
                     New PointF(rectF.Right, (rectF.rectF.Height 0.7F)),
 
                     New PointF((rectF.rectF.Width 0.7F), (rectF.rectF.Height 0.7F)),
 
                     New PointF((rectF.rectF.Width 0.7F), rectF.Bottom),
 
                     New PointF((rectF.rectF.Width 0.3F), rectF.Bottom),
 
                     New PointF((rectF.rectF.Width 0.3F), (rectF.rectF.Height 0.7F)),
 
                     New PointF(rectF.Left, (rectF.rectF.Height 0.7F))})
 
       path.CloseAllFigures()
 
       Dim matrix As Drawing2D.Matrix = New Drawing2D.Matrix()
 
       Select Case direction
            Case Directions
.East
                matrix
.RotateAt(90.0F, New PointF(xy))
 
           Case Directions.South
                matrix
.RotateAt(180.0F, New PointF(xy))
 
           Case Directions.West
                matrix
.RotateAt(270.0F, New PointF(xy))
 
       End Select
        path
.Transform(matrix)
 
   End Sub

    Protected Overrides Sub OnPaint
(As PaintEventArgs)
 
       MyBase.OnPaint(e)
 
       e.Graphics.SmoothingMode =Drawing2D.SmoothingMode.AntiAlias
        Dim r 
As Rectangle = New Rectangle(1010100100)
 
       Dim p As Drawing2D.GraphicsPath = New Drawing2D.GraphicsPath
        GetArrowPath
(prDirections.East)

 
       Using sb As New SolidBrush(Color.Black)
 
           e.Graphics.FillPath(sbp)
 
       End Using
    End Sub

    Public Enum Directions
        North
        East
        South
        West
    End Enum
End 
Class 
[attachment=14012]شكرا 
ولكن انا حددت شكل السهم المطلوب  
فى هذة الصورة 
عندما تشاهد الفيديو الاول الاعلى تجد ان السهم هو  اداة كنترول 

يتحكم فيها ممكن ان تكون دائرة  

او سهم  

او مستطيل 

قد اضفت مشروع فية الكود  الدائرة ممكن مشاهدتة اريدة ان احولة الى سهم 
كلة فى الفيديو
لقد شاهدت الفيديو و مازلت لم أفهم طلبك
لكني أخمن ان مشكلتك ليست في عملية الرسم نفسها
وانك تريد أن يكون لديك ميزة ان يكون للكونترول أكثر من شكل
وهذه الاشكال هي المستطيل و ادائرة و السهم
وان كان تخميني صحيحا
فهنا انت تحتاج ان تضيف Enumeration يعبر عن الاشكال التي تريدها بحيث حين يختار المستخدم الشكل الذي يريده يتم عمل Invalidate و يأخذ الكونترول الشكل الذي تم اختياره بواسطة المستخدم
فقط في الحدث Paint تستخدم Select Case و ترسم كل شكل علي حدة
لا انا اريد رسم سهم بهاذا الشكل كما فى الفيديو
الكود الذي كتبته لك يرسم سهم مماثل
هو فقط يحتاج تعديل بسيط بحيث أن عملية الرسم تتم بأن يكون للسهم نفس شكل و الوان الياتون الدائري
هل هذا ما تريده
الصفحات : 1 2