-
Feb 15th, 2014, 05:37 PM
#1
Thread Starter
Frenzied Member
draw a line and save to memory for reuse
$50 US/AU via PP for someone to make me a project that will draw a line on a picture box.
After drawing the line, the line properties (length, direction) will need to be saved to memory so the user can then click on a new location and a new line identical will be drawn, this needs to continue until the user clicks a button to delete the line from the memory.
pm me for skype name
toe
-
Feb 15th, 2014, 08:33 PM
#2
Thread Starter
Frenzied Member
Re: draw a line and save to memory for reuse
i have a taker, i will mark as resolved after deal is done
-
Feb 15th, 2014, 08:50 PM
#3
Re: draw a line and save to memory for reuse
$50 for that? That's a minute's work. All you need is a Point and a Size to represent the line. The Point is where it starts and the Size is the length in the X and Y directions. If you want to reproduce the line in another location you simply use a different Point with the same Size.
-
Feb 15th, 2014, 08:57 PM
#4
Thread Starter
Frenzied Member
Re: draw a line and save to memory for reuse
yer maybe, i spent 4 hours yesterday and counldnt work it out.
-
Feb 15th, 2014, 09:21 PM
#5
Re: draw a line and save to memory for reuse
I'm guessing that this is not perfect but it took about 15 minutes:
vb.net Code:
Public Class Form1 Private lineTemplate As Line Private isDrawing As Boolean = True Private origin As Point Private lines As New List(Of Line) Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Me.lineTemplate = Nothing End Sub Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown If Me.lineTemplate Is Nothing Then Me.isDrawing = True Me.origin = e.Location End If End Sub Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp If Me.isDrawing Then Me.isDrawing = False Me.lineTemplate = New Line With {.Origin = Me.origin, .Offset = New Size(e.X - Me.origin.X, e.Y - Me.origin.Y)} Me.lines.Add(Me.lineTemplate) Me.PictureBox1.Refresh() End If End Sub Private Sub PictureBox1_MouseClick(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseClick If Not Me.isDrawing Then Me.lines.Add(New Line With {.Origin = e.Location, .Offset = Me.lineTemplate.Offset}) Me.PictureBox1.Refresh() End If End Sub Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint For Each line As Line In me.lines e.Graphics.DrawLine(Pens.Black, line.Origin.X, line.Origin.Y, line.Origin.X + line.Offset.Width, line.Origin.Y + line.Offset.Height) Next End Sub End Class Public Class Line Public Property Origin As Point Public Property Offset As Size End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|