示例#1
0
        private void btnVerMapa_Click(object sender, RoutedEventArgs e)
        {
            Int16 id = Convert.ToInt16(((Button)sender).Tag.ToString());
            Entrenamiento entren;
            using (IObjectContainer container = Db4oEmbedded.OpenFile("BikeTrain.db4o"))
            {
                entren = (from Entrenamiento ent in container
                          where ent.ID == id
                          select ent).First();

            }

            if (entren.gpx)
            {
                Map map = new Map(id);
                map.Show();
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Esta ruta no tiene GPX", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#2
0
文件: PDF.cs 项目: roomm/BikeTrain
        public static void crearPDF(int id)
        {
            Entrenamiento ent = getEntrenamiento(id);
            System.IO.FileStream fs = new FileStream(Path.GetTempPath() + id + ".pdf", FileMode.Create);
            Document document = new Document(PageSize.A4, 25, 25, 30, 30);
            PdfWriter writer = PdfWriter.GetInstance(document, fs);
            document.Open();
            PdfContentByte cb = writer.DirectContent;
            BaseFont f_cn = BaseFont.CreateFont("c:\\windows\\fonts\\calibri.ttf", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            cb.BeginText();
            cb.SetFontAndSize(f_cn, 18);

            //principales
            cb.SetTextMatrix(90, 780);
            cb.ShowText("Fecha: " + ent.Fecha.ToShortDateString());
            cb.SetTextMatrix(330, 780);
            cb.ShowText("Distancia: " + ent.Distancia + " Km");
            cb.SetTextMatrix(90, 750);
            string horas = ent.Tiempo.Hours != 0 ? ent.Tiempo.Hours + "h " : "";
            string mins = ent.Tiempo.Minutes != 0 ? ent.Tiempo.Minutes + "min " : "";
            string secs = ent.Tiempo.Seconds != 0 ? ent.Tiempo.Seconds + "sec " : "";
            cb.ShowText("Tiempo: " + horas + mins + secs);
            cb.SetTextMatrix(330, 750);
            cb.ShowText("Lugar: " + ent.Lugar);

            //secundarios
            cb.SetTextMatrix(90, 700);
            cb.ShowText("Ascenso: " + ent.Ascenso + " m");
            cb.SetTextMatrix(330, 700);
            cb.ShowText("Descenso: " + ent.Descenso + " m");

            cb.SetTextMatrix(90, 670);
            cb.ShowText("Vel. Med: " + ent.VelMed + " km/h");
            cb.SetTextMatrix(330, 670);
            cb.ShowText("Vel. Max: " + ent.VelMax + " km/h");

            cb.SetTextMatrix(90, 640);
            cb.ShowText("Ritm. Prom: " + ent.RitmoPromedio + " km/min");
            cb.SetTextMatrix(330, 640);
            cb.ShowText("Hidratación: " + ent.Hidratacion + " L");

            cb.SetTextMatrix(90, 610);
            cb.ShowText("Kcal: " + ent.Kcal);
            cb.SetTextMatrix(330, 610);
            cb.ShowText("PPM: " + ent.PPM);

            cb.SetTextMatrix(85, 205);
            cb.ShowText("Observaciones");

            cb.SetTextMatrix(90, 180);
            cb.ShowText(ent.Observaciones);

            cb.EndText();

            cb.Rectangle(85, 740, 430, 60);
            cb.Stroke();

            cb.Rectangle(85, 600, 430, 120);
            cb.Stroke();

            if (ent.gpx)
            {
                Map mp = new Map(id);
                mp.getThumbail(id);
                iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(Path.GetTempPath() + id + ".png");
                img.SetAbsolutePosition(80, 280);
                cb.AddImage(img);
            }
            else
            {
                cb.BeginText();
                cb.SetFontAndSize(f_cn, 60);
                cb.SetRGBColorFill(255, 0, 0);
                cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "SIN MAPA", 300, 430, 45);

                cb.EndText();

                cb.Rectangle(85, 280, 430, 300);
                cb.Stroke();
            }

            cb.Rectangle(85, 100, 430, 100);
            cb.Stroke();

            document.Close();
            writer.Close();
            fs.Close();

            Process.Start(Path.GetTempPath() + id + ".pdf");
        }