Exemple #1
0
        /// <summary>
        ///     Queues the tracks.
        /// </summary>
        /// <param name="tracks">The tracks.</param>
        private void QueueTracks(List <Track> tracks, TrackSelector.GenerateDirection direction)
        {
            if (tracks.Count == 0)
            {
                return;
            }

            if (direction == TrackSelector.GenerateDirection.Forwards)
            {
                var currentTrackCount    = PlaylistControl.GetTracks().Count;
                var additionalTrackCount = tracks.Count - currentTrackCount;

                if (additionalTrackCount <= 0)
                {
                    return;
                }

                tracks.Reverse();
                tracks = tracks.Take(additionalTrackCount).ToList();
                tracks.Reverse();

                //this.PlaylistControl.ClearTracks();
                PlaylistControl.QueueTracks(tracks);
            }
            else
            {
                this.PlaylistControl.ClearTracks();
                PlaylistControl.QueueTracks(tracks);
            }
        }
Exemple #2
0
        private void InitializePlaylistControl()
        {
            // add playlist control
            _playlistControl      = new PlaylistControl();
            _playlistControl.Dock = DockStyle.Fill;
            PlaylistControlPanel.Controls.Add(_playlistControl);

            // attach to its events
            _playlistControl.SelectionChangedEvent += new PlaylistControl.PlaylistSelectionActionEventHandler(OnPlaylistSelectionChangedEvent);
        }
Exemple #3
0
        public PlaylistForm()
        {
            InitializeComponent();

            _playlistControl      = new PlaylistControl();
            _playlistControl.Dock = DockStyle.Fill;
            PlaylistPanel.Controls.Add(_playlistControl);

            // forward events from control
            _playlistControl.ItemDoubleClickedEvent += new PlaylistControl.PlaylistActionEventHandler(OnPlaylistDoubleClick);
            _playlistControl.SelectionChangedEvent  += new PlaylistControl.PlaylistSelectionActionEventHandler(OnPlaylistSelectionChanged);
        }
        private void SaveAsPlaylistMenuItem_Click(object sender, EventArgs e)
        {
            var dialog = new SaveFileDialog
            {
                DefaultExt       = ".m3u",
                AddExtension     = true,
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                SelectedPlaylist.SaveTo(dialog.FileName);
                PlaylistControl.SelectedTab.Text = SelectedPlaylist.Name;
                PlaylistControl.Refresh();
            }
        }
Exemple #5
0
        /// <summary>
        ///     Handles the DoWork event of the backgroundWorker control.
        /// </summary>
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <Track> availableTracks;

            if (chkDisplayedTracksOnly.Checked)
            {
                availableTracks = _displayedTracks;
            }
            else
            {
                availableTracks = LibraryControl
                                  .AvailableTracks
                                  .Where(t => t.IsShufflerTrack)
                                  .ToList();
            }

            var strategy =
                (TrackSelector.MixStrategy)
                Enum.Parse(typeof(TrackSelector.MixStrategy), cmbMode.GetTextThreadSafe().Replace(" ", ""));

            Dictionary <string, Dictionary <string, Track> > excludedMixes = null;

            if (txtExcludeTracks.Text != "" && File.Exists(txtExcludeTracks.Text))
            {
                var excludeTracks = PlaylistHelper.GetFilesInPlaylist(txtExcludeTracks.Text)
                                    .Select(f => LibraryControl.Library.GetTrackByFilename(f))
                                    .Where(t => t != null)
                                    .ToList();

                if (chkExlcudeMixesOnly.Checked)
                {
                    if (excludeTracks.Count > 1)
                    {
                        excludedMixes = LibraryControl.MixLibrary.ConvertPlaylistToMixDictionary(excludeTracks);
                    }
                }
                else
                {
                    var excludeTrackTitles = excludeTracks
                                             .Select(t => t.Title)
                                             .ToList();
                    availableTracks.RemoveAll(t => excludeTrackTitles.Contains(t.Title));
                }
            }

            var bpmDirection =
                (TrackSelector.BpmDirection)Enum.Parse(typeof(TrackSelector.BpmDirection), cmbBmpDirection.GetTextThreadSafe());

            var direction =
                (TrackSelector.GenerateDirection)Enum.Parse(typeof(TrackSelector.GenerateDirection), cmbDirection.GetTextThreadSafe());


            var allowBearable =
                (TrackSelector.AllowBearableMixStrategy)
                Enum.Parse(typeof(TrackSelector.AllowBearableMixStrategy),
                           cmbAllowBearable.GetTextThreadSafe().Replace(" ", ""));

            var approxLength = int.MaxValue;

            if (_screenMode == ScreenMode.GeneratePlaylist)
            {
                var comboText = cmbApproxLength.GetTextThreadSafe().Replace(" minutes", "");
                if (comboText != "No limit")
                {
                    approxLength = Convert.ToInt32(comboText);
                }
            }

            var continueMix =
                (TrackSelector.ContinueMix)
                Enum.Parse(typeof(TrackSelector.ContinueMix), cmbContinueMix.GetTextThreadSafe().Replace(" ", ""));

            var keyMixStrategy =
                (TrackSelector.KeyMixStrategy)
                Enum.Parse(typeof(TrackSelector.KeyMixStrategy), cmbKeyMixing.GetTextThreadSafe().Replace(" ", ""));

            var useExtendedMixes =
                (TrackSelector.UseExtendedMixes)
                Enum.Parse(typeof(TrackSelector.UseExtendedMixes),
                           cmbExtendedMixes.GetTextThreadSafe().Replace(" ", ""));

            var tracksToAdd = int.MaxValue;

            if (_screenMode == ScreenMode.AutoGeneratePlaylist)
            {
                tracksToAdd = Convert.ToInt32(cmbTracksToGenerate.GetTextThreadSafe());
            }

            var mixPath = TrackSelector.GeneratePlayList(availableTracks,
                                                         LibraryControl.MixLibrary,
                                                         PlaylistControl.GetTracks(),
                                                         bpmDirection,
                                                         approxLength,
                                                         allowBearable,
                                                         strategy,
                                                         useExtendedMixes,
                                                         excludedMixes,
                                                         chkRestrictArtistClumping.Checked,
                                                         chkRestrictGenreClumping.Checked,
                                                         chkRestrictTitleClumping.Checked,
                                                         continueMix,
                                                         keyMixStrategy,
                                                         tracksToAdd,
                                                         direction);

            if (!_cancel)
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new MethodInvoker(() => QueueTracks(mixPath, direction)));
                }
                else
                {
                    QueueTracks(mixPath, direction);
                }
            }
        }