أغلب الظن هو أنك تجيد اللغتين
عايز مساعدة في تحوبل الكود ليه بقي؟
عموما المشكلة الوحيدة التي قد تقابلك في تحويل الكود هي Handlers و Delegates فأسلوب كتابتهم مختلف في اللغتين
الكلاس EmoticonMenuItem
PHP كود :
Public Class EmoticonMenuItem
Inherits MenuItem
Private Const ICON_WIDTH As Integer = 19
Private Const ICON_HEIGHT As Integer = 19
Private Const ICON_MARGIN As Integer = 4
Private _backgroundColor As Color
Private _selectionColor As Color
Private _selectionBorderColor As Color
Private _image As Image
Public Sub New(img As Image)
Me.New()
Me._image = _image
End Sub
Public Sub New()
MyBase.OwnerDraw = True
Me._backgroundColor = SystemColors.ControlLightLight
Me._selectionColor = Color.FromArgb(50, 0, 0, 150)
Me._selectionBorderColor = SystemColors.Highlight
End Sub
Public Property Image() As Image
Get
Return Me._image
End Get
Set(value As Image)
Me._image = value
End Set
End Property
Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
'MyBase.OnDrawItem(e)
Dim g As Graphics = e.Graphics
Dim bounds As Rectangle = e.Bounds
Dim selected As Boolean = (e.State And DrawItemState.Selected) <> DrawItemState.None
Me.DrawBackground(g, bounds, selected)
If Me._image IsNot Nothing Then
Dim x As Integer = CInt(bounds.X + (bounds.Width - ICON_WIDTH) / 2)
Dim y As Integer = CInt(bounds.Y + (bounds.Height - ICON_HEIGHT) / 2)
g.DrawImage(Me._image, x, y)
End If
End Sub
Protected Overrides Sub OnMeasureItem(e As MeasureItemEventArgs)
'MyBase.OnMeasureItem(e)
e.ItemHeight = 17
e.ItemWidth = 23
End Sub
Private Sub DrawBackground(g As Graphics, bounds As Rectangle, selected As Boolean)
If selected Then
g.FillRectangle(New SolidBrush(Me._selectionColor), bounds)
g.DrawRectangle(New Pen(Me._selectionBorderColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1)
Else
g.FillRectangle(New SolidBrush(Me._backgroundColor), bounds)
End If
End Sub
End Class
الكلاس RtfCodes
أضف فورم عادي جدا للمشروع و اعطه الاسم RtfCodes
واكتب الكود بالشكل التالي
PHP كود :
Imports System.Text
Public Class RtfCodes
Private line As Integer
Private sb As StringBuilder
Public Sub New(owner As Form)
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
MyBase.Owner = owner
MyBase.Width = owner.Width
MyBase.Height = owner.Height / 2
MyBase.StartPosition = FormStartPosition.Manual
MyBase.Location = New Point(MyBase.Owner.Location.X, MyBase.Owner.Location.Y - MyBase.Height - SystemInformation.CaptionHeight)
End Sub
Public Sub AppendText(s As String)
Me.line += 1
Me.sb = New StringBuilder()
Me.sb.Append("<")
Me.sb.Append("Line ")
Me.sb.Append(Me.line)
Me.sb.Append(">")
Me.sb.Append(" ")
Me.sb.Append(s)
Me.TextBox1.Text += sb.ToString
End Sub
End Class
الكلاس الأخير IMWindow
مشكلتك هنا انك بتستخدم مكتبة اسمها Khendys.Controls.ExRichTextBox
غليك ان تضيف المكتبة الي ToolBox الخاصة بالفيجوال استوديو و ذلك لسهولة سحبها الي الفورم و حتي تتفادي كتابة كل شئ باستخدام الكود
ثم عليك أن تضيف بقية الكونترول الأخري و تضبط أماكنهم علي الفورم
أيضا عليك أن تضيف صور Emoctions الي Resources المشروع و تملأها كالتالي
PHP كود :
Private Sub GetEmoctions()
Me.emoticons = New Image(8) {}
Me.emoticons(0) = My.Resources.AngelSmile
Me.emoticons(1) = My.Resources.AngrySmile
Me.emoticons(2) = My.Resources.Beer
Me.emoticons(3) = My.Resources.BrokenHeart
Me.emoticons(4) = My.Resources.ConfusedSmile
Me.emoticons(5) = My.Resources.CrySmile
Me.emoticons(6) = My.Resources.DevilSmile
Me.emoticons(7) = My.Resources.EmbarassedSmile
Me.emoticons(8) = My.Resources.ThumbsUp
End Sub