تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
ممكن رسم سهم بهذا الكود
#11
صح
اريد ان يكون السهم مثل نفس شكل و الوان الياتون الدائري
الرد }}}
تم الشكر بواسطة:
#12
كود الباتون مربع
و سأضع لك كود السهم لاحقا

PHP كود :
Imports System.Drawing.Drawing2D
Imports System
.ComponentModel

Public Class LedSingleControlٌُRect
    Inherits Control

#Region "Declare variables"


 
   Private _OnColor As Color Color.Lime

    Private _OffColor 
As Color Color.DarkGray
#End Region

#Region "Contructors"

#End Region
#Region "Properties"




 
   <Category("HMI Properties")>
 
   Private _Value As Boolean True

    Public Property Value
() As Boolean
        Get
            Return _Value
        End Get

        Set
(ByVal value As Boolean)
 
           _Value value

            Me
.Invalidate()
 
       End Set
    End Property
    
<Category("HMI Properties")>
 
   Public Property OnColor() As Color
        Get
            Return _OnColor
        End Get

        Set
(ByVal value As Color)
 
           _OnColor value
            Me
.Refresh()
 
       End Set
    End Property
    
<Category("HMI Properties")>
 
   Public Property OffColor() As Color
        Get
            Return _OffColor
        End Get

        Set
(ByVal value As Color)
 
           _OffColor value
            Me
.Refresh()
 
       End Set
    End Property
#End Region
#Region "Methods & Events"

 
   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) / 2.0FCSng(Me.Height) / 2.0F)
 
       Dim num1 As Single Math.Min(pointF.XpointF.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.WhiteSmokeSystemColors.ControlDarkDark), Brush)
 
       g.FillRectangle(_BrushpointF.num2pointF.num22.0F num22.0F num2)
 
       _Brush.Dispose()
 
       If Me._Value Then
            Dim path 
As New GraphicsPath()
 
           Dim r As Rectangle = New Rectangle(pointF.num1pointF.num1num1 2.0Fnum1 2.0F)
 
           path.AddRectangle(r)
 
           Dim pathGradientBrush As New PathGradientBrush(path)
 
           pathGradientBrush.CenterColor Color.FromArgb(150CInt(Me.OnColor.R), CInt(Me.OnColor.G), CInt(Me.OnColor.B))
 
           Dim colorArray() As Color = {Color.FromArgb(1CInt(Me.OnColor.R), CInt(Me.OnColor.G), CInt(Me.OnColor.B))}
 
           pathGradientBrush.SurroundColors colorArray
            g
.FillRectangle(CType(pathGradientBrushBrush), pointF.num1pointF.num1num1 2.0Fnum1 2.0F)
 
           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.ControlDarkDarkColor.WhiteSmoke), Brush)
 
       g.FillRectangle(brush2pointF.num3pointF.num32.0F num32.0F num3)
 
       _Brush.Dispose()
 
       Dim gp As New GraphicsPath()
 
       Dim r1 As Rectangle = New Rectangle(pointF.num4pointF.num42.0F num42.0F num4)
 
       gp.AddRectangle(r1)
 
       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.num4 2.0FpointF.num4 2.0F)
 
           g.FillRectangle(CType(pathGradientBrushBrush), pointF.num4pointF.num42.0F num42.0F 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.num4 2.0FpointF.num4 2.0F)
 
           g.FillRectangle(CType(pathGradientBrushBrush), pointF.num4pointF.num42.0F num42.0F num4)
 
           pathGradientBrush.Dispose()
 
       End If
 
       gp.Dispose()
 
   End Sub

    Protected Overrides Sub OnSizeChanged
(ByVal e As EventArgs)
 
       MyBase.OnSizeChanged(e)
 
       Dim num As Single CSng(Math.Min(Me.WidthMe.Height))
 
       If CDbl(num) < 20.0 Then
            num 
20.0F
        End 
If
 
       Me.Width CInt(Math.Truncate(num))
 
       Me.Height CInt(Math.Truncate(num))
 
       Dim path As New GraphicsPath()
 
       Dim r As Rectangle = New Rectangle(00Me.WidthMe.Height)
 
       path.AddRectangle(r)
 
       Me.Region = New Region(path)
 
   End Sub

#End Region

End Class 
الرد }}}
تم الشكر بواسطة:
#13
تمام
معاك
الرد }}}
تم الشكر بواسطة:
#14
PHP كود :
Imports System.Drawing.Drawing2D
Imports System
.ComponentModel

Public Class LedSingleControlArrow
    Inherits Control

#Region "Declare variables"
 
   Private _OnColor As Color Color.Lime
    Private _OffColor 
As Color Color.DarkGray
#End Region

#Region "Contructors"

#End Region
#Region "Properties"

 
   <Category("HMI Properties")>
 
   Private _Value As Boolean True

    Public Property Value
() As Boolean
        Get
            Return _Value
        End Get

        Set
(ByVal value As Boolean)
 
           _Value value

            Me
.Invalidate()
 
       End Set
    End Property
    
<Category("HMI Properties")>
 
   Public Property OnColor() As Color
        Get
            Return _OnColor
        End Get

        Set
(ByVal value As Color)
 
           _OnColor value
            Me
.Refresh()
 
       End Set
    End Property
    
<Category("HMI Properties")>
 
   Public Property OffColor() As Color
        Get
            Return _OffColor
        End Get

        Set
(ByVal value As Color)
 
           _OffColor value
            Me
.Refresh()
 
       End Set
    End Property
#End Region

