تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
ممكن رسم سهم بهذا الكود
#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 
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
ممكن رسم سهم بهذا الكود - بواسطة abdalamask - 23-04-17, 08:28 PM
RE: ممكن رسم سهم بهذا الكود - بواسطة silverlight - 25-04-17, 01:56 AM


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


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم