Hello guys,
My problem is that when I want to draw 2 points on the form and connect them, the points do not appear but the connections are still on the form. I am using DrawEllipse and DrawLine methods. - public partial class Form1 : Form
-
{
-
private Point p1, p2;
-
List<Point> p1List = new List<Point>();
-
List<Point> p2List = new List<Point>();
-
-
public Form1()
-
{
-
InitializeComponent();
-
}
-
-
private void Form1_Paint(object sender, PaintEventArgs e)
-
{
-
-
-
using (var p = new Pen(Color.Blue, 4))
-
{
-
for (int x = 0; x < p1List.Count; x++)
-
{
-
e.Graphics.DrawLine(p, p1List[x], p2List[x]);
-
}
-
}
-
private void Form1_MouseDown(object sender, MouseEventArgs e)
-
{
-
-
Graphics gr = this.CreateGraphics();
-
-
int x = e.X;
-
int y = e.Y;
-
-
// Create pen.
-
Pen whitePen = new Pen(Color.Blue, 3);
-
Pen red = new Pen(Color.Red, 3);
-
SolidBrush whiteBrush = new SolidBrush(Color.Blue);
-
-
// Create rectangle for ellipse.
-
Rectangle rect = new Rectangle(x - 5, y - 5, 10, 10);
-
-
gr.DrawEllipse(whitePen, rect);
-
gr.FillEllipse(whiteBrush, rect);
-
-
if (p1.X == 0)
-
{
-
p1.X = e.X;
-
p1.Y = e.Y;
-
}
-
else
-
{
-
p2.X = e.X;
-
p2.Y = e.Y;
-
-
p1List.Add(p1);
-
p2List.Add(p2);
-
-
Invalidate();
-
p1.X = 0;
-
}
-
}
-
-
-
-
}
On the first picture you can see my first click on the form it draws a point and on the second picture the connection is drawn but without the points.
I need your help please!
0 1056 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: John |
last post by:
I wrote this class
class CLine
{
public float sX,sY,dX,dY,m,x,y;
public void Draw (PaintEventArgs g)
{
//Graphics g = this.CreateGraphics
();
Bitmap bm=new Bitmap(1,1);
|
by: harrylmh |
last post by:
Hi,
I'm learning C# and I just don't quite understand the need for
polymorphism. why do we need to use it? how does a base class variable
holding a derived class instance do any good?
Also,...
|
by: VSNT |
last post by:
Is there a way to access the painting of a MainMenu so as
to change its back color and add icons like i can with
MenuItem?
Thanks,
Allen
|
by: lallous |
last post by:
Hello
I am not very experienced with this issue and would your opinion on
whether it is healthy or not:
1) I created an ATL COM object (say MyCOM):
- that supports connection points
- that...
|
by: placid |
last post by:
Hi all,
Is it possible to be able to do the following in Python?
class Test:
def __init__(self):
pass
def puts(self, str):
print str
| |
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= |
last post by:
Hello,
I can't seem to find any information on how best to implement multiple
connections on a consumer web part and was wondering if anyone could point me
in the right direction.
I have...
|
by: busiswa |
last post by:
Hi All,
I am just new in PHP, i am asked to draw a combobox using the draw() method. Can someone help me on how to go about that.
Thank you,
Busi
|
by: KiddoGuy |
last post by:
I want to loop through an array of numbers and use those to plot points. What method should I be thinking of? I know there's one that takes an X and Y coordinate and draws points. Is there one that...
|
by: game2d |
last post by:
I am trying to create a triangle in openGL 2.0 but some some reason background is shows up but no triangle. I am following this tutorial:...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |