Пример #1
0
        void List_MouseDown(object sender, MouseEventArgs e)
        {
            mDownPos = e.Location;
            int index = PlayListBox.IndexFromPoint(new Point(PlayListBox.PointToClient(Cursor.Position).X, PlayListBox.PointToClient(Cursor.Position).Y));

            if (index >= 0 && index < PlayListBox.Items.Count)
            {
                PlayListBox.SelectedIndex = index;
            }
            ContextMenuHelper();
        }
Пример #2
0
        void List_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            int index = PlayListBox.IndexFromPoint(e.Location);

            if (index < 0)
            {
                return;
            }
            if (Math.Abs(e.X - mDownPos.X) >= SystemInformation.DragSize.Width ||
                Math.Abs(e.Y - mDownPos.Y) >= SystemInformation.DragSize.Height)
            {
                DoDragDrop(new DragObject(PlayListBox, PlayListBox.Items[index]), DragDropEffects.Move);
            }
        }
Пример #3
0
        void List_DragDrop(object sender, DragEventArgs e)
        {
            DragObject   obj      = e.Data.GetData(typeof(DragObject)) as DragObject;
            int          index    = PlayListBox.IndexFromPoint(new Point(PlayListBox.PointToClient(Cursor.Position).X, PlayListBox.PointToClient(Cursor.Position).Y));
            int          oldIndex = obj.source.Items.IndexOf(obj.item);
            PlayListItem tempItem = (PlayListItem)obj.item;

            obj.source.Items.Remove(obj.item);
            playListManager.Remove(tempItem);
            if (index < 0 || index >= PlayListBox.Items.Count)
            {
                PlayListBox.Items.Add(obj.item);
                playListManager.AddTrack(tempItem);
            }
            else
            {
                PlayListBox.Items.Insert(index, obj.item);
                playListManager.InsertTrack(index, tempItem);
            }
        }