Exemplo n.º 1
0
        public VItem InsertPlaylistAt(int index, Playlist newplaylist)
        {
            VItem i = CreateItem(newplaylist.path);

            Insert(index, i);
            return(i);
        }
Exemplo n.º 2
0
        //require override derived method instead?
        public void DropMusicFiles(List <string> files, int index)
        {
            //StoreCurrentState();
            //
            // tool.show(5, "Show");
            //SelectedItems.Clear();
            foreach (string file in files)
            {
                if (tool.IsAudioFile(file))
                {
                    VItem item = CreateItem(file);
                    base.Insert(index, item);
                    int i = base.IndexOf(item);
                    item.Selected = true;
                    continue;
                }

                if (!Path.HasExtension(file))
                {
                    List <string> dirf = tool.LoadAudioFiles(file, SearchOption.TopDirectoryOnly);
                    DropMusicFiles(dirf, index);
                    return;
                }
            }
        }
Exemplo n.º 3
0
        internal void MovePreSelectedTo(int index)
        {
            int count = lastSelectedIndices.Count;

            if (count == 0)
            {
                return;
            }

            index += 1;
            lastSelectedIndices.Reverse();

            List <int> removedItems = new List <int>();

            foreach (int i in lastSelectedIndices)
            {
                VItem newi = manager.Items[i].Clone();
                newi.Selected = true;
                manager.Insert(index, newi);
                removedItems.Add(i);
            }

            foreach (int i in removedItems)
            {
                manager.Remove(i);
            }

            UpdateColumnsAndColors();
        }
Exemplo n.º 4
0
        //add external files
        public override void AddFiles(int dropIndex, string[] arr)
        {
            List <VItem> insertItems = new List <VItem>();

            foreach (string s in arr)
            {
                string dir_path = s;
                if (!Directory.Exists(s))
                {
                    dir_path = Path.GetDirectoryName(s);
                }
                if (!Directory.Exists(dir_path))
                {
                    continue;
                }
                VItem i1 = CreateItem(s);
                if (i1 == null)
                {
                    continue;
                }
                insertItems.Add(i1);
                continue;
            }
            insertItems.Reverse();
            foreach (VItem item in insertItems)
            {
                item.Selected = true;
                Insert(dropIndex, item);
            }
        }
Exemplo n.º 5
0
        public virtual VItem Remove(int index)
        {
            VItem item = _items[index];

            _items.Remove(item);
            _view.Remove(index);
            return(item);
        }
Exemplo n.º 6
0
        public void Insert(int index, VItem item)
        {
            ListViewItem i = new ListViewItem();

            GetColumnInfo(i, item.Tag);
            WinFormUtils.GetItem(i, item);
            Items.Insert(index, i);
        }
Exemplo n.º 7
0
        public override VItem Insert(int index, VItem item)
        {
            Playlist p = item.Tag as Playlist;

            //if(!Playlists.ContainsKey(p.path))
            //   Playlists.Add(p.path, p);
            return(base.Insert(index, item));
        }
Exemplo n.º 8
0
        public override VItem CreateItem(string file)
        {
            Playlist p = FileLoader.Instance.GetPlaylist(file, true);
            VItem    v = base.CreateItem(file);

            v.Tag = p;
            return(v);
        }
Exemplo n.º 9
0
        public void Add(VItem item)
        {
            ListViewItem i = new ListViewItem();

            GetColumnInfo(i, item.Tag);
            WinFormUtils.GetItem(i, item);
            Items.Add(i);
        }
Exemplo n.º 10
0
        public VItem InsertPlaylistAt(int index, string file)
        {
            Playlist p      = FileLoader.Instance.GetPlaylist(file, true);
            VItem    v_item = base.CreateItem(file);

            v_item.Tag = p;
            Insert(index, v_item);
            return(v_item);
        }
Exemplo n.º 11
0
 public void DisplayPlaylist()
 {
     manager.CurrentList.UpdatePaths();
     manager.Items.Clear();
     foreach (string s in manager.CurrentList.tracks)
     {
         VItem i = manager.CreateItem(s);
         manager.Add(i);
     }
     UpdateColumnsAndColors();
 }
