Ejemplo n.º 1
0
        private void DrawMarker(SKCanvas canvas, Models.FishModel fish)
        {
            // position of the marker
            SKPoint markerPos = new SKPoint()
            {
                X = (float)(backgroundBitmap.Width * fish.AnchorX),
                Y = (float)(backgroundBitmap.Height * fish.AnchorY)
            };

            markerPos.Offset(-ScrollPosition, 0);

            // draw the marker
            canvas.DrawOval(markerPos, new SKSize(50, 20), markerRing);
            canvas.DrawOval(markerPos, new SKSize(25, 10), markerPaint);
            int lineLength = 300;

            canvas.DrawLine(markerPos, new SKPoint(markerPos.X, markerPos.Y - lineLength),
                            linePaint);

            // draw the fish
            if (fishAnnotations.ContainsKey(fish))
            {
                var     annotation = fishAnnotations[fish].OnscreenAnnotation;
                SKPoint fishPos    = markerPos;
                fishPos.Offset(-(annotation.Width / 2), -(annotation.Height / 2 + lineLength));
                canvas.DrawBitmap(annotation, fishPos);
            }
        }
        private void DrawMarker(SKCanvas canvas, Models.FishModel fish)
        {
            // get the absolute position marker
            var markerLocation = GetMarkerAbsolutePos(fish);

            // work out based on the position what type of annotation (left, right, center)
            var annotationType = GetAnnotationDisplayType(fish);

            // work out the rect for where i should draw the annnotation
            SKRect annotationRect = GetAnotationScreenRect(fish);

            if (annotationType == AnnotationDisplayType.Center)
            {
                var markerPos = GetMarkerOnScreenPos(fish);
                // draw the marker
                canvas.DrawOval(markerPos, new SKSize(50, 20), markerRing);
                canvas.DrawOval(markerPos, new SKSize(25, 10), markerPaint);
                canvas.DrawLine(markerPos, new SKPoint(markerPos.X, markerPos.Y - lineLength), linePaint);
            }

            // draw our bitmap at that rect
            SKBitmap annotation = null;

            switch (annotationType)
            {
            case AnnotationDisplayType.Center:
                annotation = fishAnnotations[fish].OnscreenAnnotation;
                break;

            case AnnotationDisplayType.Left:
                annotation = fishAnnotations[fish].LeftAnnotation;
                break;

            case AnnotationDisplayType.Right:
                annotation = fishAnnotations[fish].RightAnnotation;
                break;
            }
            canvas.DrawBitmap(annotation, annotationRect);
        }