private void OKCancelBox_OKClicked(object sender, EventArgs e)
        {
            this.release.DateAudioModified = DateTime.Now;

            IEncoderFactory encoderFactory;
            if (this.CollectionManager.Settings.NetworkEncoding)
            {
                encoderFactory = new RemoteFlacEncoderFactory(this.networkBox.Servers, 8, this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true);
            }
            else
            {
                encoderFactory = new NativeFlacEncoderFactory(8, this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true);
            }

            IEncoderFactory replayGainFactory = new DspEncoderFactory(this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true);

            ReplayGainTask rgTask = new ReplayGainTask(replayGainFactory, this.release, true, true, true);

            List<IParallelTask> tasks = new List<IParallelTask>();
            for (int i = 0; i < this.items.Count; ++i)
            {
                Track track = this.release.Tracklist[i];
                IImportSourceItem importSourceItem = this.items[i];

                track.RelativeFilename = FilenameGenerator.PatternToFilename(
                        this.CollectionManager.Settings.FileNamingPattern,
                        this.release, track) + ".flac";

                AudioFileTag tag = new AudioFileTag(this.release, track);

                string filename = Path.Combine(this.CollectionManager.Settings.MusicDirectory, track.RelativeFilename);

                var task = new FileEncodeTask(
                    encoderFactory,
                    () => importSourceItem.GetAudioSource(),
                    filename,
                    tag
                    );
                tasks.Add(task);
                rgTask.AddItem(track, task);
            }

            tasks.Add(rgTask);

            int concurrency = Math.Max(encoderFactory.ThreadCount, replayGainFactory.ThreadCount);
            EncoderController controller = new EncoderController(tasks.ToArray(), concurrency);
            EncodingWindow window = new EncodingWindow(controller);
            if (window.ShowDialog(this) == true)
            {
                this.release.UpdateDynamicProperties();
                this.CollectionManager.Save(this.release);

                this.Close();
            }

            CollectionManagerGlobal.OnCollectionChanged();
        }
        private void OKCancelBox_OKClicked(object sender, System.EventArgs e)
        {
            this.UpdateRelease();

            IEncoderFactory encoderFactory;
            if (this.CollectionManager.Settings.NetworkEncoding)
            {
                encoderFactory = new RemoteFlacEncoderFactory(this.networkBox.Servers, 8, this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true);
            }
            else
            {
                encoderFactory = new NativeFlacEncoderFactory(8, this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true);
            }

            IEncoderFactory replayGainFactory = new DspEncoderFactory(this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true);

            ReplayGainTask rgTask = new ReplayGainTask(replayGainFactory, this.DatabaseRelease, true, true, true);

            List<IParallelTask> tasks = new List<IParallelTask>();
            foreach (Track track in this.DatabaseRelease.Tracklist)
            {
                track.RelativeFilename = FilenameGenerator.PatternToFilename(
                        this.CollectionManager.Settings.FileNamingPattern,
                        this.DatabaseRelease, track) + ".flac";

                AudioFileTag tag = new AudioFileTag(this.DatabaseRelease, track);
                IImportSourceItem sourceItem = this.Release.Discs[track.Disc - 1][track.Position - 1].SourceItem;

                string filename = Path.Combine(this.CollectionManager.Settings.MusicDirectory, track.RelativeFilename);

                var task = new FileEncodeTask(
                    encoderFactory,
                    () => sourceItem.GetAudioSource(),
                    filename,
                    tag
                    );
                tasks.Add(task);
                rgTask.AddItem(track, task);
            }

            tasks.Add(rgTask);

            int concurrency = Math.Max(encoderFactory.ThreadCount, replayGainFactory.ThreadCount);
            EncoderController controller = new EncoderController(tasks.ToArray(), concurrency);
            EncodingWindow window = new EncodingWindow(controller);
            if (window.ShowDialog(this) == true)
            {
                this.DatabaseRelease.UpdateDynamicProperties();

                this.CollectionManager.Save(this.DatabaseRelease);
                this.InsertedReleaseId = this.DatabaseRelease.Id;

                this.imagesEditor.WriteFiles();

                CollectionManagerGlobal.OnCollectionChanged();

                this.completed = true;
                this.DialogResult = true;
            }
        }