예제 #1
0
        private void MediaFiles_KeyUp(object sender, KeyEventArgs e)
        {
            if (MediaFiles.SelectedIndex > -1)
            {
                if (e.KeyCode == Keys.Delete)
                {
                    int firstItem = MediaFiles.SelectedIndices[0];
                    int lastItem  = MediaFiles.SelectedIndices[MediaFiles.SelectedIndices.Count - 1];
                    if (trackNum >= firstItem)
                    {
                        if (trackLoaded == trackNum + 1)
                        {
                            trackLoaded = firstItem;
                        }
                        trackNum = firstItem - 1;
                    }
                    if (trackLoaded >= firstItem || trackLoaded <= lastItem)
                    {
                        trackLoaded = -1;
                    }

                    for (int i = lastItem; i >= firstItem; i--)
                    {
                        MediaFiles.Items.RemoveAt(i);
                        MediaFileLocation.RemoveAt(i);
                        MediaFileLocationType.RemoveAt(i);
                    }
                    if (MediaFiles.Items.Count == 0)
                    {
                        trackLoaded = -1;
                    }
                }
                else if (e.KeyCode == Keys.Enter)
                {
                    Play();
                }
                else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.A)
                {
                    for (int i = 0; i < MediaFiles.Items.Count; i++)
                    {
                        MediaFiles.SetSelected(i, true);
                    }
                }
            }
        }