Results 1 to 6 of 6

Thread: axes

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    49

    axes

    How can I draw simple X and Y axes?
    And how can I set my point 0 on another place?
    Could someone give me the codes for it?
    thx

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: axes

    Quote Originally Posted by Gleba
    How can I draw simple X and Y axes?
    And how can I set my point 0 on another place?
    Could someone give me the codes for it?
    thx
    Hi,

    Here's a link about the X and Y axes;

    http://msdn.microsoft.com/library/de...transforms.asp

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    49

    Re: axes

    if i use this code
    Private Sub YGrid _
    (ByVal GridColor As Color, ByVal AxisColor As Color, _
    ByVal LabelColor As Color, ByVal LineWidth As Double)

    Dim lLine As GraphicsPath
    Dim lGridPen As New Pen(GridColor, LineWidth / 4.0)
    Dim lAxisPen As New Pen(AxisColor, LineWidth)

    For Each i As Integer In AxisPoints(mMinY, mMaxY)
    lLine = New GraphicsPath
    lLine.AddLine(New PointF(mMinX, i), New PointF(mMaxX, i))
    If i = 0 Then
    mGraphics.DrawPath(lAxisPen, lLine)
    Else
    mGraphics.DrawPath(lGridPen, lLine)
    End If
    DrawString(i.ToString, New PointF(0, i), LabelColor)
    Next i

    End Sub

    i can't get it to work, I don't know where to put it in. Do I need to put it in the sub form or what? I don't know.

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: axes

    any code to draw on a form should be done in the forms paint event.

    you can draw on the form in any routine by creating a graphics object from the form class like this..

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim G As Graphics = Me.CreateGraphics
    3.         G.DrawString("HELLO WORLD", Me.Font, Brushes.Black, 0, 0)
    4.         G.Dispose()
    5.     End Sub

    However as soon as your form is repainted (minimized and the restored, moved off screen then back on, or another window comes on top of the apps window), the string that was drawn will be gone.

    If you put the drawing code in the forms paint event, it will be drawn everytime the form is repainted.

    Also in the forms paint event, you can use e.Graphics that is passed in as a parameter, instead of using Me.CreateGraphics.

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    49

    Re: axes

    thx, but i still don't know how i can use this code.


    Private Sub YGrid _
    (ByVal GridColor As Color, ByVal AxisColor As Color, _
    ByVal LabelColor As Color, ByVal LineWidth As Double)

    Dim lLine As GraphicsPath
    Dim lGridPen As New Pen(GridColor, LineWidth / 4.0)
    Dim lAxisPen As New Pen(AxisColor, LineWidth)

    For Each i As Integer In AxisPoints(mMinY, mMaxY)
    lLine = New GraphicsPath
    lLine.AddLine(New PointF(mMinX, i), New PointF(mMaxX, i))
    If i = 0 Then
    mGraphics.DrawPath(lAxisPen, lLine)
    Else
    mGraphics.DrawPath(lGridPen, lLine)
    End If
    DrawString(i.ToString, New PointF(0, i), LabelColor)
    Next i

    End Sub


    You see I'm trying to draw the x and y axe and maybe the z axe to. But I would like to do it in a picturebox.
    Also I would like that i can change the point(0,0) in the center of the picture box.

  6. #6
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: axes

    From what I understand, would I be correct in saying that you have no idea what that code actually does that you are using?

    If so, you really must start with the basics of what and how to draw simple stuff, like lines, circles etc. Learn what the objects do, learn how to call them, learn how to change them.

    If you have already done this, then ignore me .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width