<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_secScreen.ascx.cs" Inherits="NKC_WF.WebUserControls.cmp_secScreen" %>
<%@ Register Src="~/WebUserControls/cmp_ItemDet.ascx" TagPrefix="uc1" TagName="cmp_ItemDet" %>




<div class="card text-center border-primary" style="width: 100%;">
    <asp:HiddenField runat="server" ID="hfNum" />
    <asp:HiddenField ID="hfCountDown" runat="server" Value="0" />
    <asp:HiddenField ID="hfBatchId" runat="server" Value="0" />
    <asp:HiddenField ID="hfSheetId" runat="server" Value="0" />
    <asp:HiddenField ID="hfItemPdf" runat="server" Value="0" />
    <asp:HiddenField ID="hfItemDtmx" runat="server" Value="0" />
    <asp:HiddenField ID="hfItemCode" runat="server" Value="0" />
    <asp:Timer ID="timerRefresh" runat="server" Interval="1000" OnTick="timerRefresh_Tick"></asp:Timer>
    <div class="card-header bg-primary text-light">
        <div class="row">
            <div class="col-3">
                <asp:HyperLink runat="server" ID="hlShowCurrSheet" Target="_blank" CssClass="btn btn-warning btn-block"><i class="fa fa-object-group fa-2x" aria-hidden="true"></i><br /><%: traduci("ShowCurrSheet") %></asp:HyperLink>
            </div>
            <div class="col-6">
                <h3 class="text-uppercase"><%: traduci("SecScreen") %>
                    <asp:Label runat="server" ID="lblNum" CssClass="small">(<%: hfNum.Value %>)</asp:Label></h3>
                <asp:Label runat="server" ID="lblMessage" CssClass="text-light"><%: traduci("NoItemSel") %></asp:Label>
                <uc1:cmp_ItemDet runat="server" ID="cmp_ItemDet" />
            </div>
            <div class="col-3">
                <asp:HyperLink runat="server" ID="hlPdfOpener" Target="_blank" CssClass="btn btn-success btn-block"><i class="fa fa-file-pdf-o fa-2x" aria-hidden="true"></i>
<br /><%: traduci("ShowPDF") %></asp:HyperLink>
            </div>
        </div>
    </div>
    <div class="card-body py-1">
        <div class="row">
            <div runat="server" id="divImg" class="col-12">
                <asp:Image runat="server" ID="imgQrMain" CssClass="img-fluid" />
            </div>
            <%--<div class="col-12">
                <script src="//mozilla.github.io/pdf.js/build/pdf.js"></script>
                <script>

                    function loadPdf() {
                        var url = '<%: lblPdf.Text %>';
                        //var url = '../temp/119752.pdf';

                        // Loaded via <script> tag, create shortcut to access PDF.js exports.
                        var pdfjsLib = window['pdfjs-dist/build/pdf'];

                        // The workerSrc property shall be specified.
                        pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';

                        // Asynchronous download of PDF
                        var loadingTask = pdfjsLib.getDocument(url);
                        loadingTask.promise.then(function (pdf) {
                            console.log('PDF loaded');

                            // Fetch the first page
                            var pageNumber = 1;
                            pdf.getPage(pageNumber).then(function (page) {
                                console.log('Page loaded');

                                var scale = 1.5;
                                var viewport = page.getViewport({ scale: scale });

                                // Prepare canvas using PDF page dimensions
                                var canvas = document.getElementById('<%: canvasPdf.ClientID %>');
                                var context = canvas.getContext('2d');
                                canvas.height = viewport.height;
                                canvas.width = viewport.width;

                                // Render PDF page into canvas context
                                var renderContext = {
                                    canvasContext: context,
                                    viewport: viewport
                                };
                                var renderTask = page.render(renderContext);
                                renderTask.promise.then(function () {
                                    console.log('Page rendered');
                                });
                            });
                        }, function (reason) {
                            // PDF loading error
                            console.error(reason);
                        });
                    };
                </script>
                <canvas runat="server" id="canvasPdf"></canvas>
            </div>--%>
        </div>
    </div>
</div>