Exemplo n.º 12
0
 public int IndexOf(VItem item)
 {
     for (int i = 0; i < _items.Count; i++)
     {
         if (_items[i] == item)
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 13
0
 internal void RestoreOldSelections()
 {
     for (int i = 0; i < Items.Count; i++)
     {
         VItem item = manager.Items[i];
         if (item.State == ItemState.WasSelected)
         {
             item.Selected     = true;
             Items[i].Selected = true;
         }
     }
 }
Exemplo n.º 14
0
        public void MoveSelectedItemsTo(int index, List <int> selectedIndices)
        {
            List <VItem> insertItems  = new List <VItem>(selectedIndices.Count);
            List <VItem> removedItems = new List <VItem>(selectedIndices.Count);
            //if (index > ItemCount)
            //   index = ItemCount;
            VItem ref_item = Items[index];

            //tool.show(5, ref_item.Name);
            if (ref_item == null)
            {
                tool.show(5, "Ref item is null");
                return;
            }
            ClearSelection();
            int last_index = 0;

            foreach (int item in selectedIndices)
            {
                if (item == index)
                {
                    return;
                }
                VItem i = Items[item];
                i.Selected = true;
                insertItems.Add(i);
                removedItems.Add(Items[item]);
                last_index = item;
            }

            foreach (VItem removeItem in removedItems)
            {
                Remove(removeItem);
            }
            index = Items.IndexOf(ref_item);

            if (index == -1)
            {
                tool.show(3, "Index is -1");
                return;
            }
            if (index > last_index)
            {
                index++;
                //index+=2;
                //tool.show(1, "lower drop");
            }
            for (int i = insertItems.Count - 1; i >= 0; i--)
            {
                Insert(index, insertItems[i]);
            }
            CallTracksChangedDelegate();
        }
Exemplo n.º 15
0
        /*
         * public void UpdateInterface()
         * {
         *  RefreshList(manager.Items);
         * }
         */
        /*
         * public void UpdateList()
         * {
         *  manager.Items.Clear();
         *  foreach(ListViewItem i in Items)
         *  {
         *      VItem v_item = GetVListItem(i);
         *      manager.Items.Add(v_item);
         *  }
         * }
         */
        /*
         * public void GetSelectedItems()
         * {
         *  manager.SelectedIndices.Clear();
         *  foreach(int i in SelectedIndices)
         *  {
         *      manager.SelectedIndices.Add(i);
         *  }
         * }
         */
        //replace with custom draw
        public void RefreshUI()
        {
            //RefreshList(manager.Items);

            for (int i = 0; i < manager.ItemCount; i++)
            {
                ListViewItem item  = Items[i];
                VItem        vitem = manager.Items[i];
                item.ForeColor = vitem.CurrentColor.foreColor;
                item.BackColor = vitem.CurrentColor.backColor;
            }
        }
Exemplo n.º 16
0
        public override VItem Remove(int index)
        {
            VItem i = Items[index];

            if (i == null)
            {
                return(null);
            }
            Playlist p = i.Tag as Playlist;

            //Playlists.Remove(p.path);
            return(base.Remove(index));
        }
Exemplo n.º 17
0
 public static ListViewItem GetItem(ListViewItem i, VItem track)
 {
     // i.SubItems[0].Text = Path.GetFileNameWithoutExtension(track.Columns[0]);
     // i.SubItems.Add(track.Columns[1]);
     i.Tag      = track.Tag;
     i.Name     = track.Name;
     i.Selected = track.Selected;
     // i.Selected = track.Selected;
     //i.Checked = track.Checked;
     i.ForeColor = track.CurrentColor.foreColor;
     i.BackColor = track.CurrentColor.backColor;
     return(i);
 }
Exemplo n.º 18
0
        public virtual VItem Remove(VItem item)
        {
            if (!_items.Contains(item))
            {
                tool.show(5, "Crash averted:  getting the index of an item not in Items");
                return(null);
            }
            int index = IndexOf(item);

            _view.Remove(index);
            _items.Remove(item);
            return(item);
        }
Exemplo n.º 19
0
 internal void ClearOldSelections()
 {
     for (int i = 0; i < Items.Count; i++)
     {
         VItem item = manager.Items[i];
         if (item.State == ItemState.WasSelected)
         {
             item.State        = ItemState.Reset;
             item.Selected     = false;
             Items[i].Selected = false;
         }
     }
 }
Exemplo n.º 20
0
 public void ChangeItemName(VItem item, string text)
 {
     if (item != null)
     {
         Playlist p       = item.Tag as Playlist;
         string   oldpath = p.path;
         p.UpdateName(text);
         //item.Text = p.name;
         item.Columns[0] = p.name;
         item.Columns[1] = p.path;
         item.Name       = p.path;
         MusicPlayer.WinFormApp.musicControl.UpdateDockedPlaylistNames();
     }
 }
Exemplo n.º 21
0
        public void Add(VItem item)
        {
            if (item.CurrentColor == null)
            {
                tool.show(5, "Current Color hasn't been set");
            }
            ListViewItem i = new ListViewItem();

            i.Name     = item.Name;
            i.Tag      = item.Tag;
            i.Selected = item.Selected;
            GetColumnInfo(i, i.Tag); //tag is the playlist
            Items.Add(i);
        }
Exemplo n.º 22
0
 protected override void EnhancedListBox_DragDrop(object sender, DragEventArgs e)
 {
     if (!InternalClipboard.IsEmpty)
     {
         Point        cp         = PointToClient(new Point(e.X, e.Y));
         ListViewItem dragToItem = GetItemAt(cp.X, cp.Y);
         int          dropindex  = manager.ItemCount;
         if (dragToItem != null)
         {
             dropindex = dragToItem.Index;
         }
         manager.AddFiles(dropindex, InternalClipboard.Files.ToArray());
         InternalClipboard.Files.Clear();
         this.Focus();
         return;
     }
     else
     {
         string[] data = WinFormUtils.GetExternalDragDrop(e);
         if (data == null)
         {
             base.EnhancedListBox_DragDrop(sender, e);
             InternalClipboard.Clear();
         }
         else
         {
             foreach (string file in data)
             {
                 Point        cp         = PointToClient(new Point(e.X, e.Y));
                 ListViewItem dragToItem = GetItemAt(cp.X, cp.Y);
                 int          dropindex  = manager.ItemCount;
                 if (dragToItem != null)
                 {
                     dropindex = dragToItem.Index;
                 }
                 VItem i = manager.InsertPlaylistAt(dropindex, file);
                 if (i == null)
                 {
                     continue;
                 }
                 i.Selected = true;
             }
             InternalClipboard.Clear();
             this.Focus();
             this.Refresh();
             return;
         }
     }
 }
Exemplo n.º 23
0
        public void LoadPlayfilesintoManager()
        {
            List <Playlist> list = LoadPlaylistFromFileManager();

            if (list.Count > 0)
            {
                //playlistView.SelectedItems.Clear();
                foreach (Playlist p in list)
                {
                    VItem item = playlistView.manager.InsertPlaylistAt(0, p);
                    item.Selected = true;
                    MusicPlayer.WinFormApp.DockPlaylist(MusicPlayer.WinFormApp.musicPanel, p);
                }
            }
        }
Exemplo n.º 24
0
        internal VItem Clone()
        {
            VItem item = new VItem();

            item.Name         = Name;
            item.Columns[0]   = Columns[0];
            item.Columns[1]   = Columns[1];
            item.Tag          = Tag;
            item.CurrentColor = CurrentColor;
            item.OldColor     = OldColor;
            item.Selected     = Selected;
            item.State        = State;
            item.Checked      = Checked;
            return(item);
        }
Exemplo n.º 25
0
        public void LoadTmpPlaylists()
        {
            string directory = "Output\\tmp\\";

            if (Directory.Exists(directory))                             //does the directory exist?
            {
                List <string> files = tool.LoadFiles(directory, ".m3u"); //if so, grab the files
                //search for corresponding playlist
                foreach (string file in files)                           //load each file into the listview
                {
                    VItem i = CreateItem(file);
                    Add(i);
                }
            }
        }
Exemplo n.º 26
0
        public void Insert(int index, VItem item)
        {
            if (item.CurrentColor == null)
            {
                tool.show(5, "Ooops, Current Color hasn't been set");
                return;
            }
            ListViewItem i = new ListViewItem();

            i.Name     = item.Name;
            i.Tag      = item.Tag;
            i.Selected = item.Selected;
            GetColumnInfo(i, i.Tag); //tag is the playlist
            Items.Insert(index, i);
        }
Exemplo n.º 27
0
        //required overrided  method
        public override VItem CreateItem(string file)
        {
            VItem i = new VItem();

            i.Columns[0] = Path.GetFileNameWithoutExtension(file);
            i.Columns[1] = file;
            i.SetColors(CurrentColors);
            i.Name = file;
            Song song = MusicInfo.Instance.GetInfo(file);

            if (song != null)
            {
                i.Tag = song;
            }
            return(i);
        }
Exemplo n.º 28
0
        public virtual VItem CreateItem(string file)
        {
            VItem i = new VItem();

            i.Columns[0] = Path.GetFileNameWithoutExtension(file);
            i.Columns[1] = file;
            i.SetColors(CurrentColors);
            i.Name = file;
            //move this to derived createItem.  See playlistManager CreateItem
            Song song = SongInfo.Instance.GetInfo(file);

            if (song != null)
            {
                i.Tag = song;
            }
            return(i);
        }
Exemplo n.º 29
0
 internal void MusicPlayer_PlayEvent(object sender, EventArgs args)
 {
     if (base.Items.Count == 0)
     {
         tool.show(3, "Check item count...possibly empty subscribers");
         return;
     }
     if (CurrentList == MusicPlayer.Instance.playlist)
     {
         if (sender is int)
         {
             int index = (int)sender;
             IsPlayingItem       = this.Items[index];
             IsPlayingItem.State = ItemState.IsThePlayingTrack;
         }
     }
     UpdateColours();
 }
Exemplo n.º 30
0
        public override VItem Add(VItem item)
        {
            Playlist p = item.Tag as Playlist;

            if (p == null)
            {
                return(null);
            }

            /*
             * if(Playlists.ContainsKey(p.path))
             * {
             *  tool.show(2, "Playlist Already in Manager");
             *  return null;
             * }
             * Playlists.Add(p.path, p);
             */
            return(base.Add(item));
        }