Quote Originally Posted by .paul. View Post
using that link for the example, try this:

vb Code:
  1. Public Class Form1
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         PictureBox1.Invalidate()
  5.     End Sub
  6.  
  7.     Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
  8.         Dim pn As New Pen(Color.Blue)
  9.  
  10.         Dim pt1 As New Point(30, 30)
  11.         Dim pt2 As New Point(110, 100)
  12.         Dim pts As Point() = {pt1, pt2}
  13.         'Stop
  14.         Project(pts, PictureBox1.Width, PictureBox1.Height)
  15.         e.Graphics.DrawLines(pn, pts)
  16.  
  17.         ' Create a pen with red color and width 3
  18.         Dim redPen As New Pen(Color.Red, 3)
  19.         ' Create an array of points
  20.         Dim ptsArray() As Point = {New Point(10, 20), New Point(50, 40), New Point(220, 120), New Point(120, 20)}
  21.  
  22.         Project(ptsArray, PictureBox1.Width, PictureBox1.Height)
  23.         e.Graphics.DrawLines(redPen, ptsArray)
  24.  
  25.     End Sub
  26.  
  27.     Public Sub Project(ByRef p() As Point, ByVal viewWidth As Integer, ByVal viewHeight As Integer)
  28.  
  29.         Dim MinX As Integer = p.Min(Function(pt) pt.X)
  30.         Dim MaxX As Integer = p.Max(Function(pt) pt.X)
  31.  
  32.         Dim MinY As Integer = p.Min(Function(pt) pt.Y)
  33.         Dim MaxY As Integer = p.Max(Function(pt) pt.Y)
  34.  
  35.         Dim leftOffset As Integer = (viewWidth - (MaxX - MinX)) \ 2
  36.         Dim topOffset As Integer = (viewHeight - (MaxY - MinY)) \ 2
  37.  
  38.         For x As Integer = 0 To p.GetUpperBound(0)
  39.             p(x) = New Point(p(x).X + leftOffset, p(x).Y + topOffset)
  40.         Next
  41.  
  42.     End Sub
  43.  
  44.     Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
  45.         PictureBox1.Invalidate()
  46.     End Sub
  47.  
  48. End Class
woooooooooow, awesome, awesome & Awesome! Works Perfect, just what I needed (with the correction on the second post, ofc). Thank you sooooooooooooooooo muchhhhhhhhhh! Can finally present the project to my teacher, the cherry above the cake is finally put!