Exemple #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var form = new MainForm();

            var configuration    = new Configuration("config.ini");
            var logger           = new Logger(form);
            var input            = new Input(configuration.InputFile);
            var delayedInput     = new DelayedInput(input, configuration);
            var output           = new Output(configuration.DownloadDirectory);
            var activeDownloads  = new ActiveDownloads(logger);
            var directoryMonitor = new DirectoryMonitor(configuration.UploadDirectory, input);
            var PdfGenerator     = new HtmlToPdfGenerator(output, configuration, activeDownloads, directoryMonitor);

            activeDownloads.OnChange = (item) =>
            {
                var lines = activeDownloads.GetActiveItems()
                            .Select(x => string.Format("{0} {1}", x.Id, x.Uri))
                            .ToArray();

                form.SetActiveList(lines);
            };

            //#if DEBUG
            //// remove this line in production
            //Directory.CreateDirectory(configuration.DownloadDirectory);
            //Directory.CreateDirectory(configuration.UploadDirectory);
            //#endif
            var DownloadManager = new DownloadManager(delayedInput, output, configuration, activeDownloads, logger, directoryMonitor, PdfGenerator);



            Application.Run(form);
        }
        public void ReportStatus()
        {
            var text = string.Join(Environment.NewLine,
                                   ActiveDownloads.GetActiveItems().Select(item => string.Format("{0},{1}", item.Id, item.Uri)));

            if (text != LastStatusText)
            {
                LastStatusText = text;
                File.WriteAllText(Configuration.StatusFile, text);
            }
        }