473,804 Members | 2,101 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drawing lines with dots leaves spaces if mouse moves too fast

I found this code in this newsgroup and used it, but the lines drawn
are composed of point too separated when the mouse moves at medium or
fast speed. How can I fix it?

Thanks in advance !!!

Dim bTracking As Boolean
Dim blackPen As Pen
Dim g As Graphics

Private Sub frmFirma_Load(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
blackPen = New Pen(Color.Black , 2)
blackPen.LineJo in = Drawing2D.LineJ oin.Round
g = PictureBox1.Cre ateGraphics()
End Sub

Private Sub AddPoint(ByVal e As
System.Windows. Forms.MouseEven tArgs)
g.DrawLine(blac kPen, e.X, e.Y, e.X + 1, e.Y + 1)
End Sub

Private Sub PictureBox1_Mou seDown(ByVal sender As Object, ByVal e
As System.Windows. Forms.MouseEven tArgs) Handles PictureBox1.Mou seDown
bTracking = True
AddPoint(e)
End Sub

Private Sub PictureBox1_Mou seMove(ByVal sender As Object, ByVal e
As System.Windows. Forms.MouseEven tArgs) Handles PictureBox1.Mou seMove
If bTracking Then
AddPoint(e)
End If
End Sub

Private Sub PictureBox1_Mou seUp(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles PictureBox1.Mou seUp
If bTracking Then
AddPoint(e)
bTracking = False
End If
End Sub

Protected Overrides Sub Finalize()
g.Dispose()
MyBase.Finalize ()
End Sub
Nov 20 '05 #1
5 2377
"Manuel Daponte" <md******@prtc. net> schrieb
I found this code in this newsgroup and used it, but the lines
drawn are composed of point too separated when the mouse moves at
medium or fast speed. How can I fix it?


Draw lines instead of points.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
I found this code in this newsgroup and used it, but the lines
drawn are composed of point too separated when the mouse moves at
medium or fast speed. How can I fix it?
Draw lines instead of points.


Actually, I'm drawing small lines (2 points)...

The thing is that this will be used in a picture box, in an tabletPC app, to pick a signature. Do you have a better chunk of code
for that?

Thanks in advance for you help !!!

--
Manuel Daponte
Nov 20 '05 #3
* "Manuel Daponte" <md******@prtc. net> scripsit:
I found this code in this newsgroup and used it, but the lines
drawn are composed of point too separated when the mouse moves at
medium or fast speed. How can I fix it?

Draw lines instead of points.


Actually, I'm drawing small lines (2 points)...

The thing is that this will be used in a picture box, in an tabletPC app, to pick a signature. Do you have a better chunk of code
for that?


I think that's already a good solution. There may be better solutions
using interpolation to make everything look more smooth, but I think
that's too much effort...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

"Manuel Daponte" <md******@prtc. net> wrote
Draw lines instead of points.
Actually, I'm drawing small lines (2 points)...

The thing is that this will be used in a picture box, in an tabletPC app, to pick a signature. Do you have a better chunk of

code for that?

Thanks in advance for you help !!!

Here is a quick example of drawing on the form. (Drawing on the form
offers no persistance) Paste the code below in a new project, AFTER
the designer code section:

HTH
LFS
Private grx As Graphics
Private mouse As Point
Private ink As Pen = New Pen(Color.Midni ghtBlue, 3)

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
grx = Me.CreateGraphi cs
grx.SmoothingMo de = Drawing2D.Smoot hingMode.HighQu ality
End Sub

Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
Dim pos As Point = New Point(e.X, e.Y)
If e.Button = MouseButtons.Le ft Then
grx.DrawLine(in k, mouse, pos)
mouse = pos
End If
End Sub

Private Sub Form1_MouseDown (ByVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
mouse = New Point(e.X, e.Y)
End Sub

Nov 20 '05 #5
It's perfect !!! Thanks !!!

--
Manuel A. Daponte Santiago
--------------------------
DBA Municipio de Guaynabo

"Larry Serflaten" <se*******@usin ternet.com> wrote in message news:Oq******** ********@tk2msf tngp13.phx.gbl. ..

"Manuel Daponte" <md******@prtc. net> wrote
Draw lines instead of points.
Actually, I'm drawing small lines (2 points)...

The thing is that this will be used in a picture box, in an tabletPC app, to pick a signature. Do you have a better chunk of

code for that?

Thanks in advance for you help !!!

Here is a quick example of drawing on the form. (Drawing on the form
offers no persistance) Paste the code below in a new project, AFTER
the designer code section:

HTH
LFS
Private grx As Graphics
Private mouse As Point
Private ink As Pen = New Pen(Color.Midni ghtBlue, 3)

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
grx = Me.CreateGraphi cs
grx.SmoothingMo de = Drawing2D.Smoot hingMode.HighQu ality
End Sub

Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
Dim pos As Point = New Point(e.X, e.Y)
If e.Button = MouseButtons.Le ft Then
grx.DrawLine(in k, mouse, pos)
mouse = pos
End If
End Sub

Private Sub Form1_MouseDown (ByVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
mouse = New Point(e.X, e.Y)
End Sub


Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
11265
by: Anand Ganesh | last post by:
Hi All, In my application I am allowing the user to draw a line. But when the user clicks the start point and starts moving the mouse there is a series of line generated. When the mouse is up the final line is drawn. How to avoid the series of lines being generated during mouse move event? How to get the rubberband effect when the user moves the mouse? I tried using the ControlPaint.Reversible line but this does not help
6
30681
by: Rene | last post by:
I tried searching the newsgroups to see how do you draw a dotted line but I was unable to find an answer, drawing a straight line is very easy but not a dotted one. So the question is, how do I draw a dotted line? Thank you.
1
3991
by: YouPoP | last post by:
I am doing an app (C# 2.0) where you can draw in a panel with your mouse in "real time". I actually have 2 problems; 1- it does not really is "real time", if your mouse move fast or very fast the line is added after a very small delay. 2-Because I use AddLine(), it adds very short lines from one point to another and it does not give a very good result. Also because of this and my "not real time" problem, when the mouse moves fast it adds...
5
12881
by: Macias | last post by:
Hi, Please help me, how I can make a line drawing on PictureBox similar to MS paint. I thinking about this: click and hold button, move mouse and relase button. I'm trying useing this g.DrawLine(..), but I have a lot of line. In C++ is a parameter XORPUT, but in C# I can't find it.
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.