Exemple #1
0
        public void TutoPatchItemClick(object sender, MouseButtonEventArgs e)
        {
            var item          = sender as ListViewItem;
            var info          = (Tuple <EditorModel, int>)item.Tag;
            var model         = info.Item1;
            var index         = info.Item2;
            var epInfo        = model.Montage.Information.Episodes[index];
            var assembledName = model.Locations.GetOutputFile(index).FullName;

            if (File.Exists(assembledName))
            {
                addTrack(assembledName, true, index, model);
            }
            else
            {
                MessageBox.Show("Work in process. Track will be added after asssemblying");
                var work = new AssemblyEpisodeWork(model, epInfo);
                work.TaskFinished += (s, a) => { Dispatcher.Invoke(() => addTrack(assembledName, true, index, model)); };
                Program.WorkQueue.Run(work);
            }
        }
Exemple #2
0
        public static int Assemble(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Arguments missing, required: path to videotheque; guid to assemble; path to desired output");
                return(1);
            }
            var videotheque = Videotheque.Load(args[0], new ConsoleLoadingUI(), false, "..\\..\\..\\Tuto.Navigator\\bin\\Debug");

            Console.WriteLine("Videotheque loaded");
            Console.WriteLine();

            Guid guid = Guid.Empty;

            try
            {
                guid = Guid.Parse(args[1]);
            }
            catch
            {
                Console.WriteLine("GUID '" + args[1] + "' is not a correct guid");
                return(1);
            }
            var model = videotheque.EditorModels.Where(z => z.Montage.Information.Episodes.Any(x => x.Guid == guid)).FirstOrDefault();

            if (model == null)
            {
                Console.WriteLine("GUID '" + args[1] + "' is not found in videotheque");
                return(1);
            }
            var episode = model.Montage.Information.Episodes.Where(z => z.Guid == guid).FirstOrDefault();

            var work = new AssemblyEpisodeWork(model, episode);

            Console.WriteLine(work.Name);
            Console.WriteLine("Press ESC to cancel");
            work.SubsrcibeByExpression(z => z.Progress, () => Console.Write("\r{0:0.00}%        ", work.Progress));


            var queue = new WorkQueue(videotheque.Data.WorkSettings);

            queue.Dispatcher = Dispatcher.CurrentDispatcher;
            queue.Run(new[] { work });
            while (work.Status == BatchWorkStatus.Running || work.Status == BatchWorkStatus.Pending)
            {
                Thread.Sleep(10);
                if (Console.KeyAvailable)
                {
                    if (Console.ReadKey(true).Key == ConsoleKey.Escape)
                    {
                        queue.CancelTask(null);
                        Environment.Exit(1);
                        return(1);
                    }
                }
            }

            if (work.Status == BatchWorkStatus.Success)
            {
                if (File.Exists(args[2]))
                {
                    File.Delete(args[2]);
                }
                File.Move(model.Locations.GetOutputFile(episode).FullName, args[2]);
                Environment.Exit(0);
                return(0);
            }


            var errors = work.WorkTree.Select(z => z.ExceptionMessage).Where(z => !string.IsNullOrEmpty(z)).ToList();

            foreach (var e in errors)
            {
                Console.WriteLine(e);
            }

            Environment.Exit(1);
            return(1);
        }