none
How to trigger the Drawing process of a Picturebox by a button? RRS feed

  • Question

  • Hi,

    The great .net master tommytwotrain here has told me to use the paint event to handle the drawing. But the example he had shown me is too advanced for me to understand at this moment.

    So I open another post to ask. Because the original posts have already marked as an answer and I don't want to make them too long to avoid confusing other people. 

    I've written some simple codes to test it myself. He has mentioned to me that in order to make the drawing persisting within the Picturebox, I should do it by using the paint event. I found it is definitely true but have no idea how to do if I want to trigger the drawing process by a button instead.

    Here's the code:

    This is an example to draw by normal way. It works perfect and the drawing is persistent no matter you resize the form or cover by another form.

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Public Class Form1
        Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
            Dim rect1 As New Rectangle(20, 10, 100, 100)
            Dim rect2 As New Rectangle(120, 10, 100, 100)
            Dim rect3 As New Rectangle(20, 110, 100, 100)
            Dim rect4 As New Rectangle(120, 110, 100, 100)

            Dim Brush1 As SolidBrush = New SolidBrush(Color.Beige)
            Dim Brush2 As SolidBrush = New SolidBrush(Color.Blue)
            Dim Brush3 As SolidBrush = New SolidBrush(Color.Red)
            Dim Brush4 As SolidBrush = New SolidBrush(Color.Yellow)

            e.Graphics.FillRectangle(Brush1, rect1)
            e.Graphics.FillRectangle(Brush2, rect2)
            e.Graphics.FillRectangle(Brush3, rect3)
            e.Graphics.FillRectangle(Brush4, rect4)
        End Sub

      ++++++++++++++++++++++++++++++++++++++++++++

    But, the problem is that if I do not want the program to draw at the beginning. I want to trigger the process by a button or other event instead. If I change the code like this:

    +++++++++++++++++++++++++++++++++++++++++++++

    Imports System.Drawing.Drawing2D
    Public Class Form1
       Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim MyGraphics As Graphics = PictureBox1.CreateGraphics
            Dim rect1 As New Rectangle(20, 10, 100, 100)
            Dim rect2 As New Rectangle(120, 10, 100, 100)
            Dim rect3 As New Rectangle(20, 110, 100, 100)
            Dim rect4 As New Rectangle(120, 110, 100, 100)

            Dim Brush1 As SolidBrush = New SolidBrush(Color.Beige)
            Dim Brush2 As SolidBrush = New SolidBrush(Color.Blue)
            Dim Brush3 As SolidBrush = New SolidBrush(Color.Red)
            Dim Brush4 As SolidBrush = New SolidBrush(Color.Yellow)

            MyGraphics.FillRectangle(Brush1, rect1)
            MyGraphics.FillRectangle(Brush2, rect2)
            MyGraphics.FillRectangle(Brush3, rect3)
            MyGraphics.FillRectangle(Brush4, rect4)
        End Sub
    End Class

    ++++++++++++++++++++++++++++++++++++++++++++++

    It is triggered by the click button. But the drawing is not persistent because it will gone if I resize the form.

    I think it should be something like calling the paint event within the button click event. But I just don't know what value to pass in. 

    Can anyone tell me how to handle this? Or, if Tommy himself has seen this post and if it is not too bother him, please kindly help again. 

    BTW, I am not a student. Not even in the IT field. Currently I just want to learn .net for my own interest. So, please feel free to shown me the sample code if you have. And don't worry about the lecture assignment or cheating things. It does not apply to me. I am far to old to be a student:) I just want to learn the .net GDI thing myself.

    Thanks.

    Jason

    Tuesday, August 21, 2018 9:29 AM

