Canguro.Controller.Snap.SnapController.createMidPoint C# (CSharp) Method

createMidPoint() private method

Method to try to create a midpoint magnet if the mouse is close to one
private createMidPoint ( LineMagnet lm, GraphicView activeView, System e ) : PointMagnet
lm LineMagnet The Line Magnet being followed
activeView GraphicView The view in which the snap is taking place
e System The MouseEventArgs of the last MouseMove event
return PointMagnet
        private PointMagnet createMidPoint(LineMagnet lm, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            if (lm == null) return null;

            LineElement l;
            if ((l = lm.Line) != null)
            {
                PointMagnet midPtMagnet = new PointMagnet(Vector3.Scale(l.I.Position + l.J.Position, 0.5f),
                    PointMagnetType.MidPoint);
                if (midPtMagnet.Snap(activeView, e.Location) < SnapViewDistance)
                {
                    midPtMagnet.RelatedMagnets.Add(lm);
                    points.Add(midPtMagnet);
                    return midPtMagnet;
                }
            }

            return null;
        }