المشاركات : 25
المواضيع 0
الإنتساب : Sep 2013
السمعة :
0
الشكر: 2
تم شكره 0 مرات في 0 مشاركات
الرجاء مساعدتى فى تصميم button و texbox
والادوات الاخرى على الفيجوال بيسك 2010
ولكنى لا اريد برامج لتصميم هذه الادوات انا احتاج فقط
طريقه لتصميمها على الفيجوال بيسك 2010
:confused::eek:الرجاء المساعده:eek::confused:
المشاركات : 100
المواضيع 1
الإنتساب : Sep 2013
السمعة :
1
الشكر: 6
تم شكره 6 مرات في 5 مشاركات
المشاركات : 25
المواضيع 0
الإنتساب : Sep 2013
السمعة :
0
الشكر: 2
تم شكره 0 مرات في 0 مشاركات
المشاركات : 664
المواضيع 32
الإنتساب : Oct 2013
السمعة :
81
الشكر: 776
تم شكره 992 مرات في 298 مشاركات
السلام عليكم ورحمة الله وبركاته
هناك ثلاث اساليب لتطوير ادواتك الخاصة واسهلها هو وراثة الاداة
شاهد هذا الموضوع
http://vb4arb.com/vb/showthread.php?6088...1%D8%D1%DE
وبالنسبة لــ GDI+ فمن الصعب عليك تطوير مثلها لانها تحتاج الى رسم الاداة بالكاااامل مع خصائصها ودوالها
المشاركات : 25
المواضيع 0
الإنتساب : Sep 2013
السمعة :
0
الشكر: 2
تم شكره 0 مرات في 0 مشاركات
انا اتحدا الصعب هل يمكنك ان تشرح لى كيفيه تصميم {progress bar} و {button}
المشاركات : 664
المواضيع 32
الإنتساب : Oct 2013
السمعة :
81
الشكر: 776
تم شكره 992 مرات في 298 مشاركات
اخي حتى انا ليس لدي الخبره في هذا المجال لان تصميمه يأخذ منك وقت تصميم برنامج كامل والسبب لازم تكتب جميع الخصائص والطرق وانته المسئول عن الاخطاء فيه لكن استطيع مساعدتك في تصميم الادوات حسب وراثة الاداة
المشاركات : 100
المواضيع 1
الإنتساب : Sep 2013
السمعة :
1
الشكر: 6
تم شكره 6 مرات في 5 مشاركات
شوف اخى ال gdi تقدر تقول عليه ان هو الرسم فهو طريقتك للرسم و هو اختصار لكلمة Graphic Device Interface.
فى الحدث paint فى اى اداة تجد e As PaintEventArgs فى هذا ال event args تجد خاصية Graphics التى تمكنك من الرسم على الاداة.
لا اعرف كيف اتسخدم خاصية Graphics ؟
لا يهمك يمكن ان تتعلمه انظر مثلا فى الكود التالى
PHP كود :
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint e.Graphics.FillRectangle(New LinearGradientBrush(New Rectangle(10, 10, 250, 80), Color.Orange, Color.OrangeRed, LinearGradientMode.Vertical), New Rectangle(10, 10, 250, 80)) End Sub
الطريقة FillRectangle تستخدم لرسم مربع او مستطيل على حسب Width و Height الى فى ال Rectangle
طيب يبدو ان هذا لن يفيدك فيما تريد عمل لذا هذا كود ل ProgressBar و Button
ولكن ارجو منك انا ان تضع فى عين الأعتبار ان هذا الكود بغرض التعليم لذا ادرس هذا الكود جيدا واذا لم تفهم اى شئ انا موجود
كود ProgressBar
PHP كود :
Imports System.Windows.Forms Imports System.Drawing Imports System.ComponentModel Imports System.Drawing.Drawing2D
Public Class MetroProgressBar Inherits Control
#Region "Private variables etc" Private _Color As Color = System.Drawing.Color.Lime Private _borderColor As Color = Color.FromArgb(178, 178, 178)
Private _Maximum As Integer = 100 Private _Minimum As Integer = 0 Private _Value As Integer = 0
Private _ProgressPercentVisable As Boolean = True #End Region
#Region "Constructor"
Public Sub New() Me.Size = New System.Drawing.Size(400, 23) Me.SetStyle(ControlStyles.DoubleBuffer, True) Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True) Me.SetStyle(ControlStyles.ResizeRedraw, True) Me.SetStyle(ControlStyles.UserPaint, True) Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True) Me.BackColor = Color.Transparent Me.ResumeLayout(False) Me.Invalidate() Me.SuspendLayout() End Sub
#End Region
#Region "Properties"
<Category("Progress Bar")> _ Public Property ProgressPercentVisable As Boolean Get Return _ProgressPercentVisable End Get Set(ByVal value As Boolean) _ProgressPercentVisable = value End Set End Property
Private ReadOnly Property ProgWidth() As Integer Get Return ((Me.Value / Me.Maximum) - (Me.Minimum / Me.Maximum)) * (Me.Width - 1) End Get End Property
<Category("Progress Bar")> _ Public Property Color As Color Get Return _Color End Get Set(ByVal value As Color) _Color = value Invalidate() End Set End Property
<Category("Progress Bar")> _ <System.ComponentModel.DefaultValue(0)> _ Public Property Value() As Integer Get Return _Value End Get Set(ByVal value As Integer) If value > Maximum Then Throw New Exception("Value must be between maximum and minimum values") Exit Property ElseIf value < Minimum Then Throw New Exception("Value must be between maximum and minimum values") Exit Property End If If _Value <> value Then _Value = value Me.Invalidate() End If End Set End Property
<Category("Progress Bar")> _ <Localizable(False), _ Bindable(False), _ Browsable(True), _ DefaultValue(CDbl(100)), _ Description("The maximum value")> _ Public Property Maximum As Integer Get Return (_Maximum) End Get Set(ByVal value As Integer) _Maximum = value Me.Invalidate() End Set End Property
<Category("Progress Bar")> _ <Localizable(False), _ Bindable(False), _ Browsable(True), _ DefaultValue(CDbl(0)), _ Description("The minimum value.")> _ Public Property Minimum As Integer Get Return _Minimum End Get Set(ByVal value As Integer) _Minimum = value Me.Invalidate() End Set End Property #End Region
#Region "Overridden Methods"
Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaintBackground(e) Dim Rect As Rectangle = New Rectangle(0, 0, Me.Width, Me.Height) e.Graphics.FillRectangle(Brushes.Gray, Rect) End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) Dim w As Double Dim Rect As Rectangle Dim PosEnd As Double Dim PosStart As Double
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
PosEnd = CInt(((CDbl(Me.Width) - 2) * (0 - Minimum)) / (Maximum - Minimum)) PosEnd = Me.Width
PosStart = CInt(((CDbl(Me.Width) - 2) * (0 - Minimum)) / (Maximum - Minimum))
w = ((PosEnd - PosStart - 1) / Maximum) * Value
If CInt(w) > 0 Then Rect = New Rectangle(PosStart, 0, CInt(w), Me.Height) End If
e.Graphics.FillRectangle(New SolidBrush(_Color), Rect)
'Draw string If _ProgressPercentVisable Then Dim S As String = Value.ToString & "%" Dim size As SizeF = e.Graphics.MeasureString(S, Me.Font) e.Graphics.DrawString(S, Me.Font, New SolidBrush(Me.ForeColor), (Me.ClientSize.Width - size.Width) / 2, (Me.ClientSize.Height - size.Height) / 2) End If End Sub
#End Region
Protected Overrides Sub OnGotFocus(e As EventArgs) MyBase.OnGotFocus(e) Me.FindForm.ActiveControl = Me End Sub End Class
كود ButtonEx
PHP كود :
Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.ComponentModel Imports System.Windows.Forms
<DefaultEvent("Click")> _ Public Class ButtonEX Shadows Event Click(sender As Object, e As EventArgs)
Public Sub New() ' This call is required by the designer. InitializeComponent()
Me.Name = "ButtonEX" Me.Label1.TextAlign = ContentAlignment.MiddleCenter _ImageAlign = ContentAlignment.MiddleLeft _ImageSize = New Size(30, 30) _TextAlign = ContentAlignment.MiddleCenter Label1.Text = Me.Text Me.Font = New Font(Me.Font.Name, 10, FontStyle.Regular) Label1.Font = Me.Font Label1.ForeColor = Me.ForeColor Me.DrawMode = Mode.MouseMode Me.CornerRadius = 2 End Sub
#Region " Private variables etc "
Private _borderColor As Color = Color.Gray Private _backRemain1 As Color = Color.Gainsboro Private _backRemain2 As Color = Color.White Private _backRemain3 As Color = Color.FromArgb(219, 219, 219) Private _backRemain4 As Color = Color.FromArgb(243, 243, 243) Private _Hover As Boolean Private _CurrentButton As String Private _Click As Boolean Private ToolTip As New ToolTip Private _ToolTipText As String Private _Text As String Private _TextAlign As ContentAlignment = ContentAlignment.MiddleCenter Private _Image As Image Private _ImageSize As Size Private _ImageAlign As ContentAlignment Private _DrawMode As Mode Private _CornerRadius As Integer
#End Region
#Region " Properties "
<Browsable(False)> _ <EditorBrowsable(EditorBrowsableState.Never)> _ Public Overloads Property BackgroundImage As Image Get Return Nothing End Get Set(ByVal value As Image) End Set End Property
<Browsable(False)> _ <EditorBrowsable(EditorBrowsableState.Never)> _ Public Overloads Property BackgroundImageLayout As ImageLayout Get Return Nothing End Get Set(ByVal value As ImageLayout) End Set End Property
<Category("Appearance")> _ Public Property CornerRadius As Integer Get Return _CornerRadius End Get Set(ByVal value As Integer) _CornerRadius = value End Set End Property
<Category("Appearance")> _ Public Property DrawMode As Mode Get Return _DrawMode End Get Set(ByVal value As Mode) _DrawMode = value Invalidate() End Set End Property
<EditorBrowsable(EditorBrowsableState.Always)> _ <Browsable(True)> _ <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _ <DefaultValue("ButtonEx")> _ Public Overrides Property Text As String Get Return _Text End Get Set(ByVal value As String) _Text = value Label1.Text = _Text Invalidate() End Set End Property
<Category("Appearance")> _ Public Property ToolTipText As String Get Return _ToolTipText End Get Set(ByVal value As String) _ToolTipText = value ToolTip.SetToolTip(Label1, value) End Set End Property
<Category("Appearance")> _ Public Property TextAlign As ContentAlignment Get Return _TextAlign End Get Set(ByVal value As ContentAlignment) _TextAlign = value Label1.TextAlign = value Invalidate() End Set End Property
<Category("Appearance")> _ Public Property Image As Image Get Return _Image End Get Set(ByVal value As Image) _Image = value Invalidate() End Set End Property
<Category("Appearance")> _ Public Property ImageSize As Size Get Return _ImageSize End Get Set(ByVal value As Size) _ImageSize = value Invalidate() End Set End Property
<Category("Appearance")> _ Public Property ImageAlign As ContentAlignment Get Return _ImageAlign End Get Set(ByVal value As ContentAlignment) _ImageAlign = value Invalidate() End Set End Property
#End Region
#Region " Paint "
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) Dim rectUpper As Rectangle = New Rectangle(0, 0, Me.Width, Me.Height) Dim pathUpper As GraphicsPath = GetRoundPath(rectUpper, CornerRadius) If _Hover = True Then Using brushUpper As Brush = New LinearGradientBrush(rectUpper, _backRemain2, _backRemain1, LinearGradientMode.Vertical) e.Graphics.FillPath(brushUpper, pathUpper) End Using 'Draw border Dim rectFull As New Rectangle(0, 0, Me.Width - 1, Me.Height - 1) Dim pathFull As GraphicsPath = GetRoundPath(rectFull, CornerRadius) Using pen As New Pen(_borderColor) e.Graphics.DrawPath(pen, pathFull) End Using ElseIf _Click = True Then Using brushUpper As Brush = New LinearGradientBrush(rectUpper, Color.Gainsboro, Color.LightGray, LinearGradientMode.Vertical) e.Graphics.FillPath(brushUpper, pathUpper) End Using 'Draw border Dim rectFull As New Rectangle(0, 0, Me.Width - 1, Me.Height - 1) Dim pathFull As GraphicsPath = GetRoundPath(rectFull, CornerRadius) Using pen As New Pen(_borderColor) e.Graphics.DrawPath(pen, pathFull) End Using Else If DrawMode = Mode.DefaultMode Then Using brushUpper As Brush = New LinearGradientBrush(rectUpper, _backRemain4, _backRemain3, LinearGradientMode.Vertical) e.Graphics.FillPath(brushUpper, pathUpper) End Using 'Draw border Dim rectFull As New Rectangle(0, 0, Me.Width - 1, Me.Height - 1) Dim pathFull As GraphicsPath = GetRoundPath(rectFull, CornerRadius) Using pen As New Pen(_borderColor) e.Graphics.DrawPath(pen, pathFull) End Using End If End If DrawImage(e.Graphics) End Sub
Private Sub SpecialButton_FontChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.FontChanged Label1.Font = Me.Font End Sub
Private Sub SpecialButton_ForeColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ForeColorChanged Label1.ForeColor = Me.ForeColor End Sub
#End Region
#Region " Paint Methodes "
Private Function GetRoundPath(ByVal r As Rectangle, ByVal depth As Integer) As GraphicsPath Dim graphPath As New GraphicsPath graphPath.AddArc(r.X, r.Y, depth, depth, 180, 90) graphPath.AddArc(r.X + r.Width - depth, r.Y, depth, depth, 270, 90) graphPath.AddArc(r.X + r.Width - depth, r.Y + r.Height - depth, depth, depth, 0, 90) graphPath.AddArc(r.X, r.Y + r.Height - depth, depth, depth, 90, 90) graphPath.AddLine(r.X, r.Y + r.Height - depth, r.X, r.Y + depth \ 2) Return graphPath End Function
Public Sub DrawImage(ByVal gr As Graphics) If Me.Image Is Nothing Then Return Dim r As Rectangle = New Rectangle(8, 8, Me.ImageSize.Width, Me.ImageSize.Height) Select Case Me.ImageAlign Case ContentAlignment.TopCenter r = New Rectangle(Me.Width / 2 - Me.ImageSize.Width / 2, 8, Me.ImageSize.Width, Me.ImageSize.Height) Case ContentAlignment.TopRight r = New Rectangle(Me.Width - 8 - Me.ImageSize.Width, 8, Me.ImageSize.Width, Me.ImageSize.Height) Case ContentAlignment.MiddleLeft r = New Rectangle(4, Me.Height / 2 - Me.ImageSize.Height / 2, Me.ImageSize.Width, Me.ImageSize.Height) Case ContentAlignment.MiddleCenter r = New Rectangle(Me.Width / 2 - Me.ImageSize.Width / 2, Me.Height / 2 - Me.ImageSize.Height / 2, Me.ImageSize.Width, Me.ImageSize.Height) Case ContentAlignment.MiddleRight r = New Rectangle(Me.Width - 8 - Me.ImageSize.Width, Me.Height / 2 - Me.ImageSize.Height / 2, Me.ImageSize.Width, Me.ImageSize.Height) Case ContentAlignment.BottomLeft r = New Rectangle(8, Me.Height - 8 - Me.ImageSize.Height, Me.ImageSize.Width, Me.ImageSize.Height) Case ContentAlignment.BottomCenter r = New Rectangle(Me.Width / 2 - Me.ImageSize.Width / 2, Me.Height - 8 - Me.ImageSize.Height, Me.ImageSize.Width, Me.ImageSize.Height) Case ContentAlignment.BottomRight r = New Rectangle(Me.Width - 8 - Me.ImageSize.Width, Me.Height - 8 - Me.ImageSize.Height, Me.ImageSize.Width, Me.ImageSize.Height) End Select gr.DrawImage(Me.Image, r) End Sub
#End Region
#Region " Mouse Events "
Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown _Click = True _Hover = False Invalidate() End Sub
Private Sub Label1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseEnter _Hover = True Invalidate() End Sub
Private Sub Label1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseLeave _Hover = False Invalidate() End Sub
Private Sub Label1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseUp _Click = False _Hover = False Invalidate() End Sub
#End Region
Public Enum Mode MouseMode = 1 DefaultMode = 2 End Enum
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click RaiseEvent Click(Me, e) End Sub End Class
المشاركات : 901
المواضيع 34
الإنتساب : Nov 2012
السمعة :
65
الشكر: 517
تم شكره 1181 مرات في 245 مشاركات
السلام عليكم ورحمة الله وبركاته
راح أعطيك مثال يصلح لك كمبتدئ وبأبسط الأساسيات لعمل زر دون الدخول في المسائل المتقدمة
أدرسه بالتفصيل سطر سطر وبعدها بإذن الله ستنطلق من تلقاء نفسك وبالبحث عن المسائل المتقدمة
PHP كود :
Public Class myButton
'' توريث من الزر الأساسي للفجوال بيسيك Inherits Button
'' متغير لحالة ضغط الماوس على الزر Private _MouseDown As Boolean = False
'' متغير لحالة دخول الماوس على الزر Private _MouseHover As Boolean = False
'' متغير لحالة حصول الزر على التركيز Private _MouseFocused As Boolean = False
'' حدث دخول الماوس Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs) '' لازم يكون أول الإجراء ولا شيء قبله والباقي مثله MyBase.OnMouseEnter(e)
_MouseHover = True
'' تحديث رسم الزر والباقي مثله Me.Invalidate() End Sub
'' حدث خروج الماوس Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) MyBase.OnMouseLeave(e) _MouseHover = False Me.Invalidate() End Sub
'' حدث ضغظ زر الماوس Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs) MyBase.OnMouseDown(e) If e.Button = Windows.Forms.MouseButtons.Left Then _MouseDown = True Me.Invalidate() End If End Sub
'' حدث ترك ضغظ زر الماوس Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs) MyBase.OnMouseUp(e) _MouseDown = False Me.Invalidate() End Sub
'' حدث حصول الزر على التركيز Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs) MyBase.OnGotFocus(e) _MouseFocused = True Me.Invalidate() End Sub
'' حدث خسارة الزر للتركيز Protected Overrides Sub OnLostFocus(ByVal e As System.EventArgs) MyBase.OnLostFocus(e) _MouseFocused = False Me.Invalidate() End Sub
'' حدث رسم الزر Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e)
'' نأتي لمعرفة حالة ضغط الماوس ودخوله لتحديد لون الرسم If _MouseDown Then '' مسح رسم الزر واستبداله بلون e.Graphics.Clear(Color.Gray)
ElseIf _MouseHover Then e.Graphics.Clear(Color.DarkGray)
Else e.Graphics.Clear(Me.BackColor)
End If
'' رسم مستطيل أحمر داخل الزر في حالة حصوله على التركيز If _MouseFocused Then e.Graphics.DrawRectangle(Pens.Red, New Rectangle(2, 2, Me.Width - 5, Me.Height - 5)) End If
'' رسم مستطيل على جوانب الزر لتحديده e.Graphics.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
'' معرفة حجم النص Dim sz As Size = TextRenderer.MeasureText(Me.Text, Me.Font)
'' تحديد مكان رسم النص بحيث يكون في المنتصف Dim pt As New Point((Me.Width - sz.Width) / 2, (Me.Height - sz.Height) / 2)
'' رسم النص e.Graphics.DrawString(Me.Text, Me.Font, New SolidBrush(Me.ForeColor), pt)
End Sub
End Class
السلام عليكم ورحمة الله وبركاته
المشاركات : 1,379
المواضيع 77
الإنتساب : Sep 2012
السمعة :
180
الشكر: 7891
تم شكره 14093 مرات في 904 مشاركات
لا يوجد زر شكرا
الف شكرا
يعطيك العافية
(( يَا أَيَّتُهَا النَّفْسُ الْمُطْمَئِنَّةُ ارْجِعِي إِلَى رَبِّكِ رَاضِيَةً مَرْضِيَّةً فَادْخُلِي فِي عِبَادِي وَادْخُلِي جَنَّتِي ))
المشاركات : 1,817
المواضيع 141
الإنتساب : Sep 2013
السمعة :
112
الشكر: 7278
تم شكره 3459 مرات في 585 مشاركات
الله يعطيك العافية ابو رائد
ويوفقك لكل خير
|