Example #1
0
        public Sous_titre Coupage(StreamReader sr, string l)
        {
            int erreur;

            do // on boucle et essaye de convertir la ligne tant qu'on est pas à la première ligne de chaque bloque c'est a dire le numéro du st
            {
                erreur = 1;
                try
                {
                    int nbr_st = Convert.ToInt32(l);
                }
                catch (FormatException)
                {
                    l      = sr.ReadLine();
                    erreur = 0;
                }
            } while (erreur == 0);
            l = sr.ReadLine();
            string[] separator   = new string[] { " --> " };
            string[] time_st     = l.Split(separator, StringSplitOptions.RemoveEmptyEntries); //la deuxième option sert à virer les champs vide
            string   time_st_deb = time_st[0].Remove(8, 1);                                   // on enlève la virgule pour assembler les secondes et millisecondes
            string   time_st_fin = time_st[1].Remove(8, 1);

            Sous_titre st_next = new Sous_titre(time_st_deb.Split(':'), time_st_fin.Split(':'), sr.ReadLine(), sr.ReadLine());

            return(st_next);
        }
Example #2
0
        /* public async Task<string> Pause() //Essaie de la fonction pour faire pause, blocage pour récupérer une saisie d'utilisateur en asynchrone
         * {
         *   string t = Task.Run(() => Console.ReadLine());
         *   return t;
         * }*/
        /*public async Task Lire(Sous_titre st, int timer_end) //Fonction Lire sans le timer, avec des await
         * {
         *  int ancien = 0;
         *  Console.ForegroundColor = this.couleur;
         *  Console.Clear();
         *  CentrerLeTexte("Le film va pouvoir commencer, asseyez-vous au fond de votre chaise et prenez votre bol de pop corn");
         *  await Task.Delay(3000);
         *  Console.Clear();
         *  do
         *  {
         *      await Task.Delay(st.start - ancien);
         *      CentrerLeTexte(st.st1);
         *      CentrerLeTexte(st.st2);
         *      await Task.Delay(st.end - st.start);
         *      Console.Clear();
         *      ancien = st.end;
         *      st = st.next;
         *  } while (st != null);
         * }*/
        public async Task Lire(Sous_titre st, int timer_end) //Fonction Lire avec le timer
        {
            int ancien = 0;

            Console.ForegroundColor = this.couleur;
            Console.Clear();
            CentrerLeTexte("Le film va pouvoir commencer, asseyez-vous au fond de votre chaise et prenez votre bol de pop corn");
            await Task.Delay(3000);

            Console.Clear();
            Stopwatch chrono = new Stopwatch();

            chrono.Start();
            TimeSpan ts    = chrono.Elapsed;
            string   temps = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds);

            do
            {
                //string pause = Pause();
                while (chrono.ElapsedMilliseconds != st.start)
                {
                    AfficherChrono(chrono, ts, temps);
                }
                CentrerLeTexte(st.st1);
                CentrerLeTexte(st.st2);
                while (chrono.ElapsedMilliseconds != st.end)
                {
                    AfficherChrono(chrono, ts, temps);
                }
                Console.Clear();
                ancien = st.end;
                st     = st.next;
            } while (chrono.IsRunning && st != null);
        }
        public Sous_titre next; //stock le sous-titre prochain

        public Sous_titre(string[] Start, string[] End, string St1, string St2)
        {
            //On convertit les durées en millisecondes
            start = Convert.ToInt32(Start[0]) * 3600000 + Convert.ToInt32(Start[1]) * 60000 + Convert.ToInt32(Start[2]);
            end   = Convert.ToInt32(End[0]) * 3600000 + Convert.ToInt32(End[1]) * 60000 + Convert.ToInt32(End[2]);
            st1   = St1;
            st2   = St2;
            next  = null;
        }
Example #4
0
 public Sous_titre Initialiser_St()
 {
     using (StreamReader sr = new StreamReader(path))
     {
         string     l  = "";
         Sous_titre st = Coupage(sr, sr.ReadLine());
         st.head = st;
         while ((l = sr.ReadLine()) != null)
         {
             st.next      = Coupage(sr, l);
             st.next.head = st.head;
             st           = st.next;
         }
         return(st);
     }
 }
        static void Main(string[] args)
        {
            string  path_opt = @"C:\Users\jerem\Documents\CoursYnov\2020_2021\C\Options.txt";
            Fichier options  = new Fichier(path_opt);

            Task.WaitAll(options.LectureOptions());
            string path = ChoixPath(options.langue);


            Fichier film = new Fichier(path);

            film.langue  = options.langue;
            film.couleur = options.couleur;
            Sous_titre st = film.Initialiser_St();

            Console.Clear();
            Task.WaitAll(film.Lire(st.head, st.end));
        }