コード例 #1
0
ファイル: NormalView.cs プロジェクト: usmanatron/quuxplayer
        public void RemoveTracks()
        {
            List <Track> tq = SelectedTracks;

            if (tq.Count > 0)
            {
                int i = trackList.FirstSelectedIndex;

                if (NondynamicPlaylistBasedView)
                {
                    Database.RemoveFromPlaylist(ActivePlaylist, tq);
                    foreach (Track t in tq)
                    {
                        t.Selected = false;
                    }
                }
                else
                {
                    // TODO: Localize

                    frmTaskDialog td;
                    List <frmTaskDialog.Option> options = new List <frmTaskDialog.Option>();

                    // Singular

                    if (tq.Count == 1)
                    {
                        options.Add(new frmTaskDialog.Option("Remove from library only", "Remove the track from my QuuxPlayer library but leave the file where it is on my hard drive.", 0));
                        options.Add(new frmTaskDialog.Option("Remove and recycle", "Remove the track from QuuxPlayer and also send the file to the Windows recycle bin.", 1));
                        options.Add(new frmTaskDialog.Option("Cancel", "Don't remove the file.", 2));

                        td = new frmTaskDialog("Remove Track?", "Remove \"" + tq[0].ToShortString() + "\" from library?", options);
                    }
                    else
                    {
                        options.Add(new frmTaskDialog.Option("Remove from library only", "Remove the tracks from my QuuxPlayer library but leave the files where they are on my hard drive.", 0));
                        options.Add(new frmTaskDialog.Option("Remove and recycle", "Remove the tracks from QuuxPlayer and also send the files to the Windows recycle bin.", 1));
                        options.Add(new frmTaskDialog.Option("Cancel", "Don't remove the files.", 2));

                        td = new frmTaskDialog("Remove Tracks?", "Remove " + tq.Count.ToString() + " tracks from library?", options);
                    }

                    td.ShowDialog(this);

                    switch (td.ResultIndex)
                    {
                    case 0:
                        Database.RemoveFromLibrary(tq);
                        break;

                    case 1:
                        Database.RemoveFromLibrary(tq);
                        TrackWriter.RecycleFiles(tq);
                        break;

                    default:
                        return;
                    }

                    //cmb = new QCheckedMessageBox(mainForm, text, "Remove Track?", QMessageBoxButtons.YesNo, QMessageBoxIcon.Question, QMessageBoxButton.NoCancel, Localization.Get(UI_Key.General_Also_Recycle), false);

                    //if (cmb.DialogResult == DialogResult.OK)
                    //{
                    //    Database.RemoveFromLibrary(tq);
                    //    if (cmb.Checked)
                    //    {
                    //        TrackWriter.RecycleFiles(tq);
                    //    }
                    //}
                    //else
                    //{
                    //    return;
                    //}
                    //}
                    //else
                    //{
                    //    DialogResult dr;

                    //    if (tq.Count == 1)
                    //        dr = QMessageBox.Show(mainForm, "Remove \"" + tq[0].ToShortString() + "\" from library?", "Remove Track?", QMessageBoxButtons.YesNo, QMessageBoxIcon.Question, QMessageBoxButton.NoCancel);
                    //    else
                    //        dr = QMessageBox.Show(mainForm, "Remove " + tq.Count.ToString() + " tracks from library?", "Remove Tracks?", QMessageBoxButtons.YesNo, QMessageBoxIcon.Question, QMessageBoxButton.NoCancel);

                    //    if (dr == DialogResult.OK)
                    //        Database.RemoveFromLibrary(tq);
                    //    else
                    //        return;
                    //}
                }
                RefreshAll(false);

                if (i < TrackCount)
                {
                    SelectTrack(i, false, true, true);
                }
                else if (TrackCount > 0)
                {
                    SelectTrack(TrackCount - 1, false, true, true);
                }
            }
        }