예제 #1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbDisplayName.Text))
            {
                MessageBox.Show(this, "表示名を入力してください");
                return;
            }

            var input = new InputData()
            {
                DisplayName      = tbDisplayName.Text,
                TwitterAccount   = tbTwitter.Text,
                FacebookAccount  = tbFacebook.Text,
                InstagramAccount = tbInstagram.Text,
                AmebloAccount    = tbAmeblo.Text
            };

            File.WriteAllText($"{input.DisplayName}.json", JsonConvert.SerializeObject(input));
            var pr = new PrintData();
            await pr.Load(input);

            var printer = new SinglePdfProcessor(pr);

            try
            {
                printer.Print();
                MessageBox.Show(this, "出力が完了しました。");
                Process.Start(pr.OutputPath);
            }
            catch (Exception xe)
            {
                MessageBox.Show(this, xe.ToString());
            }
        }
예제 #2
0
        static async Task Main(string[] args)
        {
            if (args.Length > 0)
            {
                AllocConsole();
                Console.WriteLine($"Read file:{args[0]}");
                try
                {
                    var outputs = await Task.WhenAll(JsonConvert.DeserializeObject <InputData[]>(File.ReadAllText(args[0]))
                                                     .Select(async x =>
                    {
                        var pr = new PrintData();
                        await pr.Load(x);
                        var printer = new SinglePdfProcessor(pr);
                        printer.Print();
                        Console.WriteLine(pr.OutputPath);
                        return(pr.OutputPath);
                    }));

                    var mp = new MergePdfProcessor(outputs);
                    mp.Merge();
                    Console.WriteLine(mp.OutputPath);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);

                    Console.ReadKey();
                }
                finally
                {
                    FreeConsole();
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
        }