All pastes #2072836 Raw Edit

Mine

public text v1 · immutable
#2072836 ·published 2011-05-31 16:03 UTC
rendered paste body
Public Class Form1

    Dim pierwszy As Boolean = True
    
    Dim ArrX1 As Array
    Dim ArrX2 As Array
    Dim ArrU As Array
    Dim ArrF As Array
    'Dim sss As Graphics
    Dim q As Single
    'Dim n As Integer
    Dim xRectSize As Single = 500
    Dim yRectSize As Single = 250
    Dim xPos As Single = 10
    Dim yPos As Single = 10
    Dim xModelPos As Single = 900
    Dim yModelPos As Single = 50
    Dim xModelSize As Single = 300
    Dim yModelSize As Single = 400

    Dim Font1 As New System.Drawing.Font("Arial", 22)
    Dim Font2 As New System.Drawing.Font("Arial", 16)
    Dim Font3 As New System.Drawing.Font("Arial", 12)

    Dim row0 As String() = {0, 0, 0, 0}

    Public pictureBox1 As New PictureBox()

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        pictureBox1.Dock = DockStyle.Fill
        'picturebox1.Dock = DockStyle.Fill
        'picturebox1.Dock = DockStyle.Fill
        AddHandler pictureBox1.Paint, AddressOf Me.pictureBox1_Paint
        'AddHandler picturebox1.Paint, AddressOf Me.picturebox1_Paint
        'AddHandler picturebox1.Paint, AddressOf Me.picturebox1_Paint
        Me.Controls.Add(pictureBox1)
        'Me.Controls.Add(picturebox1)
        'Me.Controls.Add(picturebox1)
        ListBox1.SetSelected(0, True)

        'DataGridView1.Rows.Add(row0)
    End Sub

    Public Sub pictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
        'MsgBox("plackiplacki")
        Dim g As Graphics = e.Graphics

        'g.FillRectangle(Brushes.White, xPos, yPos, xRectSize, yRectSize) 'tla dla wykresow
        'g.FillRectangle(Brushes.White, xPos, yPos + 10 + yRectSize, xRectSize, yRectSize)
        'g.FillRectangle(Brushes.White, xPos, yPos + 10 * 2 + 2 * yRectSize, xRectSize, yRectSize)
        'g.FillRectangle(Brushes.White, xPos, yPos + 10 * 3 + 3 * yRectSize, xRectSize, yRectSize)

        g.FillRectangle(Brushes.White, xModelPos, yModelPos, xModelSize, yModelSize) 'model
        g.DrawLine(Pens.Red, xModelPos + 10, yModelPos + 10, xModelPos + 10, yModelPos + yModelSize - 10)
        g.DrawLine(Pens.Red, xModelPos + 10, yModelPos + yModelSize - 10, xModelPos + xModelSize - 10, yModelPos + yModelSize - 10)
        g.DrawLine(Pens.Red, xModelPos + 10, yModelPos + yModelSize / 3 + 10, xModelPos + xModelSize - 10, yModelPos + yModelSize / 3 + 10)
        g.DrawLine(Pens.Red, xModelPos + 10, yModelPos + yModelSize / 3 * 2 + 25, xModelPos + xModelSize - 10, yModelPos + yModelSize / 3 * 2 + 25)

        g.DrawLine(Pens.Red, xModelPos + 10, yModelPos + 10, xModelPos + 5, yModelPos + 15) 'strzalki modelu
        g.DrawLine(Pens.Red, xModelPos + 10, yModelPos + 10, xModelPos + 15, yModelPos + 15)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 10, yModelPos + yModelSize / 3 + 10, xModelPos + xModelSize - 15, yModelPos + yModelSize / 3 + 15)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 10, yModelPos + yModelSize / 3 + 10, xModelPos + xModelSize - 15, yModelPos + yModelSize / 3 + 5)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 10, yModelPos + yModelSize / 3 * 2 + 25, xModelPos + xModelSize - 15, yModelPos + yModelSize / 3 * 2 + 5 + 25)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 10, yModelPos + yModelSize / 3 * 2 + 25, xModelPos + xModelSize - 15, yModelPos + yModelSize / 3 * 2 - 5 + 25)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 10, yModelPos + yModelSize - 10, xModelPos + xModelSize - 15, yModelPos + yModelSize - 5)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 10, yModelPos + yModelSize - 10, xModelPos + xModelSize - 15, yModelPos + yModelSize - 15)

        g.DrawRectangle(Pens.Red, xModelPos + xModelSize / 4, yModelPos + 80, xModelSize / 2, yModelSize / 3 - 70) 'boxxxy modelu
        g.DrawRectangle(Pens.Red, xModelPos + xModelSize / 4, yModelPos + 204 + 25, xModelSize / 2, yModelSize / 3 - 70)

        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 * 2 + 25, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 * 2 + 35) 'sprezynki i tlumiki
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 * 2 + 35, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 * 2 + 40)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 * 2 + 40, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 * 2 + 50)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 * 2 + 50, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 * 2 + 60)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 * 2 + 60, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 * 2 + 70)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 * 2 + 70, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 * 2 + 80)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 * 2 + 80, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 * 2 + 90)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 * 2 + 90, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 * 2 + 100)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 * 2 + 100, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 * 2 + 105)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 * 2 + 105, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 * 2 + 123)

        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 + 10, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 + 20)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 + 20, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 + 25)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 + 25, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 + 35)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 + 35, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 + 45)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 + 45, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 + 55)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 + 55, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 + 65)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 20, yModelPos + yModelSize / 3 + 65, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 + 75)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5, yModelPos + yModelSize / 3 + 75, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 + 80)
        g.DrawLine(Pens.Red, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 + 80, xModelPos + 2 * xModelSize / 5 - 10, yModelPos + yModelSize / 3 + 95)

        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5 + 10, yModelPos + yModelSize / 3 * 2 + 25, xModelPos + 3 * xModelSize / 5 + 10, yModelPos + yModelSize / 3 * 2 + 65)
        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5 + 5, yModelPos + yModelSize / 3 * 2 + 65, xModelPos + 3 * xModelSize / 5 + 15, yModelPos + yModelSize / 3 * 2 + 65)
        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5, yModelPos + yModelSize / 3 * 2 + 80, xModelPos + 3 * xModelSize / 5 + 20, yModelPos + yModelSize / 3 * 2 + 80)
        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5, yModelPos + yModelSize / 3 * 2 + 65, xModelPos + 3 * xModelSize / 5, yModelPos + yModelSize / 3 * 2 + 80)
        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5 + 20, yModelPos + yModelSize / 3 * 2 + 65, xModelPos + 3 * xModelSize / 5 + 20, yModelPos + yModelSize / 3 * 2 + 80)
        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5 + 10, yModelPos + yModelSize / 3 * 2 + 80, xModelPos + 3 * xModelSize / 5 + 10, yModelPos + yModelSize / 3 * 2 + 123)

        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5 + 10, yModelPos + yModelSize / 3 + 10, xModelPos + 3 * xModelSize / 5 + 10, yModelPos + yModelSize / 3 + 50)
        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5 + 5, yModelPos + yModelSize / 3 + 50, xModelPos + 3 * xModelSize / 5 + 15, yModelPos + yModelSize / 3 + 50)
        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5, yModelPos + yModelSize / 3 + 65, xModelPos + 3 * xModelSize / 5 + 20, yModelPos + yModelSize / 3 + 65)
        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5, yModelPos + yModelSize / 3 + 50, xModelPos + 3 * xModelSize / 5, yModelPos + yModelSize / 3 + 65)
        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5 + 20, yModelPos + yModelSize / 3 + 50, xModelPos + 3 * xModelSize / 5 + 20, yModelPos + yModelSize / 3 + 65)
        g.DrawLine(Pens.Red, xModelPos + 3 * xModelSize / 5 + 10, yModelPos + yModelSize / 3 + 65, xModelPos + 3 * xModelSize / 5 + 10, yModelPos + yModelSize / 3 + 95)

        g.DrawLine(Pens.Red, xModelPos + 45, yModelPos + yModelSize / 3 + 10, xModelPos + 45, yModelPos + yModelSize / 3 - 40) 'strzalki opisu
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 45, yModelPos + yModelSize / 3 + 10, xModelPos + xModelSize - 45, yModelPos + yModelSize / 3 - 40)
        g.DrawLine(Pens.Red, xModelPos + 45, yModelPos + yModelSize - 10, xModelPos + 45, yModelPos + yModelSize - 60)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 45, yModelPos + yModelSize / 3 * 2 + 25, xModelPos + xModelSize - 45, yModelPos + yModelSize / 3 * 2 - 20)
        g.DrawLine(Pens.Red, xModelPos + 45, yModelPos + yModelSize / 3 - 40, xModelPos + 40, yModelPos + yModelSize / 3 - 35)
        g.DrawLine(Pens.Red, xModelPos + 45, yModelPos + yModelSize / 3 - 40, xModelPos + 50, yModelPos + yModelSize / 3 - 35)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 45, yModelPos + yModelSize / 3 - 40, xModelPos + xModelSize - 40, yModelPos + yModelSize / 3 - 35)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 45, yModelPos + yModelSize / 3 - 40, xModelPos + xModelSize - 50, yModelPos + yModelSize / 3 - 35)
        g.DrawLine(Pens.Red, xModelPos + 45, yModelPos + yModelSize - 60, xModelPos + 50, yModelPos + yModelSize - 55)
        g.DrawLine(Pens.Red, xModelPos + 45, yModelPos + yModelSize - 60, xModelPos + 40, yModelPos + yModelSize - 55)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 45, yModelPos + yModelSize / 3 * 2 - 20, xModelPos + xModelSize - 40, yModelPos + yModelSize / 3 * 2 - 15)
        g.DrawLine(Pens.Red, xModelPos + xModelSize - 45, yModelPos + yModelSize / 3 * 2 - 20, xModelPos + xModelSize - 50, yModelPos + yModelSize / 3 * 2 - 15)

        g.DrawString("m1", Font1, Brushes.Red, xModelPos + xModelSize / 2 - 20, yModelPos + yModelSize / 3 - 30) 'opis
        g.DrawString("m2", Font1, Brushes.Red, xModelPos + xModelSize / 2 - 20, yModelPos + yModelSize / 3 * 2 - 20)
        g.DrawString("f", Font1, Brushes.Red, xModelPos + 20, yModelPos + yModelSize / 3 - 30)
        g.DrawString("u", Font1, Brushes.Red, xModelPos + 17, yModelPos + yModelSize - 50)
        g.DrawString("b1", Font1, Brushes.Red, xModelPos + xModelSize - 90, yModelPos + yModelSize / 3 + 35)
        g.DrawString("b2", Font1, Brushes.Red, xModelPos + xModelSize - 90, yModelPos + yModelSize / 3 * 2 + 60)
        g.DrawString("k1", Font1, Brushes.Red, xModelPos + 60, yModelPos + yModelSize / 3 + 35)
        g.DrawString("k2", Font1, Brushes.Red, xModelPos + 60, yModelPos + yModelSize / 3 * 2 + 60)
        g.DrawString("x1", Font1, Brushes.Red, xModelPos + xModelSize - 40, yModelPos + yModelSize / 3 - 30)
        g.DrawString("x2", Font1, Brushes.Red, xModelPos + xModelSize - 40, yModelPos + yModelSize / 3 * 2 - 20)


        'For n As Integer = 0 To 3
        'g.DrawLine(Pens.Red, xPos + 5, yPos + yRectSize * n + yRectSize / 2 + 10 * n, xRectSize, yPos + yRectSize * n + yRectSize / 2 + 10 * n) 'osie dla wykresow
        'g.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize * n + 5 + 10 * n, xPos + 10, yPos + yRectSize * n + yRectSize - 5 + 10 * n)
        'g.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize * n + 5 + 10 * n, xPos + 5, yPos + yRectSize * n + 10 + 10 * n)
        'g.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize * n + 5 + 10 * n, xPos + 15, yPos + yRectSize * n + 10 + 10 * n)
        'g.DrawLine(Pens.Red, xPos + xRectSize - 10, yPos + yRectSize * n + yRectSize / 2 + 10 * n, xPos + xRectSize - 15, yPos + yRectSize * n + yRectSize / 2 + 10 * n - 5)
        'g.DrawLine(Pens.Red, xPos + xRectSize - 10, yPos + yRectSize * n + yRectSize / 2 + 10 * n, xPos + xRectSize - 15, yPos + yRectSize * n + yRectSize / 2 + 10 * n + 5)
        'g.DrawString("t", Font2, Brushes.Red, xPos + xRectSize - 30, yPos + yRectSize / 2 - 30 + (yRectSize + 10) * n)
        'Next

        'g.DrawString("f", Font2, Brushes.Red, xPos + 50, yPos + 5)
        'g.DrawString("x1", Font2, Brushes.Red, xPos + 50, yPos + yRectSize + 10 + 5)
        'g.DrawString("x2", Font2, Brushes.Red, xPos + 50, yPos + (yRectSize + 10) * 2 + 5)
        'g.DrawString("u", Font2, Brushes.Red, xPos + 50, yPos + (yRectSize + 10) * 3 + 5)


    End Sub

    Private Sub RysujBrakPobudzenia_f(ByVal e As PictureBox, ByVal file As String, ByVal SimTime As Double)
        'Dim g As Graphics = Graphics.FromImage(e.Image)
        Dim bm As New Bitmap(e.Width, e.Height)
        Dim p As Graphics = Graphics.FromImage(bm)

        p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2, xPos + xRectSize + 50, yPos + yRectSize / 2)
        p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 + 130, xPos + 10, yPos + yRectSize / 2 - 130)
        p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 - 130, xPos + 5, yPos + yRectSize / 2 - 125)
        p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 - 130, xPos + 15, yPos + yRectSize / 2 - 125)
        p.DrawLine(Pens.Red, xPos + xRectSize + 45, yPos + yRectSize / 2 + 5, xPos + xRectSize + 50, yPos + yRectSize / 2)
        p.DrawLine(Pens.Red, xPos + xRectSize + 45, yPos + yRectSize / 2 - 5, xPos + xRectSize + 50, yPos + yRectSize / 2)
        p.DrawString(SimTime, Font3, Brushes.Red, xPos + xRectSize + 38, yPos + yRectSize - 125)

        p.DrawLine(Pens.Blue, xPos + 10, yPos + yRectSize / 2, xPos + xRectSize + 40, yPos + yRectSize / 2)

        p.DrawString("f", Font3, Brushes.Red, xPos + 20, yPos - 10)

        p.DrawString("0", Font3, Brushes.Red, xPos + 12, yPos + yRectSize - 125)
        bm.Save(file)
        bm.Dispose()
    End Sub

    Private Sub RysujBrakPobudzenia_u(ByVal e As PictureBox, ByVal file As String, ByVal SimTime As Double)
        'Dim g As Graphics = e.CreateGraphics
        Dim bm As New Bitmap(e.Width, e.Height)
        Dim p As Graphics = Graphics.FromImage(bm)
        p.DrawString("0", Font3, Brushes.Red, xPos + 12, yPos + yRectSize + 155)

        p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 + 280, xPos + xRectSize + 50, yPos + yRectSize / 2 + 280)
        p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 + 130 + 280, xPos + 10, yPos + yRectSize / 2 - 130 + 280)
        p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 - 130 + 280, xPos + 5, yPos + yRectSize / 2 - 125 + 280)
        p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 - 130 + 280, xPos + 15, yPos + yRectSize / 2 - 125 + 280)
        p.DrawLine(Pens.Red, xPos + xRectSize + 45, yPos + yRectSize / 2 + 5 + 280, xPos + xRectSize + 50, yPos + yRectSize / 2 + 280)
        p.DrawLine(Pens.Red, xPos + xRectSize + 45, yPos + yRectSize / 2 - 5 + 280, xPos + xRectSize + 50, yPos + yRectSize / 2 + 280)

        p.DrawString(SimTime, Font3, Brushes.Red, xPos + xRectSize + 38, yPos + yRectSize + 125 + 30)
        p.DrawString("u", Font3, Brushes.Red, xPos + 20, yPos + yRectSize + 20)

        p.DrawLine(Pens.Blue, xPos + 10, yPos + yRectSize / 2 + yRectSize + 30, xPos + xRectSize + 40, yPos + yRectSize / 2 + 30 + yRectSize)
        bm.Save(file)
        bm.Dispose()
    End Sub

    'Private Sub picturebox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
    Private Sub Rysuj(ByVal e As PictureBox, ByVal Arr As Array, ByVal H As Array, ByVal Steps As Integer, ByVal TimeStep As Double, ByVal SimTime As Double, ByVal n As Integer, ByVal file As String)
        'Private Sub Rysuj(ByVal e As Object)
        Dim bm As New Bitmap(e.Width, e.Height)
        Dim p As Graphics = Graphics.FromImage(bm)
        'p.DrawLine(Pens.Black, 100, 100, 100, 1000)

        'Dim g As Graphics = e.CreateGraphics

        'MsgBox("nie weszłeś")
        'Dim g As Graphics = Graphics.FromImage(e.Image)
        'Dim kk As Double
        'Dim H As Array = Array.CreateInstance(GetType(Double), CInt(Steps))

        H = Arr.Clone
        Array.Sort(H)
        Dim MaxArr As Double = H.GetValue(CInt(Steps - 1))
        Dim MinArr As Double = H.GetValue(0)

        Dim kk As Double
        If Math.Abs(MinArr) > 1000000000 Then
            MinArr = 100000
        End If

        If MaxArr > 1000000000 Then
            MaxArr = 100000
        End If
        'If Math.Abs(MinArr) > MaxArr Then
        '   kk = MinArr
        '   g.DrawString(CStr(MinArr), Font3, Brushes.Red, xPos + 12, yPos + (yRectSize + 10) * n + 120)
        '   kk = Math.Abs(MinArr)
        '   g.DrawLine(Pens.Red, xPos + 8, yPos + (yRectSize + 10) * n + 15 + 120, xPos + 12, yPos + (yRectSize + 10) * n + 15 + 120)
        'Else
        '    kk = Math.Abs(MaxArr)
        '    g.DrawString(CStr(MaxArr), Font3, Brushes.Red, xPos + 12, yPos + (yRectSize + 10) * n)
        '    g.DrawLine(Pens.Red, xPos + 8, yPos + (yRectSize + 10) * n + 15, xPos + 12, yPos + (yRectSize + 10) * n + 15)
        'End If

        'If kk = 0 Then
        '    kk = 1
        'End If

        'For k As Integer = 0 To CInt(Steps - 2)
        '    If Arr(k + 1) > 10000000000 Then
        '        k = CInt(Steps - 3)
        '        MsgBox("Overflow")
        '    End If
        '    g.DrawLine(Pens.Blue, CInt(xPos + 10 + k * TimeStep * xRectSize / SimTime), CInt(yPos + (yRectSize + 10) * n + yRectSize / 2 - Arr(k) * 120 / kk), CInt(xPos + 10 + (k + 1) * TimeStep * xRectSize / SimTime), CInt(yPos + (yRectSize + 10) * n + yRectSize / 2 - Arr(k + 1) / kk * 120))
        'Next k

        'g.Dispose()
        'e.Image = bm
        'e.Refresh()

        'n = 0
        'H = Arr.Clone
        'Array.Sort(H)
        'MaxArr = H.GetValue(CInt(Steps - 1))
        'MinArr = H.GetValue(0)
        'Dim kk As Double
        If n = 0 Then
            p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2, xPos + xRectSize + 50, yPos + yRectSize / 2)
            p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 + 130, xPos + 10, yPos + yRectSize / 2 - 130)
            p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 - 130, xPos + 5, yPos + yRectSize / 2 - 125)
            p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 - 130, xPos + 15, yPos + yRectSize / 2 - 125)
            p.DrawLine(Pens.Red, xPos + xRectSize + 45, yPos + yRectSize / 2 + 5, xPos + xRectSize + 50, yPos + yRectSize / 2)
            p.DrawLine(Pens.Red, xPos + xRectSize + 45, yPos + yRectSize / 2 - 5, xPos + xRectSize + 50, yPos + yRectSize / 2)
            p.DrawString(SimTime, Font3, Brushes.Red, xPos + xRectSize + 38, yPos + yRectSize - 125)
            If file = "X1.bmp" Then
                p.DrawString("x1", Font3, Brushes.Red, xPos + 20, yPos - 10)
            End If
            If file = "F.bmp" Then
                p.DrawString("f", Font3, Brushes.Red, xPos + 20, yPos - 10)
            End If
            If file = "V1.bmp" Then
                p.DrawString("v1", Font3, Brushes.Red, xPos + 20, yPos - 10)
            End If
            p.DrawString("t", Font3, Brushes.Red, xPos + 50 + xRectSize, yPos - 30 + yRectSize / 2)
        End If

        If n = 1 Then
            p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 + 280, xPos + xRectSize + 50, yPos + yRectSize / 2 + 280)
            p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 + 130 + 280, xPos + 10, yPos + yRectSize / 2 - 130 + 280)
            p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 - 130 + 280, xPos + 5, yPos + yRectSize / 2 - 125 + 280)
            p.DrawLine(Pens.Red, xPos + 10, yPos + yRectSize / 2 - 130 + 280, xPos + 15, yPos + yRectSize / 2 - 125 + 280)
            p.DrawLine(Pens.Red, xPos + xRectSize + 45, yPos + yRectSize / 2 + 5 + 280, xPos + xRectSize + 50, yPos + yRectSize / 2 + 280)
            p.DrawLine(Pens.Red, xPos + xRectSize + 45, yPos + yRectSize / 2 - 5 + 280, xPos + xRectSize + 50, yPos + yRectSize / 2 + 280)
            p.DrawString(SimTime, Font3, Brushes.Red, xPos + xRectSize + 38, yPos + yRectSize + 125 + 30)
            If file = "X2.bmp" Then
                p.DrawString("x2", Font3, Brushes.Red, xPos + 20, yPos + 20 + yRectSize)
            End If
            If file = "U.bmp" Then
                p.DrawString("u", Font3, Brushes.Red, xPos + 20, yPos + 20 + yRectSize)
            End If
            If file = "V2.bmp" Then
                p.DrawString("v2", Font3, Brushes.Red, xPos + 20, yPos + 20 + yRectSize)
            End If
            p.DrawString("t", Font3, Brushes.Red, xPos + 50 + xRectSize, yPos - 30 + yRectSize / 2 + yRectSize + 30)
        End If

        If Math.Abs(MinArr) > MaxArr Then
            kk = MinArr
            p.DrawString(CStr(MinArr), Font3, Brushes.Red, xPos + 12, yPos + (yRectSize + 35) * n + yRectSize - 20)
            kk = Math.Abs(MinArr)
            p.DrawLine(Pens.Red, xPos + 5, yPos + (yRectSize + 35) * n + yRectSize - 10, xPos + 15, yPos + (yRectSize + 35) * n + yRectSize - 10)
        Else
            kk = Math.Abs(MaxArr)
            p.DrawString(CStr(MaxArr), Font3, Brushes.Red, xPos + 12, yPos + (yRectSize + 30) * n + 5)
            p.DrawLine(Pens.Red, xPos + 5, yPos + (yRectSize + 30) * n + 5, xPos + 15, yPos + (yRectSize + 30) * n + 5)
        End If



        If kk = 0 Then
            kk = 1
        End If

        For k As Integer = 0 To CInt(Steps - 2)
            If Arr(k + 1) > 100000000 Then
                MsgBox("overflow")
                Exit For
            End If
                p.DrawLine(Pens.Blue, CInt(xPos + 10 + k * TimeStep * (xRectSize + 30) / SimTime), CInt(yPos + (yRectSize + 30) * n + yRectSize / 2 - Arr(k) * 120 / kk), CInt(xPos + 10 + (k + 1) * TimeStep * (xRectSize + 30) / SimTime), CInt(yPos + (yRectSize + 30) * n + yRectSize / 2 - Arr(k + 1) / kk * 120))
        Next k
        bm.Save(file)
        bm.Dispose()
    End Sub

    Private Function fx1(ByVal x1 As Double, ByVal x2 As Double, ByVal v1 As Double, ByVal v2 As Double, ByVal v As Double, ByVal f As Double, ByVal k1 As Double, ByVal k2 As Double, ByVal b1 As Double, ByVal b2 As Double, ByVal m1 As Double, ByVal m2 As Double)
        fx1 = (k1 / m1 * (x2 - x1) + b1 / m1 * (v2 - v1) + f)
        Return fx1
    End Function

    Private Function fx2(ByVal x1 As Double, ByVal x2 As Double, ByVal v1 As Double, ByVal v2 As Double, ByVal v As Double, ByVal U As Double, ByVal k1 As Double, ByVal k2 As Double, ByVal b1 As Double, ByVal b2 As Double, ByVal m1 As Double, ByVal m2 As Double)
        fx2 = (k1 / m2 * (x1 - x2) + b1 / m2 * (v1 - v2) + k2 / m2 * (U - x2) + b2 / m2 * (v - v2))

        Return fx2
    End Function

    Private Sub Tabela(ByVal x1 As Array, ByVal x2 As Array, ByVal f As Array, ByVal u As Array, ByVal Steps As Integer)
        Dim row As String() = {"a", "b", "c", "d"}

        DataGridView1.Rows.Clear()

        For i As Integer = 0 To Steps - 1
            row(0) = x1(i)
            row(1) = x2(i)
            row(2) = u(i)
            row(3) = f(i)
            DataGridView1.Rows.Add(row)
        Next i
    End Sub

    'Private Sub picturebox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picturebox1.Paint
    '    picturebox1.Image = System.Drawing.Bitmap.FromFile(My.Application.Info.DirectoryPath & "\F.bmp")
    '    MsgBox("refersh")
    'End Sub

    'Private Sub picturebox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picturebox1.Paint
    '    MsgBox("Paint Event")
    'End Sub

    Private Sub Euler(ByVal f As Array, ByVal U As Array, ByVal Steps As Single, ByVal SimTime As Double, ByVal m1 As Double, ByVal m2 As Double, ByVal k1 As Double, ByVal k2 As Double, ByVal b1 As Double, ByVal b2 As Double, ByVal sx1 As Double, ByVal sx2 As Double, ByVal sv1 As Double, ByVal sv2 As Double, ByVal sv As Double)

        Me.Refresh()
        Dim x1 As Array = Array.CreateInstance(GetType(Double), CInt(Steps))
        Dim x2 As Array = Array.CreateInstance(GetType(Double), CInt(Steps))
        Dim v As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) ' pochodna U
        Dim v1 As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) 'pochodna x1
        Dim v2 As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) 'pochodna x2


        x1(0) = sx1
        x2(0) = sx2
        v(0) = sv
        v1(0) = sv1
        v2(0) = sv2

        Dim h As Double = SimTime / Steps
        Dim v1new, x1new As Double
        Dim v2new, x2new As Double
        Dim vnew As Double

        For i As Integer = 0 To CInt(Steps - 2)
            v1new = v1(i) + h * (k1 / m1 * (x2(i) - x1(i)) + b1 / m1 * (v2(i) - v1(i)) + f(i))
            x1new = x1(i) + h * v1(i)

            v2new = v2(i) + h * (k1 / m2 * (x1(i) - x2(i)) + b1 / m2 * (v1(i) - v2(i)) + k2 / m2 * (U(i) - x2(i)) + b2 / m2 * (v(i) - v2(i)))
            x2new = x2(i) + h * v2(i)

            vnew = v(i) + h * U(i)

            v1(i + 1) = v1new
            x1(i + 1) = x1new

            v2(i + 1) = v2new
            x2(i + 1) = x2new

            v(i) = vnew

        Next

        'ArrU = U.Clone
        'ArrF = f.Clone
        'ArrX1 = x1.Clone
        'ArrX2 = x2.Clone

        'picturebox1.Update()
        'Me.Invalidate()

        'picturebox1.Refresh()
        'picturebox1.Refresh()
        Dim HTab As Array = Array.CreateInstance(GetType(Double), CInt(Steps))
        Dim n As Integer
        n = 0
        Rysuj(pictureBox1, x1, HTab, CInt(Steps), h, SimTime, n, "X1.bmp")
        Rysuj(pictureBox1, v1, HTab, CInt(Steps), h, SimTime, n, "V1.bmp")
        n = 1
        Rysuj(pictureBox1, x2, HTab, CInt(Steps), h, SimTime, n, "X2.bmp")
        Rysuj(pictureBox1, v2, HTab, CInt(Steps), h, SimTime, n, "V2.bmp")
        Tabela(x1, x2, f, U, Steps)

        'Dim fuckyou As Bitmap = picturebox1.Image
        'fuckyou.Save("as1.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
        'picturebox1.Image.Save("as2.bmp", System.Drawing.Imaging.ImageFormat.Bmp)

    End Sub

    Private Sub RK(ByVal f As Array, ByVal U As Array, ByVal Steps As Single, ByVal SimTime As Double, ByVal m1 As Double, ByVal m2 As Double, ByVal k1 As Double, ByVal k2 As Double, ByVal b1 As Double, ByVal b2 As Double, ByVal sx1 As Double, ByVal sx2 As Double, ByVal sv1 As Double, ByVal sv2 As Double, ByVal sv As Double)


        Me.Refresh()
        Dim x1 As Array = Array.CreateInstance(GetType(Double), CInt(Steps))
        Dim x2 As Array = Array.CreateInstance(GetType(Double), CInt(Steps))
        Dim v As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) ' pochodna U
        Dim v1 As Array = Array.CreateInstance(GetType(Double), CInt(Steps))
        Dim v2 As Array = Array.CreateInstance(GetType(Double), CInt(Steps))
        Dim kx1_1, kx1_2, kx1_3, kx1_4 As Double
        Dim kx2_1, kx2_2, kx2_3, kx2_4 As Double
        Dim kv1_1, kv1_2, kv1_3, kv1_4 As Double
        Dim kv2_1, kv2_2, kv2_3, kv2_4 As Double
        Dim kv_1, kv_2, kv_3, kv_4 As Double

        x1(0) = sx1
        x2(0) = sx2
        v(0) = sv
        v1(0) = sv1
        v2(0) = sv2

        Dim h As Double = SimTime / Steps

        For i As Integer = 0 To CInt(Steps - 2)

            '(k1 / m1 * (x2 - x1) + b1 / m1 * (v2 - v1) + f)
            '(k1 / m2 * (x1 - x2) + b1 / m2 * (v1 - v2) + k2 / m2 * (U - x2) + b2 / m2 * (v - v2))

            'Private Function fx1(ByVal x1 As Double, ByVal x2 As Double, ByVal v1 As Double, ByVal v2 As Double, ByVal v As Double, ByVal f As Double, ByVal k1 As Double, ByVal k2 As Double, ByVal b1 As Double, ByVal b2 As Double, ByVal m1 As Double, ByVal m2 As Double)
            'Private Function fx2(ByVal x1 As Double, ByVal x2 As Double, ByVal v1 As Double, ByVal v2 As Double, ByVal v As Double, ByVal U As Double, ByVal k1 As Double, ByVal k2 As Double, ByVal b1 As Double, ByVal b2 As Double, ByVal m1 As Double, ByVal m2 As Double)

            kx1_1 = h * v1(i)
            kx2_1 = h * v2(i)
            kv1_1 = h * fx1(x1(i), x2(i), v1(i), v2(i), v(i), f(i), k1, k2, b1, b2, m1, m2)
            kv2_1 = h * fx2(x1(i), x2(i), v1(i), v2(i), v(i), U(i), k1, k2, b1, b2, m1, m2)
            kv_1 = h * U(i)

            kx1_2 = h * (v1(i) + v1(i + 1)) / 2
            kx2_2 = h * (v2(i) + v2(i + 1)) / 2
            kv1_2 = h * fx1(x1(i) + 1 / 2 * kx1_1, x2(i) + 1 / 2 * kx2_1, v1(i) + 1 / 2 * kv1_1, v2(i) + 1 / 2 * kv2_1, v(i) + 1 / 2 * kv_1, (f(i) + f(i + 1)) / 2, k1, k2, b1, b2, m1, m2)
            kv2_2 = h * fx2(x1(i) + 1 / 2 * kx1_1, x2(i) + 1 / 2 * kx2_1, v1(i) + 1 / 2 * kv1_1, v2(i) + 1 / 2 * kv2_1, v(i) + 1 / 2 * kv_1, (U(i) + U(i + 1)) / 2, k1, k2, b1, b2, m1, m2)
            kv_2 = h * (U(i) + U(i + 1)) / 2

            kx1_3 = h * (v1(i) + v1(i + 1)) / 2
            kx2_3 = h * (v2(i) + v2(i + 1)) / 2
            kv1_3 = h * fx1(x1(i) + 1 / 2 * kx1_2, x2(i) + 1 / 2 * kx2_2, v1(i) + 1 / 2 * kv1_2, v2(i) + 1 / 2 * kv2_2, v(i) + 1 / 2 * kv_2, (f(i) + f(i + 1)) / 2, k1, k2, b1, b2, m1, m2)
            kv2_3 = h * fx2(x1(i) + 1 / 2 * kx1_2, x2(i) + 1 / 2 * kx2_2, v1(i) + 1 / 2 * kv1_2, v2(i) + 1 / 2 * kv2_2, v(i) + 1 / 2 * kv_2, (U(i) + U(i + 1)) / 2, k1, k2, b1, b2, m1, m2)
            kv_3 = h * (U(i) + U(i + 1)) / 2

            kx1_4 = h * v1(i + 1)
            kx2_4 = h * v2(i + 1)
            kv1_4 = h * fx1(x1(i) + kx1_3, x2(i) + kx2_3, v1(i) + kv1_3, v2(i) + kv2_3, v(i) + kv_3, f(i + 1), k1, k2, b1, b2, m1, m2)
            kv2_4 = h * fx2(x1(i) + kx1_3, x2(i) + kx2_3, v1(i) + kv1_3, v2(i) + kv2_3, v(i) + kv_3, f(i + 1), k1, k2, b1, b2, m1, m2)
            kv_4 = h * U(i + 1)

            x1(i + 1) = x1(i) + 1 / 6 * (kx1_1 + 2 * kx1_2 + 2 * kx1_3 + kx1_4)
            x2(i + 1) = x2(i) + 1 / 6 * (kx2_1 + 2 * kx2_2 + 2 * kx2_3 + kx2_4)
            v1(i + 1) = v1(i) + 1 / 6 * (kv1_1 + 2 * kv1_2 + 2 * kv1_3 + kv1_4)
            v2(i + 1) = v2(i) + 1 / 6 * (kv2_1 + 2 * kv2_2 + 2 * kv2_3 + kv2_4)
            v(i + 1) = v2(i) + 1 / 6 * (kv_1 + 2 * kv_2 + 2 * kv_3 + kv_4)

        Next

        'ArrU = U.Clone
        'ArrF = f.Clone
        'ArrX1 = x1.Clone
        'ArrX2 = x2.Clone

        Dim HTab As Array = Array.CreateInstance(GetType(Double), CInt(Steps))
        Dim n As Integer
        n = 0
        Rysuj(pictureBox1, x1, HTab, CInt(Steps), h, SimTime, n, "X1.bmp")
        Rysuj(pictureBox1, v1, HTab, CInt(Steps), h, SimTime, n, "V1.bmp")
        n = 1
        Rysuj(pictureBox1, x2, HTab, CInt(Steps), h, SimTime, n, "X2.bmp")
        Rysuj(pictureBox1, v2, HTab, CInt(Steps), h, SimTime, n, "V2.bmp")
        Tabela(x1, x2, f, U, Steps)

    End Sub

    Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim TimeStep As Double
        Dim fAmp As Double
        Dim fTime As Double
        Dim uAmp As Double
        Dim uTime As Double
        Dim Steps As Single
        Dim SimTime As Double
        Dim m1 As Double
        Dim m2 As Double
        Dim b1 As Double
        Dim b2 As Double
        Dim k1 As Double
        Dim k2 As Double
        Dim ex As String = ""
        Dim n As New Integer
        Dim sx1 As Double
        Dim sx2 As Double
        Dim sv1 As Double
        Dim sv2 As Double
        Dim sv As Double

        'Me.Refresh()

        If (Not (TextBox7.Text = ex) And Not (TextBox8.Text = ex) Or RadioButton6.Checked = True) And (Not (TextBox20.Text = ex) And Not (TextBox19.Text = ex) Or RadioButton15.Checked = True) And Not (TextBox21.Text = ex) And Not (TextBox22.Text = ex) And Not (TextBox13.Text = ex) And Not (TextBox14.Text = ex) And Not (TextBox15.Text = ex) And Not (TextBox16.Text = ex) And Not (TextBox17.Text = ex) And Not (TextBox18.Text = ex) And Not (TextBox1.Text = ex) And Not (TextBox2.Text = ex) And Not (TextBox3.Text = ex) And Not (TextBox4.Text = ex) And Not (TextBox5.Text = ex) Then

            If Not TextBox5.Text = ex Then
                fAmp = CDbl(TextBox5.Text)
            End If

            If Not TextBox4.Text = ex Then
                fAmp = CDbl(TextBox4.Text)
            End If

            If Not TextBox3.Text = ex Then
                fAmp = CDbl(TextBox3.Text)
            End If

            If Not TextBox2.Text = ex Then
                fAmp = CDbl(TextBox2.Text)
            End If

            If Not TextBox1.Text = ex Then
                fAmp = CDbl(TextBox1.Text)
            End If

            If Not TextBox7.Text = ex Then
                fAmp = CDbl(TextBox7.Text)
            End If

            If Not TextBox8.Text = ex Then
                fTime = CDbl(TextBox8.Text)
            End If

            If Not TextBox20.Text = ex Then
                uAmp = CDbl(TextBox20.Text)
            End If

            If Not TextBox19.Text = ex Then
                uTime = CDbl(TextBox19.Text)
            End If

            m1 = CDbl(TextBox13.Text)
            m2 = CDbl(TextBox14.Text)
            k1 = CDbl(TextBox15.Text)
            k2 = CDbl(TextBox16.Text)
            b1 = CDbl(TextBox17.Text)
            b2 = CDbl(TextBox18.Text)
            Steps = CDbl(TextBox21.Text)
            SimTime = CDbl(TextBox22.Text)
            sv1 = CDbl(TextBox1.Text)
            sx1 = CDbl(TextBox5.Text)
            sv2 = CDbl(TextBox3.Text)
            sx2 = CDbl(TextBox2.Text)
            sv = CDbl(TextBox4.Text)

            pierwszy = False

            Dim plik As String = "F.bmp"
            Dim U As Array = Array.CreateInstance(GetType(Double), CInt(Steps))
            Dim F As Array = Array.CreateInstance(GetType(Double), CInt(Steps))
            Dim H As Array = Array.CreateInstance(GetType(Double), CInt(Steps))

            If RadioButton6.Checked = True Then
                n = 0
                For i As Integer = 0 To CInt(Steps - 1)
                    F(i) = 0
                Next
                RysujBrakPobudzenia_f(pictureBox1, plik, SimTime)
                'Rysuj(pictureBox1, F, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton5.Checked = True Then
                n = 0
                F(0) = fAmp
                q = 0
                TimeStep = SimTime / Steps
                For i As Integer = 1 To CInt(Steps - 1)
                    If TimeStep * i - q * fTime < fTime Then
                        F(i) = 0
                    Else
                        F(i) = fAmp
                        q = q + 1
                    End If
                Next i

                Rysuj(pictureBox1, F, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton3.Checked = True Then
                n = 0
                TimeStep = SimTime / Steps
                For i As Integer = 0 To CInt(Steps - 1)
                    F(i) = fAmp
                Next i

                Rysuj(pictureBox1, F, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton2.Checked = True Then
                n = 0
                TimeStep = SimTime / Steps
                q = 0
                For i As Integer = 0 To CInt(Steps - 1)
                    If i * TimeStep - q * fTime < fTime Then
                        If TimeStep * i - q * fTime < fTime / 2 Then
                            F(i) = fAmp
                        End If
                        If TimeStep * i - q * fTime > fTime / 2 And TimeStep * i - q * fTime < fTime Then
                            F(i) = 0
                        End If
                    Else
                        q = q + 1
                    End If
                Next i

                Rysuj(pictureBox1, F, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton1.Checked = True Then
                n = 0
                TimeStep = SimTime / Steps
                q = 0
                For i As Integer = 0 To CInt(Steps - 1)
                    If i * TimeStep - q * fTime < fTime Then
                        F(i) = fAmp * (i * TimeStep - q * fTime) / fTime
                    Else
                        F(i) = 0
                        q = q + 1
                    End If
                Next i

                Rysuj(pictureBox1, F, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton4.Checked = True Then
                n = 0
                TimeStep = SimTime / Steps
                'q = 0
                For i As Integer = 0 To CInt(Steps - 1)
                    F(i) = fAmp * Math.Sin(2 * Math.PI / fTime * i * TimeStep)
                Next i

                Rysuj(pictureBox1, F, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            plik = "U.bmp"

            If RadioButton15.Checked = True Then
                n = 1
                For i As Integer = 0 To CInt(Steps - 1)
                    U(i) = 0
                Next

                RysujBrakPobudzenia_u(pictureBox1, plik, SimTime)
                'Rysuj(pictureBox1, U, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton16.Checked = True Then
                n = 1
                U(0) = uAmp
                q = 0
                TimeStep = SimTime / Steps
                For i As Integer = 1 To CInt(Steps - 1)
                    If TimeStep * i - q * uTime < uTime Then
                        U(i) = 0
                    Else
                        U(i) = uAmp
                        q = q + 1
                    End If
                Next i

                Rysuj(pictureBox1, U, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton18.Checked = True Then
                n = 1
                TimeStep = SimTime / Steps
                For i As Integer = 0 To CInt(Steps - 1)
                    U(i) = uAmp
                Next i

                Rysuj(pictureBox1, U, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton19.Checked = True Then
                n = 1
                TimeStep = SimTime / Steps
                q = 0
                For i As Integer = 0 To CInt(Steps - 1)
                    If i * TimeStep - q * uTime < uTime Then
                        If TimeStep * i - q * uTime < uTime / 2 Then
                            U(i) = uAmp
                        End If
                        If TimeStep * i - q * uTime > uTime / 2 And TimeStep * i - q * uTime < uTime Then
                            F(i) = 0
                        End If
                    Else
                        q = q + 1
                    End If
                Next i

                Rysuj(pictureBox1, U, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton20.Checked = True Then
                n = 1
                TimeStep = SimTime / Steps
                q = 0
                For i As Integer = 0 To CInt(Steps - 1)
                    If i * TimeStep - q * uTime < uTime Then
                        U(i) = uAmp * (i * TimeStep - q * uTime) / uTime
                    Else
                        U(i) = 0
                        q = q + 1
                    End If
                Next i

                Rysuj(pictureBox1, U, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton17.Checked = True Then
                n = 1
                TimeStep = SimTime / Steps
                'q = 0
                For i As Integer = 0 To CInt(Steps - 1)
                    U(i) = uAmp * Math.Sin(2 * Math.PI / uTime * i * TimeStep)
                Next i

                Rysuj(pictureBox1, U, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If RadioButton14.Checked = True Then
                n = 1
                TimeStep = SimTime / Steps
                'q = 0
                'Dim rnd As New Random
                For i As Integer = 0 To CInt(Steps - 1)
                    U(i) = Rnd()
                Next i

                H = U.Clone
                Array.Sort(H)
                Dim MaxArr As Double = H.GetValue(CInt(Steps - 1))

                For i As Integer = 0 To CInt(Steps - 1)
                    U(i) = (U(i) / MaxArr - 1 / 2) * 2 * uAmp
                Next i

                Rysuj(pictureBox1, U, H, CInt(Steps), TimeStep, SimTime, n, plik)
            End If

            If ListBox1.SelectedItem.Equals("RK") = True Then
                'MsgBox("RK")
                RK(F, U, Steps, SimTime, m1, m2, k1, k2, b1, b2, sx1, sx2, sv1, sv2, sv)
            ElseIf ListBox1.SelectedItem.Equals("Euler") = True Then
                'MsgBox("Euler")
                Euler(F, U, Steps, SimTime, m1, m2, k1, k2, b1, b2, sx1, sx2, sv1, sv2, sv)
            End If

            'Me.Invalidate()
            'picturebox1.Update()

            Dim Image1 As New Bitmap("F.bmp")
            Dim Image2 As New Bitmap("U.bmp")
            Dim Image3 As New Bitmap(600, 1000)
            Dim g As Graphics = Graphics.FromImage(Image3)

            g.DrawImage(Image1, New Point(0, 0))
            g.DrawImage(Image2, New Point(0, 0))
            g.Dispose()
            g = Nothing

            TabPage1.BackgroundImage = Image3

            Dim Image4 As New Bitmap("X1.bmp")
            Dim Image5 As New Bitmap("X2.bmp")
            Dim Image6 As New Bitmap(600, 1000)
            Dim l As Graphics = Graphics.FromImage(Image6)

            l.DrawImage(Image4, New Point(0, 0))
            l.DrawImage(Image5, New Point(0, 0))
            l.Dispose()
            l = Nothing

            TabPage2.BackgroundImage = Image6

            Dim Image7 As New Bitmap("V1.bmp")
            Dim Image8 As New Bitmap("V2.bmp")
            Dim Image9 As New Bitmap(600, 1000)
            Dim d As Graphics = Graphics.FromImage(Image9)

            d.DrawImage(Image7, New Point(0, 0))
            d.DrawImage(Image8, New Point(0, 0))
            d.Dispose()
            d = Nothing

            TabPage3.BackgroundImage = Image9


            'picturebox1.Refresh()
            'Dim fuckyou As Bitmap = picturebox1.Image
            'fuckyou.Save("as3.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
            'picturebox1.Image.Save("as4.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
            'picturebox1.Refresh()
            Me.Refresh()
        Else
            MsgBox("Prosze wprowadzic dane do kazdego pola")
        End If



    End Sub

    Private Sub txtFedDep_KeyDown7(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox7.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 45 Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown8(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox8.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown13(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox13.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown22(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox22.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown21(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox21.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown20(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox20.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 45 Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown19(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox19.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown18(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox18.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown17(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox17.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown16(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox16.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown15(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox15.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown14(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox14.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 45 Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown2(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 45 Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown3(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 45 Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown4(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 45 Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtFedDep_KeyDown5(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 45 Or Asc(e.KeyChar) = 44 Or Asc(e.KeyChar) = 8 Then
        Else
            e.Handled = True
        End If
    End Sub


    'Private Sub TP1Left(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabPage1.Leave
    '    pic1 = pictureBox1.Image
    'End Sub

    '    Private Sub TP2Left(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabPage2.Leave
    '       pic2 = pictureBox1.Image
    '  End Sub

    'Private Sub TP1Entered(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabPage1.Click
    'Dim bm As New Bitmap("F.bmp")
    'picturebox1.Image = System.Drawing.Bitmap.FromFile(My.Application.Info.DirectoryPath & "\F.bmp")
    'picturebox1.Image = Image.FromFile("F.bmp")
    'picturebox1.Refresh()

    'Dim Image1 As New Bitmap("F.bmp")
    'Dim Image2 As New Bitmap("U.bmp")
    'Dim Image3 As New Bitmap(600, 1000)
    'Dim g As Graphics = Graphics.FromImage(Image3)

    'g.DrawImage(Image1, New Point(0, 0))
    ' g.DrawImage(Image2, New Point(0, 0))
    '  g.Dispose()
    '   g = Nothing

    '    TabPage1.BackgroundImage = Image3
    ' End Sub

    'Private Sub TP2Entered(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabPage2.Enter
    ' Dim bm As New Bitmap("X1.bmp")
    '     pictureBox1.Image = bm
    '     pictureBox1.Invalidate()
    ' End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim newwin As Form
        newwin = New Form
        newwin.Height = 600
        newwin.Width = 1250
        newwin.Show()
        newwin.BackColor = Color.White

        Dim PctrBox1 As PictureBox
        PctrBox1 = New PictureBox
        Dim PctrBox2 As PictureBox
        PctrBox2 = New PictureBox

        Dim Image1 As New Bitmap("F.bmp")
        Dim Image2 As New Bitmap("U.bmp")
        Dim Image3 As New Bitmap("X1.bmp")
        Dim Image4 As New Bitmap("X2.bmp")
        Dim Image5 As New Bitmap(600, 1000)
        Dim Image6 As New Bitmap(600, 1000)

        Dim g As Graphics = Graphics.FromImage(Image5)
        Dim i As Graphics = Graphics.FromImage(Image6)

        newwin.Controls.Add(PctrBox2)
        PctrBox2.Dock = DockStyle.Right
        PctrBox2.Height = 800
        PctrBox2.Width = 600
        newwin.Controls.Add(PctrBox1)
        PctrBox1.Dock = DockStyle.Left
        PctrBox1.Height = 800
        PctrBox1.Width = 600

        g.DrawImage(Image1, 0, 0)
        g.DrawImage(Image2, 0, 0)
        PctrBox1.Image = Image5

        i.DrawImage(Image3, 0, 0)
        i.DrawImage(Image4, 0, 0)
        PctrBox2.Image = Image6
        'g.DrawImage(Image1, New Point(0, 0))
        'g.DrawImage(Image2, New Point(0, 0))
        'g.DrawImage(Image3, New Point(600, 0))
        'g.DrawImage(Image4, New Point(600, 0))
        g.Dispose()
        g = Nothing

        'newwin.BackgroundImage = image5

    End Sub
End Class