예제 #1
0
        public SongPropertiesWindow(MainForm mainForm, Song song, int clickedIndex, PlaylistBase currentPlaylist, Library library)
        {
            this.mainForm = mainForm;
            this.song = song;
            this.currentIndex = clickedIndex;
            this.currentPlaylist = currentPlaylist;
            this.library = library;

            InitializeComponent();
        }
예제 #2
0
        public MultiSongPropertiesWindow(MainForm mainForm, List<Song> songs, PlaylistBase currentPlaylist, Library library)
        {
            this.mainForm = mainForm;
            this.songs = songs;
            this.currentPlaylist = currentPlaylist;
            this.library = library;
            this.saveProperties = new Dictionary<string, bool>();
            InitializeComponent();

            save_ComboBox.SelectedIndex = 0;
            for (int i = 2; i < save_ComboBox.Items.Count; i++)
                this.saveProperties.Add(save_ComboBox.Items[i].ToString(), false);
        }
예제 #3
0
        public void Populate()
        {
            if (Source == null)
            {
                Source = library;
                Settings.Shufflequeue_SourcePlaylistName = library.Name;
            }

            while (CurrentIndex > Settings.Shufflequeue_NumPrevious)
                Remove(0);

            if (Source.NumSongs <= 0)
                return;

            while (NumSongs - CurrentIndex < Settings.Shufflequeue_NumNext + 1)
                Add(Source.GetRandom(Settings.Shufflequeue_WeighRating));
        }
예제 #4
0
        private void TestRelation(int numSongs, float ratingRelation, PlaylistBase randomSource,
            int firstRating, int secondRating)
        {
            var list = new List<Song>();

            float lower = ratingRelation - 0.20f;
            float upper = ratingRelation + 0.20f;

            for (int run = 0; run < 100; run++)
            {
                for (int i = 0; i < numSongs; i++)
                    list.Add(randomSource.GetRandom(true));

                int c1 = list.Where(s => s.Rating == firstRating).Count();
                int c2 = list.Where(s => s.Rating == secondRating).Count();

                if (!(c1 > c2 * lower && c1 < c2 * upper))
                    Assert.Fail();

                list.Clear();
            }
        }
예제 #5
0
파일: MainForm.cs 프로젝트: koaset/KoPlayer
        private void PlaySong(Song song, PlaylistBase inPlaylist)
        {
            searchBarTimer.Stop();
            musicPlayer.Stop();
            musicPlayer.Volume = 0;

            // Check Last.fm scrobbling requirements
            if (currentSongTimePlayed.Ticks > 0.8 * musicPlayer.Length.Ticks ||
                currentSongTimePlayed.TotalMinutes > 4)
            {
                currentSongTimePlayed = TimeSpan.Zero;
                currentlyPlaying.LastPlayed = DateTime.Now;
                currentlyPlaying.PlayCount++;

                if (settings.ScrobblingEnabled)
                    if (currentlyPlaying.Length.TotalSeconds > 30)
                        lfmHandler.ScrobbleSong(currentlyPlaying);

                RefreshSongGridView();
            }

            if (!ReloadSong(song))
                return;

            ResetSearchBarTimer();
            searchBarTimer.Stop();

            try
            {
                 musicPlayer.Open(song.Path);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Play music exception: " + ex.ToString());
            }

            this.currentlyPlaying = song;
            this.playingPlaylist = inPlaylist;

            UpdateTrayIconText();
            UpdateSongImage();
            UpdateSongLengthLabel();
            UpdateSongInfoLabel();

            if (inPlaylist == shuffleQueue)
            {
                shuffleQueue.Populate();

                if (showingPlaylist == shuffleQueue)
                    UpdateShowingPlaylist();
            }

            // Saves changed from tag editing when song is not playing any more
            if (songToSave != null &&
                songToSave.Path != currentlyPlaying.Path)
            {
                songToSave.Save();
                songToSave = null;
            }

            // Show song popup according to settings
            if (settings.PopupOnSongChange)
                ShowCurrentSongPopup();

            inPlaylist.Save();
        }
