// ===========================================================================
 /**
  * Draws the info about the movie.
  * @throws DocumentException 
  */
 protected override void DrawMovieInfo(
   Screening screening, PdfContentByte directcontent
 )
 {
     base.DrawMovieInfo(screening, directcontent);
     Rectangle rect = GetPosition(screening);
     ColumnText column = new ColumnText(directcontent);
     column.SetSimpleColumn(
       new Phrase(screening.movie.Title),
       rect.Left, rect.Bottom,
       rect.Right, rect.Top, 18, Element.ALIGN_CENTER
     );
     column.Go();
 }
 // ---------------------------------------------------------------------------   
 /**
  * Create a table with information about a movie.
  * @param screening a Screening
  * @return a table
  */
 private PdfPTable GetTable(Screening screening)
 {
     // Create a table with 4 columns
     PdfPTable table = new PdfPTable(4);
     table.SetWidths(new int[] { 1, 5, 10, 10 });
     // Get the movie
     Movie movie = screening.movie;
     // A cell with the title as a nested table spanning the complete row
     PdfPCell cell = new PdfPCell();
     // nesting is done with addElement() in this example
     cell.AddElement(FullTitle(screening));
     cell.Colspan = 4;
     cell.Border = PdfPCell.NO_BORDER;
     BaseColor color = WebColors.GetRGBColor(
       "#" + movie.entry.category.color
     );
     cell.BackgroundColor = color;
     table.AddCell(cell);
     // empty cell
     cell = new PdfPCell();
     cell.Border = PdfPCell.NO_BORDER;
     cell.UseAscender = true;
     cell.UseDescender = true;
     table.AddCell(cell);
     // cell with the movie poster
     cell = new PdfPCell(GetImage(movie.Imdb));
     cell.Border = PdfPCell.NO_BORDER;
     table.AddCell(cell);
     // cell with the list of directors
     cell = new PdfPCell();
     cell.AddElement(PojoToElementFactory.GetDirectorList(movie));
     cell.Border = PdfPCell.NO_BORDER;
     cell.UseAscender = true;
     cell.UseDescender = true;
     table.AddCell(cell);
     // cell with the list of countries
     cell = new PdfPCell();
     cell.AddElement(PojoToElementFactory.GetCountryList(movie));
     cell.Border = PdfPCell.NO_BORDER;
     cell.UseAscender = true;
     cell.UseDescender = true;
     table.AddCell(cell);
     return table;
 }
 // ---------------------------------------------------------------------------        
 /**
  * Draws a colored block on the time table, corresponding with
  * the screening of a specific movie.
  * @param    screening    a screening POJO, contains a movie and a category
  * @param    under    the canvas to which the block is drawn
  */
 protected void DrawBlock(
   Screening screening, PdfContentByte under, PdfContentByte over
 )
 {
     under.SaveState();
     BaseColor color = WebColors.GetRGBColor(
       "#" + screening.movie.entry.category.color
     );
     under.SetColorFill(color);
     Rectangle rect = GetPosition(screening);
     under.Rectangle(
       rect.Left, rect.Bottom, rect.Width, rect.Height
     );
     under.Fill();
     over.Rectangle(
       rect.Left, rect.Bottom, rect.Width, rect.Height
     );
     over.Stroke();
     under.RestoreState();
 }
Example #4
0
        // ---------------------------------------------------------------------------

        /**
         * Returns a list with Screening objects, if you pass
         * a stringified date.
         * @param day stringified date "yyyy-MM-dd"
         * @return a List of Screening POJOs
         */
        public static List <Screening> GetScreenings(string day)
        {
            List <Screening> list = new List <Screening>();

            using (var c = AdoDB.Provider.CreateConnection())
            {
                c.ConnectionString = AdoDB.CS;
                using (DbCommand cmd = c.CreateCommand())
                {
                    cmd.CommandText = AdoDB.SCREENINGS;
                    cmd.Parameters.Add(cmd.CreateParameter());
                    cmd.Parameters[0].ParameterName = "@day";
                    cmd.Parameters[0].Value         = day;
                    c.Open();
                    using (var r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            Screening screening = GetScreening(r);
                            Movie     movie     = GetMovie(r);
                            foreach (var d in GetDirectors(Convert.ToInt32(r["id"])))
                            {
                                movie.AddDirector(d);
                            }
                            foreach (var cn in GetCountries(Convert.ToInt32(r["id"])))
                            {
                                movie.AddCountry(cn);
                            }
                            Entry    entry    = GetEntry(r);
                            Category category = GetCategory(r);
                            entry.category  = category;
                            entry.movie     = movie;
                            movie.entry     = entry;
                            screening.movie = movie;
                            list.Add(screening);
                        }
                    }
                }
            }
            return(list);
        }
