Hey ho,
hab da ein kleines Problem.
Ich will Stützpunkte einzeichnen, Aber irgentwie wandern mir die teile immer weg
Denke mal das es ein mathematisches Problem ist welches ich einfach nicht erkenne..
Hier der Quellcode der das ganze machen soll:
Ist nicht perfect und sicher unnötige Sachen drin usw. ist ja auch noch nicht fertig, von daher bitte nur auf das Problem und nicht auf die schönheit eingehen
Anbei noch ein Bild was dabei ensteht. Hoffe das reicht an Infos und Quellcode sonst meckert halt
hab da ein kleines Problem.
Ich will Stützpunkte einzeichnen, Aber irgentwie wandern mir die teile immer weg
Denke mal das es ein mathematisches Problem ist welches ich einfach nicht erkenne..
Hier der Quellcode der das ganze machen soll:
VB.NET-Quellcode
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- For iwiw = 1 To 10
- DataGridView1.Rows.Add()
- DataGridView1.Rows(iwiw - 1).Cells(0).Value = iwiw
- DataGridView1.Rows(iwiw - 1).Cells(1).Value = iwiw ^ 2
- Next
- Me.Refresh()
- If DataGridView1.RowCount > 1 Then
- Draw(DataGridView1.RowCount)
- End If
- End Sub
- Private Sub Draw(ByVal Stützpunkte As Integer)
- imagee = New Bitmap(PictureBox1.Width, PictureBox1.Height)
- Dim peon As New Pen(Brushes.Firebrick, 1)
- PenBlue.Width = 2
- gr = Graphics.FromImage(imagee)
- gr.DrawImage(imagee, 0, 0, imagee.Width, imagee.Height)
- gr.Clear(PictureBox1.BackColor)
- gr.FillRectangle(Brushes.WhiteSmoke, MainForm.ClientRectangle)
- gr.DrawRectangle(peon, 0, 0, PictureBox1.Size.Width - 1, PictureBox1.Size.Height - 1)
- Dim X As Double = 54
- Dim i2 As Integer = 0
- For j = DataGridView1.Rows.Count - 2 To 0 Step -1
- Wertex(9 - j) = Convert.ToDouble(VB.Replace(DataGridView1.Rows(j).Cells(0).Value.ToString, ".", ","))
- Wertey(9 - j) = Convert.ToDouble(VB.Replace(DataGridView1.Rows(j).Cells(1).Value.ToString, ".", ","))
- Next
- While i2 < 10
- gr.DrawString(Wertex(9 - i2).ToString, f, pinsel, New Point(Convert.ToInt32(X) - 34, PictureBox1.Height - 25))
- gr.DrawLine(Pens.Blue, New Point(Convert.ToInt32(X), PictureBox1.Height - 30), New Point(Convert.ToInt32(X), 1))
- i2 += 1
- X += (PictureBox1.Size.Width - 56) / 9
- End While
- X = PictureBox1.Size.Height - 2 - 50
- i2 = 0
- While i2 < 10
- gr.DrawString(Wertey(9 - i2).ToString, f, pinsel, New Point(5, Convert.ToInt32(X) - 17))
- gr.DrawLine(Pens.Blue, New Point(10, Convert.ToInt32(X)), New Point(PictureBox1.Width - 2, Convert.ToInt32(X)))
- i2 += 1
- X -= (PictureBox1.Size.Height - 80) / 9
- End While
- Dim Y As Double
- For i = 0 To 9
- X = ((Wertex(i) - Wertex(9)) / (Wertex(0) - Wertex(9))) * (PictureBox1.Width - 56)
- Y = ((Wertey(i) - Wertey(9)) / (Wertey(0) - Wertey(9))) * (PictureBox1.Height - 80)
- gr.DrawLine(Pens.Red, Convert.ToInt32(X) + 54, (PictureBox1.Height - 52) - Convert.ToInt32(Y) + 2, Convert.ToInt32(X) + 50, (PictureBox1.Height - 52) - (Convert.ToInt32(Y) + 3))
- Next
- imagee.Save(My.Application.Info.DirectoryPath & "\Temp.png", System.Drawing.Imaging.ImageFormat.Png)
- PictureBox1.Image = imagee
- End Sub
Ist nicht perfect und sicher unnötige Sachen drin usw. ist ja auch noch nicht fertig, von daher bitte nur auf das Problem und nicht auf die schönheit eingehen
Anbei noch ein Bild was dabei ensteht. Hoffe das reicht an Infos und Quellcode sonst meckert halt