Пример #1
0
 public override void Action(Point cursorCoordinates)
 {
     if (counter == 0)
     {
         p1 = cursorCoordinates;
         var a = ObjectCollection.Instance.objects;
         foreach (var b in a)
         {
             if (b is BrightPoint)
             {
                 if (b.DistanceToPointS(p1) <= 6)
                 {
                     bound = (BrightPoint)b;
                 }
             }
         }
         if (bound == null)
         {
             GenNew = true;
             bound  = new BrightPoint(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.BrightPoint)), p1);
         }
         else
         {
             p1 = bound.Coordinates;
         }
         counter++;
     }
     else
     {
         p2      = cursorCoordinates;
         counter = 2;
         CodeFunctions.CreateRay(p1, p2, bound, GenNew);
         Deactivate();
     }
 }
 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();
             }
         }
     }
 }
Пример #3
0
 private void pastleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (PastleObj != null)
     {
         string h = PastleObj.GenerateSaveString();
         PastleObj      = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), h);
         PastleObj.Name = ObjectProto.GenName(PastleObj.GetTypeSpecifier(),
                                              PastleObj.GetTypeSpecifier() ==
                                              ObjectProto.GetSpec(ObjectTypes.Ray));
         int id = -1;
         if (!(PastleObj is Ray))
         {
             ObjectCollection.Instance.AddObject(PastleObj);
         }
         else
         {
             ((Ray)PastleObj).Angle = new Angle(((Ray)PastleObj).Angle.GetInDegrees() + 30, false);
             id = ObjectCollection.Instance.AddRay(PastleObj.Name, PastleObj.Coordinates, ((Ray)PastleObj).Angle,
                                                   ((Ray)PastleObj).BoundPoint, true);
         }
         if (PastleObj is Ray)
         {
             SelectedItem = ObjectCollection.Instance.Select(ObjectCollection.Instance.GetRayByID(id));
         }
         else
         {
             SelectedItem = ObjectCollection.Instance.Select(PastleObj);
         }
         if (!(PastleObj is Ray))
         {
             SystemCoordinates tmp = new SystemCoordinates(PastleObj.Coordinates);
             Point             X   = tmp;
             X.X += 10;
             X.Y += 10;
             PastleObj.Coordinates = new SystemCoordinates(X);
         }
         PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), PastleObj.GenerateSaveString());
     }
 }
Пример #4
0
 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();
     }
 }
