using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication58
{
public partial class Form1 : Form
{
Graphics g;
int x = -1;
int y = -1;
bool moving = false;
Pen pen;
public Form1()
{
InitializeComponent();
g = panel1.CreateGraphics();
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
pen = new Pen(Color.Black, 5);
pen.StartCap = pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
PictureBox p = (PictureBox)sender;
pen.Color = p.BackColor;
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
moving = true;
x = e.X;
y = e.Y;
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (moving && x != -1 && y != -1)
{
g.DrawLine(pen, new Point(x, y), e.Location);
x = e.X;
y = e.Y;
}
}
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
moving = false;
x = -1;
y = -1;
}
private void Drawarc(object sender, PaintEventArgs e)
{
Pen blackPen = new Pen(Color.Black, 3);
// Create coordinates of rectangle to bound ellipse.
float x1 = 420.0F;
float y1 = 178.0F;
float x2 = 425.0F;
float y2 = 228.0F;
float width1 = 60.0F;
float height1 = 50.0F;
float width2 = 60.0F;
float height2 = 50.0F;
// Create start and sweep angles on ellipse.
float startAngle1 = 75.0F;
float startAngle2 = 255.0F;
float sweepAngle1 = 220.0F;
float sweepAngle2 = 220.0F;
float[] dashValues = { 2, 2, 2, 2 };
blackPen.DashPattern = dashValues;
e.Graphics.DrawLine(blackPen, new Point(400, 150), new Point(530, 150));
e.Graphics.DrawLine(blackPen, new Point(465, 150), new Point(465, 178));
e.Graphics.DrawLine(blackPen, new Point(420, 278), new Point(460, 278));
e.Graphics.DrawLine(blackPen, new Point(495, 250), new Point(498, 253));
// e.Graphics.DrawLine(blackPen, new Point(430, 230), new Point(480, 270));
// e.Graphics.DrawLine(blackPen, new Point(430, 230), new Point(480, 230));
// Draw arc to screen.
e.Graphics.DrawArc(blackPen, x1, y1, width1, height1, startAngle1, sweepAngle1);
e.Graphics.DrawArc(blackPen, x2, y2, width2, height2, startAngle2, sweepAngle2);
}
}
}
``
Here is the code for painting and drawing dash line now i want that when i paint/Drawline over dash line then it should say it is correct otherwise it is false .If the line drawn is not over dash line then it should say false... This code is executable ... but i just need to add last if else condition so that i can check whether the line is drawn over dash line or not in paint ... how can i do it..