Example #5
0
        // ---------------------------------------------------------------------------

        /**
         * Returns a list with Screening objects
         * @return a List of Screening POJOs
         */
        public static List <Screening> GetPressPreviews()
        {
            List <Screening> list = new List <Screening>();

            using (var c = AdoDB.Provider.CreateConnection())
            {
                c.ConnectionString = AdoDB.CS;
                using (DbCommand cmd = c.CreateCommand())
                {
                    cmd.CommandText = AdoDB.PRESS;
                    c.Open();
                    using (var r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            Screening screening = GetScreening(r);
                            Movie     movie     = GetMovie(r);
                            int       film_id   = Convert.ToInt32(r["id"]);
                            foreach (Director d in GetDirectors(film_id))
                            {
                                movie.AddDirector(d);
                            }
                            foreach (Country country in GetCountries(film_id))
                            {
                                movie.AddCountry(country);
                            }
                            Entry    entry    = GetEntry(r);
                            Category category = GetCategory(r);
                            entry.category  = category;
                            entry.movie     = movie;
                            movie.entry     = entry;
                            screening.movie = movie;
                            list.Add(screening);
                        }
                    }
                }
            }
            return(list);
        }
 // ---------------------------------------------------------------------------
 /**
  * Calculates the position of a rectangle corresponding with a screening.
  * @param    screening    a screening POJO, contains a movie
  * @return    a Rectangle
  */
 protected Rectangle GetPosition(Screening screening)
 {
     float llx, lly, urx, ury;
     // long minutesAfter930 = (screening.getTime().getTime() - TIME930) / 60000L;
     long minutesAfter930 = (
       Utility.GetMilliseconds(screening.Time) - TIME930
     ) / 60000L;
     llx = OFFSET_LEFT + (MINUTE * minutesAfter930);
     int location = locations.IndexOf(screening.Location) + 1;
     lly = OFFSET_BOTTOM + (LOCATIONS - location) * HEIGHT_LOCATION;
     urx = llx + MINUTE * screening.movie.Duration;
     ury = lly + HEIGHT_LOCATION;
     Rectangle rect = new Rectangle(llx, lly, urx, ury);
     return rect;
 }
Example #7
0
 // ---------------------------------------------------------------------------
 /**
  * Adds a screening to this entry.
  */
 public void AddScreening(Screening screening)
 {
     _screenings.Add(screening);
 }
Example #8
0
        // ---------------------------------------------------------------------------

        /**
         * Adds a screening to this entry.
         */
        public void AddScreening(Screening screening)
        {
            _screenings.Add(screening);
        }
 // ---------------------------------------------------------------------------            
 /**
  * Draws the info about the movie.
  * @throws DocumentException 
  */
 protected virtual void DrawMovieInfo(
   Screening screening, PdfContentByte directcontent
 )
 {
     // if (true) {
     if (screening.Press)
     {
         Rectangle rect = GetPosition(screening);
         ColumnText.ShowTextAligned(
           directcontent,
           Element.ALIGN_CENTER,
           press, (rect.Left + rect.Right) / 2,
           rect.Bottom + rect.Height / 4, 0
         );
     }
 }
Example #10
0
 // ---------------------------------------------------------------------------       
 /**
  * Create a table with the full movie title
  * @param screening a Screening object
  * @return a table
  */
 private static PdfPTable FullTitle(Screening screening)
 {
     PdfPTable table = new PdfPTable(3);
     table.SetWidths(new int[] { 3, 15, 2 });
     table.WidthPercentage = 100;
     // cell 1: location and time
     PdfPCell cell = new PdfPCell();
     cell.Border = PdfPCell.NO_BORDER;
     cell.BackgroundColor = BaseColor.WHITE;
     cell.UseAscender = true;
     cell.UseDescender = true;
     String s = string.Format(
         // "{0} \u2013 %2$tH:%2$tM",
       "{0} \u2013 {1}",
       screening.Location,
       screening.Time.Substring(0, 5)
         // screening.Time().getTime()
     );
     cell.AddElement(new Paragraph(s));
     table.AddCell(cell);
     // cell 2: English and original title 
     Movie movie = screening.movie;
     Paragraph p = new Paragraph();
     p.Add(new Phrase(movie.MovieTitle, FilmFonts.BOLD));
     p.Leading = 16;
     if (!string.IsNullOrEmpty(movie.OriginalTitle))
     {
         p.Add(new Phrase(" (" + movie.OriginalTitle + ")"));
     }
     cell = new PdfPCell();
     cell.AddElement(p);
     cell.Border = PdfPCell.NO_BORDER;
     cell.UseAscender = true;
     cell.UseDescender = true;
     table.AddCell(cell);
     // cell 3 duration
     cell = new PdfPCell();
     cell.Border = PdfPCell.NO_BORDER;
     cell.BackgroundColor = BaseColor.WHITE;
     cell.UseAscender = true;
     cell.UseDescender = true;
     // p = new Paragraph(String.format("%d'", movie.getDuration()));
     p = new Paragraph(movie.Duration.ToString() + "'");
     p.Alignment = Element.ALIGN_CENTER;
     cell.AddElement(p);
     table.AddCell(cell);
     return table;
 }
 // ---------------------------------------------------------------------------
 /**
  * Checks if the screening has been sold out.
  * @param screening a Screening POJO
  * @return true if the screening has been sold out.
  */
 public bool IsSoldOut(Screening screening)
 {
     return screening.movie.MovieTitle.StartsWith("L")
       ? true : false
     ;
 }