Answers

  • Hi,

    try the code:

    Imports System.Drawing.Drawing2D
    Public Class Form1
        Dim b As Boolean = False
        Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
            If b = False Then Return
            Dim rect1 As New Rectangle(20, 10, 100, 100)
            Dim rect2 As New Rectangle(120, 10, 100, 100)
            Dim rect3 As New Rectangle(20, 110, 100, 100)
            Dim rect4 As New Rectangle(120, 110, 100, 100)
    
            Dim Brush1 As SolidBrush = New SolidBrush(Color.Beige)
            Dim Brush2 As SolidBrush = New SolidBrush(Color.Blue)
            Dim Brush3 As SolidBrush = New SolidBrush(Color.Red)
            Dim Brush4 As SolidBrush = New SolidBrush(Color.Yellow)
    
            e.Graphics.FillRectangle(Brush1, rect1)
            e.Graphics.FillRectangle(Brush2, rect2)
            e.Graphics.FillRectangle(Brush3, rect3)
            e.Graphics.FillRectangle(Brush4, rect4)
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            b = True
            PictureBox1.Refresh()
        End Sub
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by tommytwotrain Tuesday, August 21, 2018 11:48 AM
    • Marked as answer by jasonfan2000 Tuesday, August 21, 2018 3:27 PM
    Tuesday, August 21, 2018 9:51 AM

