Exemplo n.º 1
0
        private void SimulatorView_MouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            Vector2 point = new Vector2((float)(e.GetPosition(this).X), (float)(e.GetPosition(this).Y));
            _pickedGeom = physicsSimulator.Collide(point);

            if (_pickedGeom == null)
                return;

            //Remove it from canvas if it already exist. This is to prevent a bork with mouse events.
            RemoveFixedLinearSpringBrush(_mouseSpringBrush);

            if (_mousePickSpring != null && !_mousePickSpring.IsDisposed)
            {
                _mousePickSpring.Dispose();
                _mousePickSpring = null;
            }

            _mousePickSpring = SpringFactory.Instance.CreateFixedLinearSpring(physicsSimulator, _pickedGeom.Body,
                                                                              _pickedGeom.Body.GetLocalPosition(
                                                                                  point), point, 20, 10);
            _mouseSpringBrush = AddFixedLinearSpringBrushToCanvas(_mousePickSpring);
        }
Exemplo n.º 2
0
 public FixedLinearSpringBrush AddFixedLinearSpringBrushToCanvas(FixedLinearSpring spring)
 {
     FixedLinearSpringBrush fls = new FixedLinearSpringBrush();
     fls.FixedLinearSpring = spring;
     Children.Add(fls);
     drawingList.Add(fls);
     return fls;
 }
Exemplo n.º 3
0
 public void RemoveFixedLinearSpringBrush(FixedLinearSpringBrush fls)
 {
     Children.Remove(fls);
     drawingList.Remove(fls);
 }