Esempio n. 1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            dlg.Filter           = "Pdf Files|*.pdf";
            dlg.Multiselect      = true;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                double time = 0;
                button1.Enabled = false;
                label2.Text     = "Розраховується час виконання...";
                label2.Visible  = true;
                for (int i = 0; i < dlg.FileNames.Length; i++)
                {
                    time += TimeCalc.CalculateTimeForFiles(dlg.FileNames[i]);
                    //Cutter.DeleteJpeg();
                }

                label1.Visible = true;
                //label2.Text = TimeCalc.MinuteSeconds(TimeCalc.CalculateTimeForFiles(dlg.FileNames[i])).ToString();

                for (int i = 0; i < dlg.FileNames.Length; i++)
                {
                    label2.Text = $"Файл {i + 1} з {dlg.FileNames.Length}";

                    //label2.Text = TimeCalc.TimeCutPage(dlg.FileNames[i]).ToString()+"\n";
                    //label2.Text += TimeCalc.TimeGeneratePage()+"\n";
                    ProgressBar progressBar = new ProgressBar();
                    progressBar.Name     = progressBar + i.ToString();
                    progressBar.Location = new Point(12, 100);
                    progressBar.Width    = 284;
                    progressBar.Height   = 30;
                    this.Controls.Add(progressBar);
                    await Task.Run(() => Cutter.ConvertToImg(dlg.FileNames[i], ref progressBar, ref time, ref label1));

                    await Task.Run(() => Cutter.GeneratePdf(ref progressBar, i.ToString(), ref time, ref label1, dlg.FileNames[i]));

                    this.Controls.Remove(progressBar);
                    // label2.Visible = false;
                }
            }
            label1.Text     = "";
            label2.Text     = "";
            button1.Enabled = true;
        }
Esempio n. 2
0
        private async void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string[] FileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
            button1.Enabled = false;
            double time = 0;

            button1.Enabled = false;
            label2.Text     = "Розраховується час виконання...";
            label2.Visible  = true;
            for (int i = 0; i < FileNames.Length; i++)
            {
                time += TimeCalc.CalculateTimeForFiles(FileNames[i]);
                //Cutter.DeleteJpeg();
            }

            label1.Visible = true;
            //label2.Text = TimeCalc.MinuteSeconds(TimeCalc.CalculateTimeForFiles(dlg.FileNames[i])).ToString();

            for (int i = 0; i < FileNames.Length; i++)
            {
                label2.Text = $"Файл {i + 1} з {FileNames.Length}";

                //label2.Text = TimeCalc.TimeCutPage(dlg.FileNames[i]).ToString()+"\n";
                //label2.Text += TimeCalc.TimeGeneratePage()+"\n";
                ProgressBar progressBar = new ProgressBar();
                progressBar.Name     = progressBar + i.ToString();
                progressBar.Location = new Point(12, 100);
                progressBar.Width    = 284;
                progressBar.Height   = 30;
                this.Controls.Add(progressBar);
                await Task.Run(() => Cutter.ConvertToImg(FileNames[i], ref progressBar, ref time, ref label1));

                await Task.Run(() => Cutter.GeneratePdf(ref progressBar, i.ToString(), ref time, ref label1, FileNames[i]));

                this.Controls.Remove(progressBar);
                // label2.Visible = false;
            }
            label1.Text     = "";
            label2.Text     = "";
            button1.Enabled = true;
        }