All replies

  • Hi,

    try the code:

    Imports System.Drawing.Drawing2D
    Public Class Form1
        Dim b As Boolean = False
        Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
            If b = False Then Return
            Dim rect1 As New Rectangle(20, 10, 100, 100)
            Dim rect2 As New Rectangle(120, 10, 100, 100)
            Dim rect3 As New Rectangle(20, 110, 100, 100)
            Dim rect4 As New Rectangle(120, 110, 100, 100)
    
            Dim Brush1 As SolidBrush = New SolidBrush(Color.Beige)
            Dim Brush2 As SolidBrush = New SolidBrush(Color.Blue)
            Dim Brush3 As SolidBrush = New SolidBrush(Color.Red)
            Dim Brush4 As SolidBrush = New SolidBrush(Color.Yellow)
    
            e.Graphics.FillRectangle(Brush1, rect1)
            e.Graphics.FillRectangle(Brush2, rect2)
            e.Graphics.FillRectangle(Brush3, rect3)
            e.Graphics.FillRectangle(Brush4, rect4)
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            b = True
            PictureBox1.Refresh()
        End Sub
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by tommytwotrain Tuesday, August 21, 2018 11:48 AM
    • Marked as answer by jasonfan2000 Tuesday, August 21, 2018 3:27 PM
    Tuesday, August 21, 2018 9:51 AM
  • Alex's example is one way. See the .refresh in the button click? That will make the paint event fire at that statement, run the code in the paint event, then return to the button click next line statement. If you use .invalidate then the paint event will fire when the system is ready. Not quite the same. For now you can use refresh but if you get a large drawing eventually you should use the .invalidate. This minimizes the drawing time and can be explained later.

    You don't need the b = true flag for the example but it shows how to specifiy different types of drawng. For example if b = true then draw the tracer from the mouse move event.

    Put a break point on the .refresh statement and then watch where the code executes, the next statement will go to the paint event.

    Keep in mind its not that it all makes perfect logical sense to you, its that it makes sense to vb. This is how vb.net works. Do it this way and save a lot of headaches down the line.

    The other option instead of using the paint event all the time is draw on a memory bitmap and put that in the picturebox.image property or draw the bitmap on the e.graphics in the paint event. That will persist the image too as the bitmap remains in memory after you draw on it but its more work. The paint event e.graphics is cleared each time the paint event is called.

    I just want to point out now that you need to make a data file to save your drawing with? To do that you should make a list of rectangles (later a list of other objects too by using a class) and then draw that list of rects in a loop in the paint event rather than a separated statement for each line.

    In this example see all the pic1.invalidates in each mouse event. So you draw a line, update the screen, move the mouse with a line tracer, update the screen. Move the form border update the screen... that is event driven object oriented programing.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/a95ea88e-588f-47c0-b8bc-a3a9fe8a7469/how-to-draw-to-scale-cad-with-gdi-and-vbnet?forum=vbgeneral

    It may seem like your astro program is not a cad program but you should still draw this way I believe. The CAD example has all the mouse events for the user to draw on the drawing, select objects, etc. I don't know if you will have that in your program but you should still draw with this basic structure. I worked it out to be simple. It has draw grid, select objects, rounding scales, mouse wheel zooming on the mouse pointer, dragging the screen (scrolling) with the mouse and just a lot of things you will eventually want all worked out to work.

    You could probably replace what you have with this CAD example and start over adding to the cad example but I guess you will be stubborn and try to learn how to do it using your old backwards vb6 way which is fine. Once you bang your head enough with that you will then understand why this way I show you is better.

    :)




    Tuesday, August 21, 2018 12:06 PM
  • PS Here I added a sub routine in Alex's example3 to the paint event to draw the rects. See how the e.graphics is passed to the sub?

    Eventually you can have subs for each type object you want to draw. This one is passed e.graphics from the paint event but that could also be a bitmap's create graphics called from the button click etc if your app needs that.

    Public Class Form5
        Dim b As Boolean = False
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            b = True
            PictureBox1.Refresh()
        End Sub
    
        Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
            If b Then DrawRectangles(e.Graphics)
        End Sub
    
        Private Sub DrawRectangles(g As Graphics)
    
            With g
                Dim rect1 As New Rectangle(20, 10, 100, 100)
                Dim rect2 As New Rectangle(120, 10, 100, 100)
                Dim rect3 As New Rectangle(20, 110, 100, 100)
                Dim rect4 As New Rectangle(120, 110, 100, 100)
    
                Dim Brush1 As SolidBrush = New SolidBrush(Color.Beige)
                Dim Brush2 As SolidBrush = New SolidBrush(Color.Blue)
                Dim Brush3 As SolidBrush = New SolidBrush(Color.Red)
                Dim Brush4 As SolidBrush = New SolidBrush(Color.Yellow)
    
                .FillRectangle(Brush1, rect1)
                .FillRectangle(Brush2, rect2)
                .FillRectangle(Brush3, rect3)
                .FillRectangle(Brush4, rect4)
    
            End With
        End Sub
    End Class

    Tuesday, August 21, 2018 1:00 PM
  • Hi, Both

    I'd like to thank for Alex's quick reply first. He has given me a simple and straight forward solution. I finally understand what the command Picturebox.Refresh does.
    So, I'd like to mark Alex's as the Right Answer this time although both of you have kindly given me the solutions. I believe Tommy wouldn't mind. He is really the great master of vb.net.

    In fact, Tommy has provided an advanced and better solutions.

    With Tommy's explanation, I have come up with the following testing codes by adding more to Tommy's example. I've found it works.

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Public Class Form1
        Dim b As Boolean = False
        Dim DrawType As Integer = 0

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            b = True
            DrawType = 1
            PictureBox1.Refresh()
        End Sub

        Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
            If b Then
                Select Case DrawType
                    Case 1
                        DrawRectangles(e.Graphics)
                    Case 2
                        DrawArcs(e.Graphics)
                End Select
            End If
        End Sub

        Private Sub DrawRectangles(g As Graphics)

            With g
                Dim rect1 As New Rectangle(20, 10, 100, 100)
                Dim rect2 As New Rectangle(120, 10, 100, 100)
                Dim rect3 As New Rectangle(20, 110, 100, 100)
                Dim rect4 As New Rectangle(120, 110, 100, 100)

                Dim Brush1 As SolidBrush = New SolidBrush(Color.Beige)
                Dim Brush2 As SolidBrush = New SolidBrush(Color.Blue)
                Dim Brush3 As SolidBrush = New SolidBrush(Color.Red)
                Dim Brush4 As SolidBrush = New SolidBrush(Color.Yellow)

                .FillRectangle(Brush1, rect1)
                .FillRectangle(Brush2, rect2)
                .FillRectangle(Brush3, rect3)
                .FillRectangle(Brush4, rect4)

            End With
        End Sub

        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            b = True
            DrawType = 2
            PictureBox1.Refresh()
        End Sub
        Private Sub DrawArcs(g As Graphics)

            With g
                Dim MyPen As New Pen(Color.Black, 1)
                Dim Rect As Rectangle
                Dim Xaxis As Integer = 10
                Dim Yaxis As Integer = 10
                Dim Width As Integer = 40
                Dim Height As Integer = 40
                Dim startAngle As Single = 0
                Dim sweepAngle As Single = -180

                For I As Integer = 1 To 20
                    Rect = New Rectangle(Xaxis + I, Yaxis + I, Width + (I * 15), Height + (I * 15))

                    .DrawArc(MyPen, Rect, startAngle, sweepAngle)

                Next

            End With
        End Sub
    End Class

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Please correct me if the above codes are not properly written.

    What I've tried to do here is to separate the drawing logic or calculations from Picturebox1_paint event. The purpose is to minimize the length of this single event when I have more logics calculations to handle before the drawing is done.

    I have mentioned the CAD example of Tommy's is too advanced for me to understand. Because it only shown me a fixed picture after I've done 2 things:

    1) changed the picture path to f:\temp\rabbits.jpg

    2) make sure the form's name are Form2 as it is written in the code.

    When I click the mouse and drag it, the picture won't move. It just fixed there. I'm not sure whether it is due to the version of my Visual Studio or not. Mine is the newest 2017 version.

    Perhaps I've mentioned before. I'm curious to know how to make a drawing though vb.net and more the drawing with mouse. Like this kind:

    Tuesday, August 21, 2018 3:22 PM
  • When the drawing is clicked and drag by mouse, the location of the drawing should move. It finally should look like this:

    I'm very interested to know how this can be done in vb .net. :)

    Best Regards,

    Jason

    Tuesday, August 21, 2018 3:25 PM
  • Jason,

    "I have mentioned the CAD example of Tommy's is too advanced for me to understand. Because it only shown me a fixed picture after I've done 2 things:"

    The examples are just examples. The cad example does not do anything else other than what is described. It is a shell.

    The cad example description said LMB to drag drawing but that should be RMB (I have corrected the example). LMB draws and moves the fence rectangle (after you draw one) and handles.

    So drag the RMB in the picturebox of the cad example and the whole drawing will scroll grid, picture etc.


    The cad example does not move the pic as is right now. Just the selectable rectangle fence  moves and resizes in the cad example. Plus zoom, scroll etc.

    If you dont get the cad example then skip it for now and stay with what you have.

    I dont know what you plan on drawing? So that will affect how you draw. Maybe you don't need the mouse events from the cad example.

    Anyhow, that example is maybe too much at once. Maybe learn mouse events with at this example first:


    https://social.msdn.microsoft.com/Forums/vstudio/en-US/31e42fd8-8a0f-4239-9a94-0e065febe28a/create-dyamically-resizable-lineshape-winforms?forum=vbgeneral


    See how in the mouse down event the click point location is saved as MouseDownPt. Then in the mouse move event the second point for the line is set and and then Invalidate statment fires the paint event and the line is drawn for the two sets of endpoints.

    All the line example doe is draw the line nothing else.

    So there is a whole bunch of drawing info we gave you and now you need to sort through it and learn what you can. Then decide what to do next. Exactly what do you plan on doing ? Move images or draw lines or both?

    "When the drawing is clicked and drag by mouse, the location of the drawing should move. It finally should look like this:

    I'm very interested to know how this can be done in vb .net. :)"

    The cad example does it now. Drag the entire drawing with the RMB. Look at the gif animation in the cad example. see the drawing screen (with image and grid) dragging and resizing?

    To move the image on the drawing is not implemented in the cad example. The cad example just has the fence rect.


    Tuesday, August 21, 2018 5:10 PM
  • Hi, Tommy

    Thank you for your reply and advise again. 

    Jason

    Wednesday, August 22, 2018 3:34 AM
  • BTW, Tommy

    What I'm trying to say is that your cad example does not work on my Visual Studio 2017. I don't know what reason. It is too advanced for me to fix it. So, I am not be able to see how the picture is zoom or move by mouse. The picture just stays there and not zoom out or zoom in. Like the screen cap that I've shown you above.

    I've added the line at the beginning of your codes:

    Imports System.Drawing.Drawing2D

    But, as I can imagine, it won't work and it has nothing to deal with it.

    I don't know how the program result look like in your machine and what line I should add in order to see it run:)

    Are you sure there's no additonal plug-in I need to install or package to pre-install before run your code? I saw your original code post and no one has ever left a message to say anything. I believe it should be a very good example. Do you think other people also found the same issue?

    Jason

    Wednesday, August 22, 2018 5:44 AM
  • BTW, Tommy

    What I'm trying to say is that your cad example does not work on my Visual Studio 2017. I don't know what reason. It is too advanced for me to fix it. So, I am not be able to see how the picture is zoom or move by mouse. The picture just stays there and not zoom out or zoom in. Like the screen cap that I've shown you above.

    I've added the line at the beginning of your codes:

    Imports System.Drawing.Drawing2D

    But, as I can imagine, it won't work and it has nothing to deal with it.

    I don't know how the program result look like in your machine and what line I should add in order to see it run:)

    Are you sure there's no additonal plug-in I need to install or package to pre-install before run your code? I saw your original code post and no one has ever left a message to say anything. I believe it should be a very good example. Do you think other people also found the same issue?

    Jason


    Which example are you talking about?

    This CAD example from the link below?

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/a95ea88e-588f-47c0-b8bc-a3a9fe8a7469/how-to-draw-to-scale-cad-with-gdi-and-vbnet?forum=vbgeneral

    I just copied it into a new form in a test project and it works for me.

    What do you mean it does not work? What does not work? What are you doing that does not work? Do you get an error?

    You will have to describe what "does not work" means or I cant help you. You will have to describe it so that I can reproduce whatever it is or I cant help. Try to describe exactly what you are doing.

    PS Alex or anyone else try the CAD example?

    Jason, did you try the line example I posted the link to above? Here it is again:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/31e42fd8-8a0f-4239-9a94-0e065febe28a/create-dyamically-resizable-lineshape-winforms?forum=vbgeneral


    Wednesday, August 22, 2018 11:25 AM
  • Which example are you talking about?

    This CAD example from the link below?

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/a95ea88e-588f-47c0-b8bc-a3a9fe8a7469/how-to-draw-to-scale-cad-with-gdi-and-vbnet?forum=vbgeneral

    Exactly, that's the one I'm talking about.

    No error. I just copied your whole codes and paste to a new form and new project.

    Then 1)change the Form1 name to Form2 as you did in your code.

    2)change the path to f:\temp\rabbits.jpg

    The above is the result I've got. But when I use the mouse to click the picture, nothing change. It is not like the picture that you've paste here. Not allow me to zoom in or zoom out.

    It just deadly place there:)

    Did I missed anything to make it work?

    I haven't got a time to try the line example you've shown me. I will try it later on. I know it will be very useful for learning GDI thing. But I also like to see this CAD example work if possible. I believe it is well written.

    Unfortunately, I can't make it work:) Anyway, thank you very much for your reply and help.

    Jason

    Wednesday, August 22, 2018 12:08 PM
  • Which example are you talking about?

    This CAD example from the link below?

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/a95ea88e-588f-47c0-b8bc-a3a9fe8a7469/how-to-draw-to-scale-cad-with-gdi-and-vbnet?forum=vbgeneral

    Exactly, that's the one I'm talking about.

    No error. I just copied your whole codes and paste to a new form and new project.

    Then 1)change the Form1 name to Form2 as you did in your code.

    2)change the path to f:\temp\rabbits.jpg

    The above is the result I've got. But when I use the mouse to click the picture, nothing change. It is not like the picture that you've paste here. Not allow me to zoom in or zoom out.

    It just deadly place there:)

    Did I missed anything to make it work?

    I haven't got a time to try the line example you've shown me. I will try it later on. I know it will be very useful for learning GDI thing. But I also like to see this CAD example work if possible. I believe it is well written.

    Unfortunately, I can't make it work:) Anyway, thank you very much for your reply and help.

    Jason

    Jason,

    "Then 1)change the Form1 name to Form2 as you did in your code."

    Why form2? Is that the form in your project? If you make a new project then the startup form is form1. So you would paste the example code to form1 in your project.

    But I guess the way you did is ok since it runs. I guess form2 in your test project is the startup form (was form 1)?

    My form2 in the cad example was just the name I had in my project. You can change it to anything. Form2 was in a test project and I just opened it from form1 the startup form. So you must not understand that fully?

    But since it runs you are ok.

    "The above is the result I've got. But when I use the mouse to click the picture, nothing change. "

    Where does it say click the mouse on the picture and move it?

    I just told you in my previous post the picture does not move on the drawing. But the whole drawing - grid and picture image, will move ( scroll) by dragging the drawing view port with the RIGHT MOUSE BUTTON (rmb). Did you do that? Drag the rmb on the screen?


    "It is not like the picture that you've paste here.

    What is not like the picture here? What picture I pasted here? The dog? And you replaced it with a bunny?


    " Not allow me to zoom in or zoom out."

    What are you doing to zoom?

    Did you try to run the line drawing example? Try that.

    Well it gets very hard to do this with forum texting. We must be very clear and meticulous.

    But you should be able to learn how to add a form example to your project.

    Lets drop the cad example for now and practice making a form and copying the code example into the form.

    Try making the line drawing example:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/31e42fd8-8a0f-4239-9a94-0e065febe28a/create-dyamically-resizable-lineshape-winforms?forum=vbgeneral

    1. Make a new windows forms test project and call the project test1 or something.

    2. Make a new windows form in the test project, the new form will be named form 2 automatically by visual studio.

    3. Cut and paste the line draw example into the form2 in your project. It just happens the example is already named form2 (if it had any other name you would just change the example form name to your whatever your form name is).

    In the form load of form1 in your test project start form 2 with form2.show() .

    You could just paste the code into form1. I am just showing you how to do a test project and have many forms in the project. One form for each example.

    Save and then run the line drawing example project. Now draw a line with the example.

    Comprende?

    If not I think you need to brush up on how to make a project and add forms to it and paste code into it with visual studio?

    Don't go getting discouraged. It is hard to learn. One little mistake or misunderstanding and it "wont work" and then gets frustrating. Do you have a relative or neighbor friend that is experienced with computers? Maybe they can spot the mistake one is stuck on?

    But I think the cad example is working for you. You just don't understand what it does.

    :)





    Wednesday, August 22, 2018 12:41 PM
  • Hi, Tommy

    I see what happen now. Sorry I've misunderstand your words. It is the RIGHT mouse do the whole thing. Not the left mouse.

    Now, I can see what the program does. Splendid!

    Thanks,

    Jason


    Wednesday, August 22, 2018 1:41 PM
  • Hi, Tommy

    I see what happen now. Sorry I've misunderstand your words. It is the RIGHT mouse do the whole thing. Not the left mouse.

    Now, I can see what the program does. Splendid!

    Thanks,

    Jason


    Oh that's good.

    And the LMB drag makes the selection fence rectangle. And lmb to drag the fence rect and or handle.

    So see how you move and resize the selection fence on the drawing? You could move the image the same way its just not in the example.

    And Mouse Wheel to zoom.

    Try the line drawing example too even first.

    Just add another form to your test project. It might be form3. And cut and paste the code for the line draw example into your form3. Then add Form3.Show() in the test project startup form load event.


    PS Finally if you really want to understand the two examples now add line drawing to the cad example. You will need to make a toolbar with a button (or whatever) for draw line.

    Again, only if you think you need it for your astro app.

    Or if you want to learn to draw.


    Wednesday, August 22, 2018 1:47 PM