コード例 #1
0
ファイル: Form1.cs プロジェクト: balderi/Thumbnailer
        private void btnStart_Click(object sender, EventArgs e)
        {
            logger.LogInfo($"Starting conversion");
            int count = fileListBox.Items.Count;

            if (count > 0)
            {
                logger.LogInfo($"Building {count} sheets...");
                tsProcessing.Text = "Starting image capture...";
                foreach (var f in fileListBox.Items)
                {
                    sheets.Add(ContactSheetFactory.CreateContactSheet(f.ToString(), logger));
                }

                tsProcessing.Text = "Processing...";
                Refresh();

                curFile            = 0;
                tsPbar.Value       = 0;
                tsPbar.Maximum     = count;
                tsCurrentFile.Text = curFile.ToString();
                tsTotalFiles.Text  = count.ToString();
                DisableItems();
                sheets.ForEach(x => x.SheetPrinted += SheetPrinted);
                ContactSheet.AllSheetsPrinted      += AllSheetsPrinted;
                logger.LogInfo($"Converting {count} files...");
                ContactSheet.PrintSheetsParallel(sheets, _currentConfig, logger, true, tbOutput.Text); //TODO: Replace 'true' with overwrite option
            }
            else
            {
                MessageBox.Show("No files loaded.");
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: balderi/Thumbnailer
        static async Task Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Too few arguments. Use -h or --help for help.");
                return;
            }

            logger = new Logger();
            sheets = new List <ContactSheet>();

            foreach (string arg in args)
            {
                if (arg[0] == '-')
                {
                    try
                    {
                        ParseFlag(arg);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        Environment.Exit(1);
                    }
                }
                else if (sourcePath is null)
                {
                    sourcePath = arg;
                }
                else if (configPath is null)
                {
                    configPath = arg;
                }
            }

            if (configPath is null)
            {
                configPath = "default.xml";
            }

            config = Config.Load(configPath);

            List <string> files = (List <string>)Loader.LoadFiles(sourcePath, recurse);

            totalFiles = files.Count;
            logger.LogInfo($"Building {totalFiles} sheets...");
            PrintMsg($"Building {totalFiles} sheets...\n");
            int count = 0;

            foreach (var f in files)
            {
                var sheet = ContactSheetFactory.CreateContactSheet(f, logger);
                if (verbose)
                {
                    sheet.SheetPrinted += SheetPrinted;
                }
                sheets.Add(sheet);
                PrintOverMsg($"Built {++count}/{totalFiles} sheets...");
            }

            curFile = 0;

            ContactSheet.AllSheetsPrinted += AllSheetsPrinted;
            logger.LogInfo($"Printing {count} sheets...");
            PrintMsg($"Printing {count} sheets...\n");
            ContactSheet.PrintSheetsParallel(sheets, config, logger, overwrite: overwrite);

            //Wait forever until the AllSheetsPrinted event is fired
            await Task.Delay(-1);
        }