Exemplo n.º 1
0
        //Supprime un morceau si selectionné
        private void Track_Removed(object sender, RoutedEventArgs e)
        {
            if (SelectedTrack != null)
            {
                Album al = TheAlbum as Album;

                al.ListTrack.Remove(SelectedTrack as Track);
                TheAlbum.TimeCalculator();
            }
        }
Exemplo n.º 2
0
        //Quand la fentre se fermera un nouveau morceau sera ajouter si les paramètres sont valides
        void newTrack_Closing(object sender, CancelEventArgs e)
        {
            var window = sender as AddNewTrack;
            int min;
            int sec;
            int tracknum;

            if (int.TryParse(window.TextMinT.Text, out min))
            {
                if (min < 0)
                {
                    min = -1;
                }
            }
            else
            {
                min = -1;
            }
            if (int.TryParse(window.TextSecT.Text, out sec))
            {
                if (sec < 0 || sec > 59)
                {
                    min = -1;
                }
            }
            else
            {
                min = -1;
            }
            if (!int.TryParse(window.TextNomTrack.Text, out tracknum))
            {
                tracknum = 0;
            }
            if (window.TextNameT.Text != "" && window.TextGenreT.Text != "" && min != -1 && sec != -1 && tracknum > 0)
            {
                Track tr = new Track(window.TextNameT.Text, min, sec, (TheAlbum as Album).Artist, (TheAlbum as Album).Title, window.TextGenreT.Text, (TheAlbum as Album).Year, tracknum, window.SongBox.Text);
                (TheAlbum as Album).AddTrack(tr);
                TheAlbum.TimeCalculator();
            }
            else if (window.TextGenreT.Text == "" && window.TextNameT.Text != "" && min != -1 && sec != -1 && tracknum > 0)
            {
                Track tr = new Track(window.TextNameT.Text, min, sec, (TheAlbum as Album).Artist, (TheAlbum as Album).Title, (TheAlbum.Genre), (TheAlbum as Album).Year, tracknum, window.SongBox.Text);
                (TheAlbum as Album).AddTrack(tr);
                TheAlbum.TimeCalculator();
            }
        }