Showing posts with label GDK. Show all posts

RTS Game VB.net

Hello Friends ! Today i will teach you :
                 How To make Real Time Strategy Game 
Read more

Here is A Gradient Panel Control

Add New Class  & Add The Following Code

Inherits Panel
    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim control As Color = SystemColors.Control
        Dim window As Color = SystemColors.Window
   
        Dim formGraphics As Graphics = e.Graphics
   
        Dim gradientBrush As New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(Width, 0), clr1, clr2)
        formGraphics.FillRectangle(gradientBrush, ClientRectangle)
        '     Dim p As New Drawing2D.GraphicsPath
        '    p.StartFigure()
        '   p.AddArc(New Rectangle(0, 0, 40, 40), 180, 90)
        '  p.AddLine(40, 0, Me.Width - 40, 0)
        ' p.AddArc(New Rectangle(Me.Width - 40, 0, 40, 40), -90, 90)
        '  p.AddLine(Me.Width, 40, Me.Width, Me.Height - 40)
        ' p.AddArc(New Rectangle(Me.Width - 40, Me.Height - 40, 40, 40), 0, 90)
        'p.AddLine(Me.Width - 40, Me.Height, 40, Me.Height)
        'p.AddArc(New Rectangle(0, Me.Height - 40, 40, 40), 90, 90)
        ' p.CloseFigure()
     
    End Sub

    Dim clr1 As Color = Color.White
    Dim clr2 As Color = Color.White
    Property color1() As Color
        Get
            color1 = clr1
        End Get
        Set(ByVal value As Color)
            clr1 = value
        End Set
    End Property
    Property Color2() As Color
        Get
            Color2 = clr2
        End Get
        Set(ByVal value As Color)
            clr2 = value
        End Set
    End Property
Read more

FIND AND REPLACE IN TEXTBOX

TO DO SO YOU WILL NEED TO CREATE NEW  RICHTEXTBOX CONTROL

Follow The Steps :
Right Click on your Project ; GO TO Add> And Select CLASS


Now Insert The following Code

  Inherits RichTextBox
 
 
    Public Sub Replace(ByVal FindText As String, ByVal ReplaceText As String)
        Me.Find(FindText)
        If Not Me.SelectionLength = 0 Then
            Me.SelectedText = ReplaceText
        Else
            ' MsgBox("The following specified text was not found: " & FindText)
        End If
    End Sub
 
 
    Public Sub Replace(ByVal FindText As String, ByVal ReplaceText As String, ByVal ReplaceAll As Boolean, _
     ByVal MatchCase As Boolean, ByVal WholeWord As Boolean)
 
        Select Case ReplaceAll
 
            Case False
                If MatchCase = True Then
                    If WholeWord = True Then
                        Me.Find(FindText, RichTextBoxFinds.MatchCase Or RichTextBoxFinds.WholeWord)
                    Else
                        Me.Find(FindText, RichTextBoxFinds.MatchCase)
                    End If
                Else
                    If WholeWord = True Then
                        Me.Find(FindText, RichTextBoxFinds.WholeWord)
                    Else
                        Me.Find(FindText)
                    End If
                End If
 
                If Not Me.SelectionLength = 0 Then
                    Me.SelectedText = ReplaceText
                Else
                    '  MsgBox("The following specified text was not found: " & FindText)
                End If
 
 
            Case True
 
 
                Dim i As Integer
                For i = 0 To Me.TextLength
 
 
                    If MatchCase = True Then
                        If WholeWord = True Then
                            Me.Find(FindText, RichTextBoxFinds.MatchCase Or RichTextBoxFinds.WholeWord)
                        Else
                            Me.Find(FindText, RichTextBoxFinds.MatchCase)
                        End If
                    Else
                        If WholeWord = True Then
                            Me.Find(FindText, RichTextBoxFinds.WholeWord)
                        Else
                            Me.Find(FindText)
                        End If
                    End If
 
 
                    If Not Me.SelectionLength = 0 Then
                        Me.SelectedText = ReplaceText
                    Else
                        ' MsgBox(i & " occurrence(s) replaced")
                        Exit For
                    End If
                Next i
 
        End Select
End Sub 

Now Go to Debug And Build


Goto your main Form And U Will See a New Controll -





  

Add The Following Code to Replace

Me.RichtextboxFr1.replace(text to be finded , text to replace with, replace all as boolean , machcase as boolean , wholeword as boolean)
Read more

Translate