using System;
using Hiperscan.PdfLib;
using Hiperscan.Unix;

namespace Hiperscan.ApoIdentCore.Reporting.Protocol.Rating
{
    public class CommonRating : IDraw
    {
        public bool Draw(PdfArgs args)
        {
            args.Layout.Feed(args.Layout.ParagraphBoundingBox.Height);
            args.Layout.Feed(0.6 * args.ReferenceParagraphFeed);

            args.Layout.SetFont(PdfFontTypes.HELVETICA, args.ReferenceFontSize, PdfColors.Black);
            string min_rating = (args.Info.MinRating * 100).ToString("f1");
            string rating = (args.Info.Rating * 100).ToString("f1");

            if (args.Info.IsMatch == false && min_rating == rating)
                rating = (args.Info.MinRating * 100 - 0.1).ToString("f1");

            string text = String.Format(Catalog.GetString("Valuation: {0}% (bounds {1}% to 100%)"), rating, min_rating);
            if (args.Layout.AddParagraph(text) == false)
                return false;

            args.Layout.Feed(args.Layout.ParagraphBoundingBox.Height + args.ReferenceLineDistance);
            return true;
        }
    }
}
