Exemple #1
0
        internal void UpdateFolder()
        {
            List <MusicFile> files = new List <MusicFile>();

            foreach (ListViewItem item in viewGroup.Items)
            {
                MusicFile mf = window.FindMusicFile(item);
                window.importedFiles.Remove(mf);
                files.Add(mf);
            }

            files = MusicFolder.RegroupFiles(files, window.musicDirectory, folder);

            window.importedFiles.AddRange(files.ToArray());

            window.Invoke((MethodInvoker) delegate
            {
                for (int i = 0; i < viewGroup.Items.Count; i++)
                {
                    ListViewItem item     = viewGroup.Items[i];
                    MusicFile file        = files[i];
                    item.SubItems[0].Text = MusicFolder.GetFolderName(file.Folder);
                }

                window.musicFileList.Refresh();
                for (int i = 0; i < window.musicFileList.Columns.Count; i++)
                {
                    window.musicFileList.AutoResizeColumn(i, i != 0 ? ColumnHeaderAutoResizeStyle.HeaderSize : ColumnHeaderAutoResizeStyle.ColumnContent);
                }
            });
        }
Exemple #2
0
        private void OnListMouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (musicFileList.FocusedItem.Bounds.Contains(e.Location) == true)
                {
                    if (!musicFileList.FocusedItem.Group.Name.Equals("lieder"))
                    {
                        MenuItem[] items = new MenuItem[4];

                        items[0]        = new MenuItem(MusicFolder.GetFolderName(MusicFolder.Folders.ALBUM));
                        items[0].Click += OnClickMenuAlbum;
                        items[1]        = new MenuItem(MusicFolder.GetFolderName(MusicFolder.Folders.FILMMUSIK));
                        items[1].Click += OnClickMenuSoundtrack;
                        items[2]        = new MenuItem(MusicFolder.GetFolderName(MusicFolder.Folders.PODCASTS));
                        items[2].Click += OnClickMenuPodcast;
                        items[3]        = new MenuItem("Edit Folder Name");
                        items[3].Click += OnClickMenuEditName;


                        musicFileList.ContextMenu = new ContextMenu(items);
                    }
                }
            }
        }
Exemple #3
0
 public override string ToString()
 {
     return(FormatDiscNr() + FormatTrackNr() + " - " + Artist + " - " + Title + " (from '" + Album + "', Genre: " + Genre + ") File: " + Source + " Sorted into: " + MusicFolder.GetFolderName(Folder));
 }
Exemple #4
0
        internal void Import()
        {
            Dictionary <string, ListViewGroup> albumGroups = new Dictionary <string, ListViewGroup>();
            List <ListViewItem> items       = new List <ListViewItem>();
            ListViewGroup       liederGroup = new ListViewGroup("lieder", "Lieder");

            window.importedFiles = MusicFolder.ReadMusicFiles(window.musicDirectory, files);

            foreach (MusicFile file in window.importedFiles)
            {
                ListViewItem item = new ListViewItem(MusicFolder.GetFolderName(file.Folder));
                item.SubItems.Add(file.Title);
                item.SubItems.Add(file.Artist);
                item.SubItems.Add(file.FormatDiscNr());
                item.SubItems.Add(file.FormatTrackNr());
                item.SubItems.Add(new System.IO.FileInfo(file.Source).Name);
                item.SubItems.Add(file.BiteRate.ToString() + " kbit/s");
                item.SubItems.Add(file.Duration.ToString(@"mm\:ss"));

                if (file.Folder == MusicFolder.Folders.LIEDER)
                {
                    item.Group = liederGroup;
                }
                else
                {
                    if (albumGroups.ContainsKey(file.Album))
                    {
                        item.Group = albumGroups[file.Album];
                    }
                    else
                    {
                        ListViewGroup group = new ListViewGroup(file.Album.ToLower(), file.HasParent() ? "'" + file.GetParent() + "' / '" + file.CreateFolderName() + "'" : file.CreateFolderName());
                        albumGroups.Add(file.Album, group);
                        item.Group = group;
                    }
                }

                items.Add(item);
            }

            window.Invoke((MethodInvoker) delegate
            {
                window.musicFileList.Items.Clear();
                window.musicFileList.Groups.Clear();
                window.musicFileList.Groups.Add(liederGroup);
                foreach (ListViewGroup gr in albumGroups.Values)
                {
                    window.musicFileList.Groups.Add(gr);
                }

                window.musicFileList.Items.AddRange(items.ToArray());

                for (int i = 0; i < window.musicFileList.Columns.Count; i++)
                {
                    window.musicFileList.AutoResizeColumn(i, i != 0 ? ColumnHeaderAutoResizeStyle.HeaderSize : ColumnHeaderAutoResizeStyle.ColumnContent);
                }

                window.buttonCopy.Enabled = window.importedFiles.Count != 0;

                window.progressBar.Style = ProgressBarStyle.Continuous;
                window.progressBar.Value = 0;

                if (window.importedFiles.Count == 0)
                {
                    MessageBox.Show("No valid files found!");
                }
            });
        }