Ejemplo n.º 1
0
        private void BeginProcessing(List <List <string> > duplicateResults)
        {
            DoInvoke((MethodInvoker) delegate()
            {
                duplicateList.BeginUpdate();
            });

            int max = 0;

            foreach (List <string> ss in duplicateResults)
            {
                foreach (string s in ss)
                {
                    max++;
                }
            }

            ProcessProgress progress = new ProcessProgress(max, "Processing");

            DoInvoke((MethodInvoker) delegate()
            {
                progress.Show(this);
            });

            int count = 0;
            int total = 0;

            foreach (List <string> dupeGroup in duplicateResults)
            {
                FileInfo f = new FileInfo(dupeGroup[0]);

                string headerKey = Hasher.md5(Encoding.ASCII.GetBytes(f.FullName));

                DoInvoke((MethodInvoker) delegate()
                {
                    duplicateList.Groups.Add(headerKey, f.Name);
                });

                foreach (string file in dupeGroup)
                {
                    ListViewItem i = new ListViewItem(duplicateList.Groups[headerKey]);
                    i.Text = new FileInfo(file).FullName;

                    DoInvoke((MethodInvoker) delegate()
                    {
                        duplicateList.Items.Add(i);
                    });

                    count++;
                    total++;
                    if (count > 50)
                    {
                        count = 0;
                        progress.UpdateProgress(total);
                    }
                    Application.DoEvents();
                }
            }
            DoInvoke((MethodInvoker) delegate()
            {
                progress.Close();
            });

            DoInvoke((MethodInvoker) delegate()
            {
                duplicateList.EndUpdate();
            });
        }