Пример #1
0
        public void OnMouseMove(Renderer r, MouseEventArgs e)
        {
            currentPoint = Vector2.FromPointF(r.ScreenToWorld(e.Location));

            if ((modeMovePOI == true) && (shouldMove == true))
            {
                PointF p = r.ScreenToWorld(new PointF(e.X, e.Y));
                foreach (NotepointRenderer np in poiList)
                {
                    if (np.Equals(pointToMove))
                    {
                        NotepointRenderer mousePoint = np;
                        mousePoint.X = p.X;
                        mousePoint.Y = p.Y;
                        poiList.Remove(np);
                        poiList.Add(mousePoint);
                        pointToMove = mousePoint;
                        break;
                    }
                }
            }
        }
Пример #2
0
 public void OnMouseDown(Renderer r, MouseEventArgs e)
 {
     PointF worldPoint = r.ScreenToWorld(e.Location);
     if (e.Button == MouseButtons.Right)
     {
         //if (GestureExpData != null)
         //    GestureExpData(this, new GestureExpPointToolEventArgs("right down click, at " + e.X + ", " + e.Y + " (screen), " + worldPoint.X + ", " + worldPoint.Y + " (world)"));
     }
     else if(e.Button.Equals(MouseButtons.Left))
     {
         //PointF worldPoint = r.ScreenToWorld(e.Location);
         if (modeNewPOI == true)
         {
             if (POItype == "PICTURE")
             {
                 if (r.Selectables.Count() > 0)
                 {
                     foreach (ISelectable sel in r.Selectables)
                     {
                         RobotRenderer rr = sel as RobotRenderer;
                         if (rr != null && rr.IsSelected)
                         {
                             r.AddRenderable(new FakeObjectRenderer("important", rr.GetBoundingPolygon().Center.ToPointF(), "picture"));
                             if (GestureExpData != null)
                             {
                                 GestureExpData(this, new GestureExpHRIEventArgs("Tool:PointTool|left click down|take picture|Robot " + rr.GetName().Substring(rr.GetName().Length-1) + "|" + e.X + "|" + e.Y + "|(screen)|" + worldPoint.X + "|" + worldPoint.Y + "|(world)"));
                             }
                         }
                     }
                 }
             }
             else
             {
                 NotepointRenderer newPoint = new NotepointRenderer();
                 newPoint.Name = POItype;
                 if (POItype == "SQUARE")
                 {
                     newPoint.Color = Color.DarkMagenta;
                 }
                 else if (POItype == "TRIANGLE")
                 {
                     newPoint.Color = Color.DarkGreen;
                 }
                 else if (POItype == "SPIRAL")
                 {
                     newPoint.Color = Color.DarkRed;
                 }
                 newPoint.X = worldPoint.X;
                 newPoint.Y = worldPoint.Y;
                 newPoint.Z = 0;
                 poiList.Add(newPoint);
                 r.AddRenderable(newPoint);
                 if (GestureExpData != null)
                 {
                     GestureExpData(this, new GestureExpHRIEventArgs("Tool:PointTool|left click down|create|" + newPoint.Name + "|" + e.X + "|" + e.Y + "|(screen)|" + worldPoint.X + "|" + worldPoint.Y + "|(world)"));
                 }
             }
         }
         else if (modeDeletePOI == true)
         {
             if (poiList.Count > 0)
             {
                 List<NotepointRenderer> pointsToRemove= new List<NotepointRenderer>();
                 foreach (NotepointRenderer np in poiList)
                 {
                     if ((worldPoint.X - np.X > -.25) && (worldPoint.Y - np.Y > -.25) &&
                         (worldPoint.X - np.X < .25) && (worldPoint.Y - np.Y < .25))
                     {
                         pointsToRemove.Add(np);
                         r.RemoveRenderable(np);
                         if (GestureExpData != null)
                             GestureExpData(this, new GestureExpHRIEventArgs("Tool:PointTool|left click down|remove|" + np.Name + "|" + e.X + "|" + e.Y + "|(screen)|" + worldPoint.X + "|" + worldPoint.Y + "|(world)"));
                     }
                 }
                 if (pointsToRemove.Count>0)
                 {
                     foreach (NotepointRenderer n in pointsToRemove)
                     {
                         poiList.Remove(n);
                     }
                     myToolManager.SelectTool.TempReactivate();
                     myToolManager.PathTool.TempReactivate();
                     modeDeletePOI = false;
                 }
             }
         }
         else if (modeMovePOI == true)
         {
             if (poiList.Count > 0)
             {
                 foreach (NotepointRenderer np in poiList)
                 {
                     if ((worldPoint.X - np.X > -.25) && (worldPoint.Y - np.Y > -.25) &&
                         (worldPoint.X - np.X < .25) && (worldPoint.Y - np.Y < .25))
                     {
                         shouldMove = true;
                         pointToMove = np;
                         if (GestureExpData != null)
                             GestureExpData(this, new GestureExpHRIEventArgs("Tool:PointTool|left click down|move|" + np.Name + "|" + e.X + "|" + e.Y + "|(screen)|" + worldPoint.X + "|" + worldPoint.Y + "|(world)"));
                         break;
                     }
                 }
             }
         }
     }
 }