Click here to Skip to main content
15,911,132 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to draw lines then undo ??? Pin
Ray Guan20-Jun-05 15:29
Ray Guan20-Jun-05 15:29 
GeneralRe: How to draw lines then undo ??? Pin
Christian Graus20-Jun-05 15:41
protectorChristian Graus20-Jun-05 15:41 
GeneralRe: How to draw lines then undo ??? Pin
Ray Guan20-Jun-05 15:18
Ray Guan20-Jun-05 15:18 
GeneralRe: How to draw lines then undo ??? Pin
Christian Graus20-Jun-05 15:24
protectorChristian Graus20-Jun-05 15:24 
GeneralRe: How to draw lines then undo ??? Pin
Ray Guan20-Jun-05 15:40
Ray Guan20-Jun-05 15:40 
GeneralRe: How to draw lines then undo ??? Pin
Christian Graus20-Jun-05 15:47
protectorChristian Graus20-Jun-05 15:47 
GeneralRe: How to draw lines then undo ??? Pin
lespaul3620-Jun-05 19:10
lespaul3620-Jun-05 19:10 
GeneralRe: How to draw lines then undo ??? Pin
T-Smooth21-Jun-05 2:01
T-Smooth21-Jun-05 2:01 
I think what you are looking for is the GraphicsPath object from GDI+. I just recently had to use this and read up on it but I am by no means an expert with it. I did however throw together a quick example in a couple min. to show you how you can use this to draw lines, select them, and then get rid of them. A quick disclaimer first: Being that i did this quick at work, the collection of GraphicsPath objects continously grows... the current implementation never gets rid of the objects, just resets their points to basically have them draw nothing. This should definitely be changed. For additional information, read up on GraphicsPath on MSDN.

<br />
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown<br />
        Dim oGP As GraphicsPath<br />
<br />
        ' Loop through the collection of lines to see if we clicked on one.<br />
        For Each oGP In LineCollection<br />
            ' The following IF returns true if the line was clicked on, the trigonometry is done for you :)<br />
            If oGP.IsOutlineVisible(e.X, e.Y, New Pen(Color.Black)) Then<br />
                oGP.Reset() ' Should remove the line from the collection or do something different here!<br />
                Me.Invalidate()<br />
                Exit Sub<br />
            End If<br />
        Next<br />
<br />
        Drawing = True<br />
        GP = New GraphicsPath ' Create a new GP object to hold the line. <br />
        pt1 = New Point(e.X, e.Y) ' Set the start point of the line.<br />
        LineCollection.Add(GP) ' Add this graphics path object to the collection<br />
End Sub<br />
<br />
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp<br />
        Drawing = False ' Not drawing a line anymore<br />
End Sub<br />
<br />
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove<br />
        If Drawing = True Then<br />
            GP.Reset() ' Clear the current graphics path object.<br />
            GP.AddLine(pt1.X, pt1.Y, e.X, e.Y) ' Add the line<br />
            Me.Invalidate() ' Force paint<br />
        End If<br />
<br />
End Sub<br />


You'll have to make sure you declare LineCollection As a New System.Collections.ArrayList somewhere as well as GP as a GraphicsPath and pt1 as a Point.

Hope this helps. Should let you draw lines on the form and then to "erase" them, just click on them.
GeneralRe: How to draw lines then undo ??? Pin
lespaul3621-Jun-05 11:26
lespaul3621-Jun-05 11:26 
GeneralRecordsets in VB.Net Pin
directred20-Jun-05 4:29
directred20-Jun-05 4:29 
GeneralRe: Recordsets in VB.Net Pin
lespaul3620-Jun-05 9:19
lespaul3620-Jun-05 9:19 
GeneralCreating print documents Pin
Anonymous20-Jun-05 2:50
Anonymous20-Jun-05 2:50 
GeneralRe: Creating print documents Pin
Dave Kreskowiak20-Jun-05 3:58
mveDave Kreskowiak20-Jun-05 3:58 
GeneralApplying Updates Pin
nitin_ion20-Jun-05 0:21
nitin_ion20-Jun-05 0:21 
QuestionHow to do Web Scraping Using MS Inet Control Pin
shahzad316419-Jun-05 22:11
shahzad316419-Jun-05 22:11 
AnswerRe: How to do Web Scraping Using MS Inet Control Pin
Dave Kreskowiak20-Jun-05 1:31
mveDave Kreskowiak20-Jun-05 1:31 
AnswerRe: How to do Web Scraping Using MS Inet Control Pin
Ashaman20-Jun-05 1:52
Ashaman20-Jun-05 1:52 
GeneralDial-Up connection In .Net Pin
Anonymous19-Jun-05 21:09
Anonymous19-Jun-05 21:09 
GeneralRe: Dial-Up connection In .Net Pin
lespaul3621-Jun-05 12:53
lespaul3621-Jun-05 12:53 
Generalcannot forcefully delete a file Pin
ashu_sharma2119-Jun-05 20:11
ashu_sharma2119-Jun-05 20:11 
GeneralRe: cannot forcefully delete a file Pin
Dave Kreskowiak20-Jun-05 1:26
mveDave Kreskowiak20-Jun-05 1:26 
GeneralRe: cannot forcefully delete a file Pin
Ashaman20-Jun-05 1:57
Ashaman20-Jun-05 1:57 
GeneralVisula Basic Tree Traversal With database sync Pin
sakkatha19-Jun-05 19:37
sakkatha19-Jun-05 19:37 
GeneralRe: Visula Basic Tree Traversal With database sync Pin
Christian Graus19-Jun-05 19:49
protectorChristian Graus19-Jun-05 19:49 
GeneralRe: Visula Basic Tree Traversal With database sync Pin
Shreeja19-Jun-05 21:17
Shreeja19-Jun-05 21:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.