コード例 #1
0
        private void FillFiles(string[] filePaths, string folderName)
        {
            this.label1.Text = folderName;

            var counter = 1;

            for (int i = 0; i < _bindingSource.Count; i++)
            {
                if (((Row)_bindingSource[i]).Path == null)
                {
                    _bindingSource.RemoveAt(i);
                }
            }

            foreach (var filePath in filePaths)
            {
                ProcessingLabel.Text = counter + " sur " + filePaths.Length;
                ProcessingLabel.Refresh();

                var date    = Metadata.GetDate(filePath);
                var newDate = Metadata.ExtractNewDate(filePath);
                _bindingSource.Add(new Row {
                    Path = filePath, CurrentDate = date, ExpectedDate = newDate
                });

                counter++;
            }

            this.dataGridView.DataSource = _bindingSource;

            this.status.Text      = "Ready";
            this.status.ForeColor = Color.Black;
        }
コード例 #2
0
        private void FillFiles(string[] filePaths, string folderName)
        {
            this.label1.Text = folderName;

            var counter = 1;

            foreach (var filePath in filePaths)
            {
                ProcessingLabel.Text = counter + " sur " + filePaths.Count();
                ProcessingLabel.Refresh();

                string fileName = filePath;

                string prefix = folderName.Split('-').First() + "-";
                string file   = fileName.Split('\\').Last();
                string path   = fileName.Replace(file, "");

                string extension = "." + file.Split('.').Last();

                string zeroToAdd = "";

                if (filePaths.Count() > 100)
                {
                    if (counter < 10)
                    {
                        zeroToAdd = "00";
                    }
                    else if (counter < 100)
                    {
                        zeroToAdd = "0";
                    }
                    else
                    {
                        zeroToAdd = "";
                    }
                }
                else if (filePaths.Count() >= 10)
                {
                    zeroToAdd = counter < 10 ? "0" : "";
                }
                else if (filePaths.Count() < 11)
                {
                    zeroToAdd = "0";
                }

                file = prefix + zeroToAdd + counter;

                this.dataGridView.Rows.Add(fileName, path + file + extension);
                counter++;
            }
        }
コード例 #3
0
        private void ChangeDateTimeButtonClick(object sender, EventArgs e)
        {
            this.status.Text      = "Ongoing";
            this.status.ForeColor = Color.Gray;

            var counter = 1;

            foreach (var g in from DataGridViewRow g in this.dataGridView.Rows where g.Cells[0].Value != null && g.Cells[1].Value != null select g)
            {
                ProcessingLabel.Text = counter + " sur " + (this.dataGridView.RowCount - 1);
                ProcessingLabel.Refresh();

                Metadata.ChangeDateTime((string)g.Cells[0].Value, (DateTime)g.Cells[2].Value);
                counter++;
            }

            this.status.Text      = "DONE";
            this.status.ForeColor = Color.ForestGreen;

            this.ReloadDates();
        }
コード例 #4
0
        private void RenameButtonClick(object sender, EventArgs e)
        {
            // First use basic file names to avoid conflicts
            var count = 0;

            foreach (var g in from DataGridViewRow g in this.dataGridView.Rows where g.Cells[0].Value != null && g.Cells[1].Value != null select g)
            {
                var fileName = (string)g.Cells[0].Value;
                File.Move(fileName, fileName + "__" + count);
                count++;
            }

            // Then update to the final name
            count = 0;
            foreach (var g in from DataGridViewRow g in this.dataGridView.Rows where g.Cells[0].Value != null && g.Cells[1].Value != null select g)
            {
                ProcessingLabel.Text = count + 1 + " sur " + (this.dataGridView.Rows.Count - 1);
                ProcessingLabel.Refresh();

                File.Move((string)g.Cells[0].Value + "__" + count, (string)g.Cells[1].Value);
                count++;
            }
        }