Пример #5
0
        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            SaveLoad.Instance.HookManager_KeyUp(sender, e);
            if (e.KeyCode == Keys.Escape)
            {
                if (!(activeInstrument is InstrumentSelectAndMove))
                {
                    SelectNewInstrument(InstrumentSelectAndMove.Instance);
                }
            }
            if (e.KeyCode == System.Windows.Forms.Keys.LControlKey || e.KeyCode == System.Windows.Forms.Keys.RControlKey || e.KeyCode == System.Windows.Forms.Keys.ControlKey)
            {
                ctrl = false;
            }
            if (ctrl && e.KeyCode == Keys.C && SelectedItem != null)
            {
                PastleObj = SelectedItem;
                string h = PastleObj.GenerateSaveString();
                PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), h);
            }
            if (ctrl && e.KeyCode == Keys.V && PastleObj != null)
            {
                string h = PastleObj.GenerateSaveString();
                PastleObj      = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), h);
                PastleObj.Name = ObjectProto.GenName(PastleObj.GetTypeSpecifier(),
                                                     PastleObj.GetTypeSpecifier() ==
                                                     ObjectProto.GetSpec(ObjectTypes.Ray));
                int id = -1;
                if (!(PastleObj is Ray))
                {
                    ObjectCollection.Instance.AddObject(PastleObj);
                }
                else
                {
                    ((Ray)PastleObj).Angle = new Angle(((Ray)PastleObj).Angle.GetInDegrees() + 30, false);
                    id = ObjectCollection.Instance.AddRay(PastleObj.Name, PastleObj.Coordinates, ((Ray)PastleObj).Angle,
                                                          ((Ray)PastleObj).BoundPoint, true);
                }
                if (PastleObj is Ray)
                {
                    SelectedItem = ObjectCollection.Instance.Select(ObjectCollection.Instance.GetRayByID(id));
                }
                else
                {
                    SelectedItem = ObjectCollection.Instance.Select(PastleObj);
                }
                if (!(PastleObj is Ray))
                {
                    SystemCoordinates tmp = new SystemCoordinates(PastleObj.Coordinates);
                    Point             X   = tmp;
                    X.X += 10;
                    X.Y += 10;
                    PastleObj.Coordinates = new SystemCoordinates(X);
                }
                PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), PastleObj.GenerateSaveString());
            }
            if (SelectedItem != null && e.KeyCode == Keys.Delete)
            {
                X.DeleteObjectRay(SelectedItem);
            }

            /*if (e.KeyCode == System.Windows.Forms.Keys.LControlKey || e.KeyCode == System.Windows.Forms.Keys.RControlKey || e.KeyCode == System.Windows.Forms.Keys.ControlKey)
             *  ((InstrumentMirror)instruments_bindage[pictureBox3]).ControlPressed(false);*/
        }
 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())
     {
         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;
         count++;
     }
     else if (count == 3 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p3.ToScreen() && cursorCoordinates != p4.ToScreen() && cursorCoordinates != p6.ToScreen())
     {
         p2 = cursorCoordinates;
         count++;
     }
     else if (count == 4 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p3.ToScreen() && cursorCoordinates != p4.ToScreen() && cursorCoordinates != p6.ToScreen() && p2.ToScreen() != cursorCoordinates)
     {
         p5 = cursorCoordinates;
         count++;
     }
     if (count == 5)
     {
         SystemCoordinates center;
         if (p1.Distance(p4) > p1.Distance(p6))
         {
             Line z = new Line(p1, p4, false);
             Line u = new Line(p3, p6, false);
             bool isect, equal;
             center = z.IntersectWithLine(u, out isect, out equal);
         }
         else
         {
             Line z = new Line(p1, p6, false);
             Line u = new Line(p3, p4, false);
             bool isect, equal;
             center = z.IntersectWithLine(u, out isect, out equal);
         }
         if (p1.Distance(p4) < p1.Distance(p6))
         {
             ObjectCollection.Instance.AddObject(
                 new Lense(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Lense)), center, p1, p2, p4, p3, p5,
                           p6));
         }
         else
         {
             ObjectCollection.Instance.AddObject(
                 new Lense(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Lense)), center, p1, p2, p6, p3, p5,
                           p4));
         }
         Deactivate();
     }
 }
Пример #7
0
        public static void CreateRay(Point p1, Point p2, BrightPoint bpoint, bool GenNew)
        {
            string s1 = ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Ray), true);

            ObjectCollection.Instance.AddRay(s1, p1, p2, bpoint, GenNew);
        }
Пример #8
0
        public static void AddPoly(SystemCoordinates[] x)
        {
            string name = ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Polygon));

            ObjectCollection.Instance.AddObject(new OPolygon(new Polygon(x), 1.2, name));
        }
Пример #9
0
        public static void AddSphere(SystemCoordinates c, DoubleExtention l)
        {
            string name = ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Sphere));

            ObjectCollection.Instance.AddObject(new Sphere(name, c, l, 1.2));
        }
Пример #10
0
        public static void AddBrightPoint(SystemCoordinates c)
        {
            string s1 = ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.BrightPoint));

            ObjectCollection.Instance.AddObject(new BrightPoint(s1, c));
        }
Пример #11
0
        public static void AddMirror(SystemCoordinates c, Angle a, DoubleExtention Length)
        {
            string s1 = ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Mirror));

            ObjectCollection.Instance.AddObject(new Mirror(s1, c, a, Length));
        }