SONU GUPTA

SONU GUPTA

  • NA
  • 40
  • 4.4k

checking correct or not

Jun 1 2018 7:02 AM
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Threading.Tasks;  
  9. using System.Windows.Forms;  
  10. namespace WindowsFormsApplication58  
  11. {  
  12. public partial class Form1 : Form  
  13. {  
  14. Graphics g;  
  15. int x = -1;  
  16. int y = -1;  
  17. bool moving = false;  
  18. Pen pen;  
  19. public Form1()  
  20. {  
  21. InitializeComponent();  
  22. g = panel1.CreateGraphics();  
  23. g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;  
  24. pen = new Pen(Color.Black, 5);  
  25. pen.StartCap = pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;  
  26. }  
  27. private void pictureBox1_Click(object sender, EventArgs e)  
  28. {  
  29. PictureBox p = (PictureBox)sender;  
  30. pen.Color = p.BackColor;  
  31. }  
  32. private void panel1_MouseDown(object sender, MouseEventArgs e)  
  33. {  
  34. moving = true;  
  35. x = e.X;  
  36. y = e.Y;  
  37. }  
  38. private void panel1_MouseMove(object sender, MouseEventArgs e)  
  39. {  
  40. if (moving && x != -1 && y != -1)  
  41. {  
  42. g.DrawLine(pen, new Point(x, y), e.Location);  
  43. x = e.X;  
  44. y = e.Y;  
  45. }  
  46. }  
  47. private void panel1_MouseUp(object sender, MouseEventArgs e)  
  48. {  
  49. moving = false;  
  50. x = -1;  
  51. y = -1;  
  52. }  
  53. private void Drawarc(object sender, PaintEventArgs e)  
  54. {  
  55. Pen blackPen = new Pen(Color.Black, 3);  
  56. // Create coordinates of rectangle to bound ellipse.  
  57. float x1 = 420.0F;  
  58. float y1 = 178.0F;  
  59. float x2 = 425.0F;  
  60. float y2 = 228.0F;  
  61. float width1 = 60.0F;  
  62. float height1 = 50.0F;  
  63. float width2 = 60.0F;  
  64. float height2 = 50.0F;  
  65. // Create start and sweep angles on ellipse.  
  66. float startAngle1 = 75.0F;  
  67. float startAngle2 = 255.0F;  
  68. float sweepAngle1 = 220.0F;  
  69. float sweepAngle2 = 220.0F;  
  70. float[] dashValues = { 2, 2, 2, 2 };  
  71. blackPen.DashPattern = dashValues;  
  72. e.Graphics.DrawLine(blackPen, new Point(400, 150), new Point(530, 150));  
  73. e.Graphics.DrawLine(blackPen, new Point(465, 150), new Point(465, 178));  
  74. e.Graphics.DrawLine(blackPen, new Point(420, 278), new Point(460, 278));  
  75. e.Graphics.DrawLine(blackPen, new Point(495, 250), new Point(498, 253));  
  76. // e.Graphics.DrawLine(blackPen, new Point(430, 230), new Point(480, 270));  
  77. // e.Graphics.DrawLine(blackPen, new Point(430, 230), new Point(480, 230));  
  78. // Draw arc to screen.  
  79. e.Graphics.DrawArc(blackPen, x1, y1, width1, height1, startAngle1, sweepAngle1);  
  80. e.Graphics.DrawArc(blackPen, x2, y2, width2, height2, startAngle2, sweepAngle2);  
  81. }  
  82. }  
  83. }  
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