public AudioFormatAnalysisWindow(ICollectionSessionFactory factory)
            : base(factory)
        {
            this.bucketCollection = new FormatBucketCollection();
            this.localBuckets     = new FormatBucketCollection();
            this.fileBuckets      = new ObservableCollection <FileBucket>();
            this.localFileBuckets = new ObservableCollection <FileBucket>();

            InitializeComponent();

            this.listFormats.ItemsSource = this.bucketCollection;
            this.listFiles.ItemsSource   = this.fileBuckets;

            this.ProgressChanged += ProgressBarUpdater.CreateHandler(this.Dispatcher, this.busyIndicator, () => false, p =>
            {
                this.bucketCollection.Add(this.localBuckets);
                this.localBuckets.Clear();
                this.fileBuckets.AddRange(this.localFileBuckets);
                this.localFileBuckets.Clear();
            });
            new Task(this.CalculateAudioFormats).Start();
        }
 public void Add(FormatBucketCollection formatCollection)
 {
     foreach (FormatBucket otherBucket in formatCollection)
     {
         foreach (FormatBucket bucket in this)
         {
             if (otherBucket.Channels == bucket.Channels &&
                 otherBucket.BitsPerSample == bucket.BitsPerSample &&
                 otherBucket.SampleRate == bucket.SampleRate)
             {
                 bucket.Tracks += otherBucket.Tracks;
                 return;
             }
         }
         this.Add(new FormatBucket()
         {
             Channels      = otherBucket.Channels,
             SampleRate    = otherBucket.SampleRate,
             BitsPerSample = otherBucket.BitsPerSample,
             Tracks        = otherBucket.Tracks
         });
     }
 }