Esempio n. 1
0
 protected virtual void OnDuplicateFound(
     VideoFile file1,
     VideoFile file2) =>
 DuplicateFound?.Invoke(this, new DuplicateFoundEventArgs
 {
     File1    = file1,
     File2    = file2,
     BasePath = CurrentState.Settings.BasePath,
 });
Esempio n. 2
0
        private void NotifyDuplicateFound(List <IFile> filelist, string hash, IFile file)
        {
            DuplicateFound onDuplicateFound = OnDuplicateFound;

            if (onDuplicateFound != null)
            {
                // Since each duplicate file is notified via an
                // individial event, we need to fire two events
                // when the first duplicate is detected
                if (filelist.Count == 2)
                {
                    foreach (IFile ff in filelist)
                    {
                        Action action = () => onDuplicateFound(hash, filelist.IndexOf(ff) + "-" + ff.Path, ff.GetSize());

                        if (dispatcher != null)
                        {
                            dispatcher.Execute(action);
                        }
                        else
                        {
                            action();
                        }
                    }
                }

                // After the third or greater is duplicate file
                // is found, we already know that the prior duplicate files
                // have had events fired for them, so we only need to
                // fire one event for the latest file found

                if (filelist.Count > 2)
                {
                    Action action = () => onDuplicateFound(hash, filelist.IndexOf(file) + "-" + file.Path, file.GetSize());

                    if (dispatcher != null)
                    {
                        dispatcher.Execute(action);
                    }
                    else
                    {
                        action();
                    }
                }
            }
        }
        protected virtual void OnDuplicateFound(int start, int length)
        {
            var duplicate = CreateReadOnlyList(start, length);

            DuplicateFound?.Invoke(this, new FileInfoReadOnlyListEventArgs(duplicate));
        }