Exemple #1
0
        private void tsmiImportFolder_Click(object sender, EventArgs e)
        {
            var path = OpenFolder();

            if (!string.IsNullOrEmpty(path))
            {
                var frm = new frmProgressBar();
                frm.Show();

                var files = new List <string>();
                var count = 1;

                foreach (var d in Directory.GetDirectories(path))
                {
                    foreach (var f in Directory.GetFiles(d))
                    {
                        files.Add(f);
                        frm.Status = $"Indexing... {count++} files!";
                        Application.DoEvents();
                    }
                }

                for (int i = 0; i < files.Count; i++)
                {
                    MediaAdd(files[i]);
                    frm.Status   = $"Importing... {i + 1} of {files.Count} files\nAdding to queue: {files[i]}";
                    frm.Progress = (int)(((float)(i + 1) / files.Count) * 100.0);
                    Application.DoEvents();
                }
            }
        }
Exemple #2
0
        private void tsmiImportFolder_Click(object sender, EventArgs e)
        {
            var files = Get.FilesRecursive();
            var frm   = new frmProgressBar();

            if (files.Count == 0)
            {
                return;
            }

            frm.Show();
            frm.Text   = Language.Lang.PleaseWait;
            frm.Status = Language.Lang.ReadProjectFile;

            var thread = new BackgroundWorker();

            thread.DoWork += delegate(object o, DoWorkEventArgs r)
            {
                for (int i = 0; i < files.Count; i++)
                {
                    AddMedia(files[i]);

                    if (InvokeRequired)
                    {
                        Invoke(new MethodInvoker(delegate
                        {
                            frm.Progress = (int)(((float)(i + 1) / files.Count) * 100.0);
                            frm.Status   = string.Format(Language.Lang.ProgressBarImport.Message, i + 1, files.Count, files[i]);
                            frm.Text     = Language.Lang.ProgressBarImport.Title + $": {frm.Progress}%";

                            //Application.DoEvents();
                        }));
                    }
                }
            };

            thread.RunWorkerCompleted += delegate(object o, RunWorkerCompletedEventArgs r)
            {
                frm.Close();
            };

            thread.RunWorkerAsync();
        }