Author Topic: Help with GDI+  (Read 1489 times)

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Help with GDI+
« on: January 30, 2020, 09:51:52 AM »
Hi..

I've been stuck Please help me.

My project contains a recipe where there are parameters

1. Line length
2. Angle
3. Direction

Every recipe has maximum 10 steps. Every time an length is written the program draws the line and every time an angle and direction is introduced the x,y co-ordinate will draw a line at the given angle, in a given direction, at a given length from the point where the last drawn line has finished.

Now the problem is I'm able to do all the things and draw but certain times my lines go out of the control{Picture Box}.

I hope some one here might help me with this.

profnova

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Help with GDI+
« Reply #1 on: January 30, 2020, 10:15:13 AM »
You should post your code. There is probably some scaling issue.

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: Help with GDI+
« Reply #2 on: January 30, 2020, 11:35:58 AM »
Code: [Select]
   
Private Sub DrawLines(ByVal lngth As Single)
        Dim objPen As Pen
        Dim objPicGraphics As Graphics = Graphics.FromHwnd(hwnd:=PaintBox().Handle)
        objPen = New Pen(Drawing.Color.Black, 1.5F)
        objPen.DashStyle = Drawing2D.DashStyle.Solid

        WidthLen = CInt((PaintBox.Width - leftPad - RightPad) / 8)

        objPicGraphics.PageUnit = GraphicsUnit.Millimeter
        objPen.LineJoin = Drawing.Drawing2D.LineJoin.Round

        Dim angleRadians As Double = (Math.PI / 180.0) * angle

        Dim a As New PointF(4, 100)
        Dim b As New PointF(lngth, 100)

        objPicGraphics.DrawLine(objPen, a, b)

    End Sub