#Region "Methods & Events"

 
   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) / 2.0FCSng(Me.Height) / 2.0F)
 
       Dim num1 As Single Math.Min(pointF.XpointF.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.WhiteSmokeSystemColors.ControlDarkDark), Brush)
 
       Dim bottomLayerRect As Rectangle = New Rectangle(pointF.num2pointF.num22.0F num22.0F num2)
 
       Dim bottomlayerPath As GraphicsPath = New GraphicsPath()
 
       Me.GetArrowPath(bottomlayerPathbottomLayerRectDirections.East)
 
       g.FillPath(_BrushbottomlayerPath)
 
       _Brush.Dispose()
 
       If Me._Value Then
            Dim path 
As New GraphicsPath()
 
           Dim r As Rectangle = New Rectangle(pointF.num1pointF.num1num1 2.0Fnum1 2.0F)
 
           'Dim p2 As Drawing2D.GraphicsPath = New Drawing2D.GraphicsPath
            GetArrowPath(path, r, Directions.East)

            Dim pathGradientBrush As New PathGradientBrush(path)
            pathGradientBrush.CenterColor = Color.FromArgb(150, CInt(Me.OnColor.R), CInt(Me.OnColor.G), CInt(Me.OnColor.B))
            Dim colorArray() As Color = {Color.FromArgb(1, CInt(Me.OnColor.R), CInt(Me.OnColor.G), CInt(Me.OnColor.B))}
            pathGradientBrush.SurroundColors = colorArray

            g.FillPath(CType(pathGradientBrush, Brush), path)
            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.FillRectangle(brush2, pointF.X - num3, pointF.Y - num3, 2.0F * num3, 2.0F * num3)
        _Brush.Dispose()
        Dim gp As New GraphicsPath()
        Dim r1 As Rectangle = New Rectangle(pointF.X - num4, pointF.Y - num4, 2.0F * num4, 2.0F * num4)
        GetArrowPath(gp, r1, Directions.East)

        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 / 2.0F, pointF.Y - num4 / 2.0F)
            g.FillPath(CType(pathGradientBrush, Brush), gp)
            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 / 2.0F, pointF.Y - num4 / 2.0F)
            g.FillPath(CType(pathGradientBrush, Brush), gp)
            pathGradientBrush.Dispose()
        End If
        gp.Dispose()
    End Sub

    Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
        MyBase.OnSizeChanged(e)
        Dim num As Single = CSng(Math.Min(Me.Width, Me.Height))
        If CDbl(num) < 20.0 Then
            num = 20.0F
        End If
        Me.Width = CInt(Math.Truncate(num))
        Me.Height = CInt(Math.Truncate(num))
        Dim path As New GraphicsPath()
        Dim r As Rectangle = New Rectangle(0, 0, Me.Width, Me.Height)
        GetArrowPath(path, r, Directions.East)
        Me.Region = New Region(path)
    End Sub

    Private Sub GetArrowPath(path As Drawing2D.GraphicsPath, rect As Rectangle, direction As Directions)
        Dim rectF As RectangleF = RectangleF.Inflate(rect, -4.0F, -4.0F)
        Dim x As Single = (rectF.X + rectF.Width / 2.0F)
        Dim y As Single = (rectF.Y + rectF.Height / 2.0F)
        path.StartFigure()
        path.AddLines(New PointF() {
                      New PointF(x, rectF.Top),
                      New PointF(rectF.Right, (rectF.Y + rectF.Height * 0.7F)),
                      New PointF((rectF.X + rectF.Width * 0.7F), (rectF.Y + rectF.Height * 0.7F)),
                      New PointF((rectF.X + rectF.Width * 0.7F), rectF.Bottom),
                      New PointF((rectF.X + rectF.Width * 0.3F), rectF.Bottom),
                      New PointF((rectF.X + rectF.Width * 0.3F), (rectF.Y + rectF.Height * 0.7F)),
                      New PointF(rectF.Left, (rectF.Y + 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(x, y))
            Case Directions.South
                matrix.RotateAt(180.0F, New PointF(x, y))
            Case Directions.West
                matrix.RotateAt(270.0F, New PointF(x, y))
        End Select
        path.Transform(matrix)
    End Sub

    Public Enum Directions
        North
        East
        South
        West
    End Enum

#End Region

End Class 

انا لم أعدل في الكود الأصلي كثيرا
لكن الكود يحتاج اعادة صياغة بالكامل
خاصة انك في الحدث Resize تقوم بضبط Region حتي يكون طول الكونترول مساويا لعرض الكونترول

أيضا انت كتبت الكود لتتم عملية الرسم علي هيئة طبقات Layers
لأنك وعلي ما يبدو تريد الاختفاظ بالشكل العام للكونترول من حيث Glow و الألوان
أنصحك تدرس الكلاس Blend سوف يوفر عليك صداع كثير جدا
ايضا أنصحك ان لا تقوم بضبط Region فقط تقوم بعمل Invalidate للكونترول في حالة Resize للكونترول و هذا سيعطيك امكانية ان تتحكم انت بأبعاد الكونترول في مرحلة التصميم
الرد }}}
تم الشكر بواسطة:
#15
شكرا على المحاولة

كيف ارسم السهم فى WPF
الرد }}}
تم الشكر بواسطة:
#16
وشكرا على مساعدتكم ولا تنزعج منى

وهذة المكتبة المنشودة للافادة
[url= https://cdn.fbsbx.com/v/t59.2708-21/1819...9403A&dl=1[/url]

شكرا لكم
الرد }}}
تم الشكر بواسطة:
#17
اللينك الذي وضعته للمكتبه لا يعمل
برجاء تعديل اللينك أور فع المكتبة نفسها
الرد }}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: