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

Paint() public method

This method paints all the gadgets added by the Snaps (i.e.
public Paint ( Device device, GraphicView activeView, System e ) : void
device Device
activeView GraphicView
e System
return void
        public void Paint(Device device, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            for (int i = 0; i < paintMagnets.Count; i++)
            {
                Magnet m = paintMagnets[i];
                if (m != null)
                {
                    if (m is PointMagnet)
                    {
                        byte alpha = 255;
                        if (m.LastSnapFitness >= EffectiveSnapDistance)
                            alpha = (byte)((1f - (m.LastSnapFitness - EffectiveSnapDistance) /
                                           (SnapViewDistance - EffectiveSnapDistance)) * 128f + 64f);

                        switch (((PointMagnet)m).Type)
                        {
                            case PointMagnetType.Perpendicular:
                                if (alpha == 255 && m.RelatedMagnets.Count > 0 && m.RelatedMagnets[0] is PointMagnet)
                                    painter.PaintLineSegment(device, activeView, m.Position, m.RelatedMagnets[0].Position, LineMagnetType.FollowHelper);
                                break;
                            case PointMagnetType.SimplePoint:
                                if (alpha == 255 && m.RelatedMagnets.Count > 0 && m.RelatedMagnets[0] is PointMagnet)
                                    painter.PaintPointSymbol(device, activeView, m.RelatedMagnets[0].Position, PointMagnetType.SimplePoint, 192);
                                break;
                        }

                        painter.PaintPointSymbol(device, activeView, m.Position, ((PointMagnet)m).Type, alpha);
                    }
                    else if (m is LineMagnet)
                    {
                        LineMagnetType lmt = ((LineMagnet)m).Type;
                        if (lmt == LineMagnetType.FollowProjection && lines.CurrentLine != null)
                            lmt = LineMagnetType.FollowHelper;

                        painter.PaintLineSegment(device, activeView, m.Position, m.SnapPositionInt, lmt);
                    }
                }
            }

            if (lines.CurrentLine != null)
                painter.PaintLineSegment(device, activeView, lines.CurrentLine.Position, lines.CurrentLine.SnapPositionInt, lines.CurrentLine.Type);
        }