예제 #6
0
파일: MainForm.cs 프로젝트: koaset/KoPlayer
        private void MainForm_Load(object sender, EventArgs e)
        {
            trayIcon.Icon = Icon;
            Width = settings.FormWidth;
            Height = settings.FormHeight;

            ResetSearchBarTimer();
            LoadPlaylists();

            showingPlaylist = GetPlaylist(settings.StartupPlaylist) ?? library;
            playingPlaylist = showingPlaylist;

            SetSongGridViewStyle();

            UpdateShowingPlaylist();
            songGridView.AutoGenerateColumns = false;
            songGridView.Columns["Length"].DefaultCellStyle.Format = Song.LengthFormat;

            columnSettings = ColumnSettings.Load(ColumnSettingsPath)
                ?? ColumnSettings.Load(DefaultColumnSettingsPath) ?? new ColumnSettings(songGridView.Columns);

            //Sets the columns
            foreach (ColumnSetting cs in columnSettings.SettingList)
            {
                songGridView.Columns[cs.Name].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                songGridView.Columns[cs.Name].DisplayIndex = cs.DisplayIndex;
                songGridView.Columns[cs.Name].Visible = cs.Visible;
                songGridView.Columns[cs.Name].Width = cs.Width;
                songGridView.Columns[cs.Name].SortMode = DataGridViewColumnSortMode.Automatic;
            }

            SetPlaylistGridView();

            playlistGridView.ClearSelection();
            // Select proper playlist in gridview
            foreach (DataGridViewRow row in playlistGridView.Rows)
                if ((row.DataBoundItem as PlaylistBase).Name == settings.StartupPlaylist)
                    row.Cells[0].Selected = true;

            shuffleQueue.Source = GetPlaylist(settings.Shufflequeue_SourcePlaylistName);
            shuffleQueue.Populate();
            UpdateTrayIconText();
            SetTrayIconContextMenu();
            SetStatusStrip();
            UpdateShowingPlaylist();
            volumeTrackBar.Value = settings.Volume;
        }
예제 #7
0
파일: MainForm.cs 프로젝트: koaset/KoPlayer
        private void DoSearch()
        {
            ChangeToPlaylist(library);
            if (searchBox.Text.Length > 0)
            {
                showingPlaylist = library.Search(searchBox.Text);
            }
            else if (searchBox.Text.Length == 0)
                library.ResetSearchDictionaries();

            UpdateShowingPlaylist();
        }
예제 #8
0
파일: MainForm.cs 프로젝트: koaset/KoPlayer
        private void DeletePlaylist(DataGridViewCell cell)
        {
            bool deleted = false;
            PlaylistBase pl = playlists[cell.RowIndex];
            if (pl != library && pl != shuffleQueue)
            {
                if (pl == showingPlaylist)
                    ChangeToPlaylist(library);
                if (pl == shuffleQueue.Source)
                {
                    shuffleQueue.Source = library;
                    settings.Shufflequeue_SourcePlaylistName = library.Name;
                }
                if (pl == playingPlaylist)
                {
                    StopPlaying();
                    playingPlaylist = library;
                }
                playlists.Remove(pl);
                try
                {
                    File.Delete(pl.Path);
                }
                catch { }
                deleted = true;
            }

            if (deleted)
                SetPlaylistGridView();
        }
예제 #9
0
파일: MainForm.cs 프로젝트: koaset/KoPlayer
        private void ChangeToPlaylist(PlaylistBase playlist)
        {
            if (showingPlaylist == playlist)
                return;

            if (playlist != library)
                ResetSearchBox();
            showingPlaylist = playlist;

            if (showingPlaylist == shuffleQueue)
                shuffleQueue.Populate();

            UpdateShowingPlaylist();
            songGridView.ClearSelection();

            SetPlaylistGridView();
            UpdateStatusStrip();
        }