// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2024 Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.


using System;
using Hiperscan.AnalysisModule.Identification;
using Hiperscan.PdfLib;
using Hiperscan.Unix;

namespace Hiperscan.ApoIdentCore.Reporting.Protocol.FinalResult
{
    public class CommonFinalResult : IDraw
    {
        public bool Draw(PdfArgs args)
        {
            args.Layout.Feed(args.ReferenceParagraphFeed * 1.1);
            args.Layout.SetFont(PdfFontTypes.HELVETICA_BOLD, args.ReferenceFontSize, PdfColors.Black);

            args.Layout.XPosition = 0;
            if (args.Layout.AddParagraph(Catalog.GetString("Conclusion:")) == false)
                return false;

            string substance_name = args.Info.SelectedName;
            args.Layout.SetFont(PdfFontTypes.HELVETICA, args.ReferenceFontSize, PdfColors.Black);
            args.Layout.XPosition = args.ReferenceTabIndent;
            string text = string.Format(Catalog.GetString("{0} has been clearly identified."), substance_name);
            if (args.Layout.AddParagraph(text) == false)
                return false;

            if (args.Info.CustomerResult == false)
            {
                args.Layout.Feed(args.Layout.ParagraphBoundingBox.Height * 1.6);

                PdfRect sqaure_yes = new PdfRect(args.ReferenceTabIndent, args.Layout.YPosition,
                    args.ReferenceFontSize, args.ReferenceFontSize);
                if (args.Layout.AddRectangle(sqaure_yes, 0.5, PdfColors.Black) == false)
                    return false;

                args.Layout.YPosition -= 0.15 * args.ReferenceFontSize;
                args.Layout.XPosition = args.ReferenceTabIndent + args.ReferenceFontSize * 1.2;
                if (args.Layout.AddParagraph(Catalog.GetString("Yes")) == false)
                    return false;
                args.Layout.YPosition += 0.15 * args.ReferenceFontSize;

                double no_indent = 50;
                PdfRect sqaure_no = new PdfRect(args.ReferenceTabIndent + no_indent, args.Layout.YPosition,
                    args.ReferenceFontSize, args.ReferenceFontSize);
                if (args.Layout.AddRectangle(sqaure_no, 0.5, PdfColors.Black) == false)
                    return false;

                args.Layout.YPosition -= 0.15 * args.ReferenceFontSize;
                args.Layout.XPosition = args.ReferenceTabIndent + no_indent + args.ReferenceFontSize * 1.2;
                if (args.Layout.AddParagraph(Catalog.GetString("No")) == false)
                    return false;
                args.Layout.YPosition += 0.15 * args.ReferenceFontSize;
            }

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