Exemplo n.º 1
0
        private void DoFirma(FirmaResponse f)
        {
            if (f is null)
            {
                return;
            }
            var pnl = new StackPanel {
                Margin = new Thickness(60, 0, 0, 0)
            };

            if (!f.name.IsEmpty())
            {
                var t = new TextBlock
                {
                    Text          = f.name,
                    TextAlignment = TextAlignment.Center,
                    FontWeight    = FontWeights.Bold
                };
                pnl.Children.Add(t);
            }
            if (!f.collegiate.IsEmpty())
            {
                pnl.Children.Add(new TextBlock
                {
                    Text          = f.collegiate,
                    TextAlignment = TextAlignment.Center
                });
            }
            if (!f.extra.IsEmpty())
            {
                pnl.Children.Add(new TextBlock
                {
                    Text          = f.extra,
                    TextAlignment = TextAlignment.Center
                });
            }
            GrdFirmas.Children.Add(pnl);
        }
Exemplo n.º 2
0
        internal FormPage(InformeResponse data, IEnumerable <LabeledImage> imgs, Size pgSize, Language language, bool useDpi = true)
        {
            InitializeComponent();

            if (data is null || data.serial == 0)
            {
                throw new ArgumentNullException();
            }

            _fltImages = (Floater)FindResource("FltImages");
            Lang       = language;
            switch (Lang)
            {
            case FormRender.Language.Spanish:
                LblTit.Text  = "Reporte de Histopatología";
                LblPac.Text  = "Paciente:";
                LblMed.Text  = "Médico:";
                LblAddr.Text = "Dirección:";
                LblDiag.Text = "Diag. Clínico:";
                LblMat.Text  = "Material Estudiado:";
                LblAge.Text  = "Edad:";
                LblSex.Text  = "  Género:";
                LblDte.Text  = "Fecha:";
                LblRec.Text  = "Recibido:";
                LblNb.Text   = "No. biopsia:";
                LblInf.Text  = "INFORME";
                LblIDt.Text  = "Fecha de informe:";
                _lblPg       = "Página";

                TxtFecha.Text    = data.fecha_biopcia?.ToString("dd/MM/yyyy") ?? string.Empty;
                TxtRecv.Text     = data.fecha_muestra?.ToString("dd/MM/yyyy") ?? string.Empty;
                TxtFechaInf.Text = data.fecha_informe?.ToString("dd/MM/yyyy") ?? string.Empty;

                break;

            case FormRender.Language.English:
                var ci = CultureInfo.CreateSpecificCulture("en-us");

                LblTit.Text  = "Histopathology Report";
                LblPac.Text  = "Patient:";
                LblMed.Text  = "Dr:";
                LblAddr.Text = "Address:";
                LblDiag.Text = "Clinical Diagnosis:";
                LblMat.Text  = "Specimen:";
                LblAge.Text  = "Age:";
                LblSex.Text  = "  Gender:";
                LblDte.Text  = "Date:";
                LblRec.Text  = "Received:";
                LblNb.Text   = "Biopsy N.:";
                LblInf.Text  = "REPORT";
                LblIDt.Text  = "Report date:";
                _lblPg       = "Page";

                TxtFecha.Text    = data.fecha_biopcia?.ToString("MMMM dd, yyyy", ci.DateTimeFormat) ?? string.Empty;
                TxtRecv.Text     = data.fecha_muestra?.ToString("MMMM dd, yyyy", ci.DateTimeFormat) ?? string.Empty;
                TxtFechaInf.Text = data.fecha_informe?.ToString("MMMM dd, yyyy", ci.DateTimeFormat) ?? string.Empty;

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Data = data;
            var labeledImages = imgs.ToList();

            Imgs = labeledImages;

            //Llenar header...
            TxtPaciente.Text  = data.facturas.nombre_completo_cliente;
            TxtMedico.Text    = data.facturas.medico;
            TxtDireccion.Text = data.facturas.direccion_entrega_sede;
            TxtDiag.Text      = data.diagnostico;
            TxtEstudiado.Text = data.muestra;
            TxtEdad.Text      = data.facturas.edad;
            TxtSexo.Text      = data.facturas.sexo;

            TxtBiop.Text    = $"{data.serial ?? 0} - {data.fecha_muestra?.Year.ToString() ?? "N/A"}";
            TxtFactNum.Text = $"C.I. {data.factura_id}";

            // Parsear y extraer texto desde html...
            var oo = XA.Parse(HTC.ConvertHtmlToXaml(data.informe, true)) as FlowDocument;

            while (oo?.Blocks.Any() ?? false)
            {
                oo.Blocks.FirstBlock.FontFamily = (FontFamily)FindResource("FntFmly");
                oo.Blocks.FirstBlock.FontSize   = (double)FindResource("FntSze");
                DocRoot.Blocks.Add(oo.Blocks.FirstBlock);
            }

            if (labeledImages.Any())
            {
                var fb = (Paragraph)DocRoot.Blocks.FirstBlock;
                fb.Inlines.InsertBefore(fb.Inlines.FirstInline, _fltImages);
            }

            _pageSize = pgSize;
            _ctrlSize = useDpi ? new Size(_pageSize.Width * UI.GetXDpi(), _pageSize.Height * UI.GetYDpi()) : pgSize;

            Rsze();

            foreach (var j in labeledImages)
            {
                GetImg(j);
            }
            switch (data.images.Length)
            {
            case 0:
            case 1: break;

            default:
                if (_imgAdjust > DocSize - GrdHead.ActualHeight)
                {
                    _fltImages.Width = 230 * ((DocSize) - GrdHead.ActualHeight) / _imgAdjust;
                }
                break;
            }

            RootContent.Width  = _ctrlSize.Width;
            RootContent.Height = _ctrlSize.Height;
            UpdateLayout();

            _firma             = data.firma;
            _firma2            = data.firma2;
            DocRoot.PageHeight =
                ActualHeight
                - ImgHeader.ActualHeight
                - GrdHead.ActualHeight
                - GrdFooter.ActualHeight
                - LblTit.ActualHeight
                - LblInf.ActualHeight
                - 25
                - GrdPager.ActualHeight;
        }