public override void Action(Point cursorCoordinates) { if (count == 0) { p1 = cursorCoordinates; count++; } else { if (count == 1 && cursorCoordinates != p1.ToScreen()) { p2 = cursorCoordinates; count++; } else { if (count == 2 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen()) { p3 = cursorCoordinates; count++; } else if (count == 3 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen() && cursorCoordinates != p3.ToScreen()) { if (!(SystemCoordinates.InOneLine(p1, p3, p2) && SystemCoordinates.InOneLine(p1, cursorCoordinates, p2))) { p4 = cursorCoordinates; count++; } } if (count == 4) { Line aa = new Line(p1, p2, false); ObjectCollection.Instance.AddObject( new Lense(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Lense)), aa.Center, p1, p3, p2, p1, p4, p2)); Deactivate(); } } } }
public override void Action(Point cursorCoordinates) { if (count == 0) { c1 = cursorCoordinates; count++; } else if (count == 1 && c1.ToScreen() != cursorCoordinates) { c2 = cursorCoordinates; count++; } else if (count == 2 && c1.ToScreen() != cursorCoordinates && c2.ToScreen() != cursorCoordinates && !SystemCoordinates.InOneLine(c1, c2, cursorCoordinates)) { c3 = cursorCoordinates; count++; Circle a = new Circle(c1, c3, c2); ObjectCollection.Instance.AddObject( new SphereMirror(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.SphereMirror)), a.Center, a.Radius, c1, c3, c2, control_modifier)); Deactivate(); } }
public override void Draw(Point cursorCoordinates) { SystemCoordinates P1, P3, P4, P6; if (count == 0) { OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5); } if (count == 1) { OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5); } if (count == 2 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen()) { Line x = p1 + p2; DoubleExtention l = x.DistanceToPoint(cursorCoordinates); Line z = x.BuildOrthogonalLine(p2); z.BuildAngle(); if (z.AngleForOnePointLines == new Angle(90, false) || z.AngleForOnePointLines == new Angle(90, false)) { z.FirstEnd = new SystemCoordinates(p2.X, p2.Y + l); z.SecondEnd = new SystemCoordinates(p2.X, p2.Y - l); } else { z.FirstEnd = new SystemCoordinates(p2.X + l * z.AngleForOnePointLines.cos(), p2.Y + l * z.AngleForOnePointLines.sin()); z.SecondEnd = new SystemCoordinates(p2.X - l * z.AngleForOnePointLines.cos(), p2.Y + l * z.AngleForOnePointLines.sin()); } Line u = x.BuildOrthogonalLine(p1); u.BuildAngle(); if (u.AngleForOnePointLines == new Angle(90, false) || u.AngleForOnePointLines == new Angle(90, false)) { u.FirstEnd = new SystemCoordinates(p1.X, p1.Y + l); u.SecondEnd = new SystemCoordinates(p1.X, p1.Y - l); } else { u.FirstEnd = new SystemCoordinates(p1.X + l * u.AngleForOnePointLines.cos(), p1.Y + l * u.AngleForOnePointLines.sin()); u.SecondEnd = new SystemCoordinates(p1.X - l * u.AngleForOnePointLines.cos(), p1.Y + l * u.AngleForOnePointLines.sin()); } P1 = z.FirstEnd; P3 = z.SecondEnd; P4 = u.FirstEnd; P6 = u.SecondEnd; u = new Line(P1, P3, false); z = new Line(P4, P6, false); u.Drawer(2); z.Drawer(2); OGL.DrawFilledCircle(new Pen(Color.Yellow), P1, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), P3, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), P4, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), P6, 5); } if (count == 3 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p3.ToScreen() && cursorCoordinates != p4.ToScreen() && cursorCoordinates != p6.ToScreen()) { Line z = new Line(p1, p3, false); Line u = new Line(p4, p6, false); z.Drawer(2); u.Drawer(2); if (p1.Distance(p4) < p1.Distance(p6)) { Circle beta = null; Line alpha = null; if (SystemCoordinates.InOneLine(p1, cursorCoordinates, p4)) { alpha = new Line(p1, p4, false); } else { beta = new Circle(p1, cursorCoordinates, p4); } if (alpha != null) { alpha.Drawer(Color.Black, 2); } if (beta != null) { beta.Draw(false); } } else { Circle beta = null; Line alpha = null; if (SystemCoordinates.InOneLine(p1, cursorCoordinates, p6)) { alpha = new Line(p1, p6, false); } else { beta = new Circle(p1, cursorCoordinates, p6); } if (alpha != null) { alpha.Drawer(Color.Black, 2); } if (beta != null) { beta.Draw(false); } } OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p3, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p4, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p6, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5); } if (count == 4 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p3.ToScreen() && cursorCoordinates != p4.ToScreen() && cursorCoordinates != p6.ToScreen()) { Line z = new Line(p1, p3, false); Line u = new Line(p4, p6, false); z.Drawer(2); u.Drawer(2); if (p1.Distance(p4) < p1.Distance(p6)) { Line beta_x = null; Line alpha_x = null; Circle alpha = null, beta = null; if (SystemCoordinates.InOneLine(p1, p2, p4)) { beta_x = new Line(p1, p4, false); } else { beta = new Circle(p1, p2, p4); } if (SystemCoordinates.InOneLine(p3, cursorCoordinates, p6)) { alpha_x = new Line(p3, p6, false); } else { alpha = new Circle(p3, cursorCoordinates, p6); } if (beta != null) { beta.Draw(false); } if (alpha != null) { alpha.Draw(false); } if (beta_x != null) { beta_x.Drawer(2); } if (alpha_x != null) { alpha_x.Drawer(2); } } else { Line beta_x = null; Line alpha_x = null; Circle beta = null; Circle alpha = null; if (SystemCoordinates.InOneLine(p1, p2, p6)) { beta_x = new Line(p1, p6, false); } else { beta = new Circle(p1, p2, p6); } if (SystemCoordinates.InOneLine(p3, cursorCoordinates, p4)) { alpha_x = new Line(p3, p4, false); } else { alpha = new Circle(p3, cursorCoordinates, p4); } if (beta != null) { beta.Draw(false); } if (alpha != null) { alpha.Draw(false); } if (beta_x != null) { beta_x.Drawer(2); } if (alpha_x != null) { alpha_x.Drawer(2); } } OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p3, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p4, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p6, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5); } if (count == 5) { Line z = new Line(p1, p3, false); Line u = new Line(p4, p6, false); z.Drawer(2); u.Drawer(2); if (p1.Distance(p4) < p1.Distance(p6)) { Line beta_x = null; Line alpha_x = null; Circle alpha = null, beta = null; if (SystemCoordinates.InOneLine(p1, p2, p4)) { beta_x = new Line(p1, p4, false); } else { beta = new Circle(p1, p2, p4); } if (SystemCoordinates.InOneLine(p3, p5, p6)) { alpha_x = new Line(p3, p6, false); } else { alpha = new Circle(p3, p5, p6); } if (beta != null) { beta.Draw(false); } if (alpha != null) { alpha.Draw(false); } if (beta_x != null) { beta_x.Drawer(2); } if (alpha_x != null) { alpha_x.Drawer(2); } } else { Line beta_x = null; Line alpha_x = null; Circle beta = null; Circle alpha = null; if (SystemCoordinates.InOneLine(p1, p2, p6)) { beta_x = new Line(p1, p6, false); } else { beta = new Circle(p1, p2, p6); } if (SystemCoordinates.InOneLine(p3, p5, p4)) { alpha_x = new Line(p3, p4, false); } else { alpha = new Circle(p3, p5, p4); } if (beta != null) { beta.Draw(false); } if (alpha != null) { alpha.Draw(false); } if (beta_x != null) { beta_x.Drawer(2); } if (alpha_x != null) { alpha_x.Drawer(2); } } OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p3, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p4, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p6, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5); OGL.DrawFilledCircle(new Pen(Color.Yellow), p5, 5); } }