예제 #1
0
        /// <summary>
        /// Based upon the given root folder, this will create the path of the music file while maintaining the structure as defined by 'Folder' and the album and artist fields.
        /// This will include all necessary subdirectories within the root folder.
        /// </summary>
        /// <param name="targetFolder">Root folder as basis for the path (usually the music collection folder)</param>
        /// <returns>Path of the music file, will all naming options (parent folders, album names etc.) included</returns>
        public string GetDestination(string targetFolder)
        {
            FileInfo sourceFile = new FileInfo(Source);
            string   newPath    = MusicFolder.GetPath(targetFolder, Folder);

            //Console.WriteLine("Source " + sourceFile + " new " + newPath);

            if (Folder == MusicFolder.Folders.ALBUM || Folder == MusicFolder.Folders.FILMMUSIK ||
                Folder == MusicFolder.Folders.PODCASTS || Folder == MusicFolder.Folders.LIEDER)
            {
                if (HasParent())
                {
                    if (AlternateParentFolder != null)
                    {
                        newPath = Path.Combine(newPath, AlternateParentFolder);
                    }
                    else if (AlbumParentFolder != null)
                    {
                        newPath = Path.Combine(newPath, AlbumParentFolder);
                    }
                }

                //Console.WriteLine("Folder: "+ CreateFolderName() + " File: " + CreateFileName(sourceFile, true));

                //Console.WriteLine("Destination: " + Path.Combine(newPath, CreateFolderName(), CreateFileName(sourceFile, true)));
                return(Path.Combine(newPath, CreateFolderName(), CreateFileName(sourceFile, Folder != MusicFolder.Folders.LIEDER)));
            }
            else
            {
                //Console.WriteLine("Destination = Source: " + Source);
                return(Source);
            }
        }
예제 #2
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);
                }
            });
        }
예제 #3
0
        internal void UpdateParent()
        {
            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.AlterParent(files, overrideParent, AlternateParentFolder, AlternateAlbumFolder != null, AlternateAlbumFolder);

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

            window.Invoke((MethodInvoker) delegate
            {
                if (files.Count > 0)
                {
                    viewGroup.Header = files[0].HasParent() ? "'" + files[0].GetParent() + "' / '" + files[0].CreateFolderName() + "'" : files[0].CreateFolderName();
                }


                window.musicFileList.Refresh();

                /*for (int i = 0; i < window.musicFileList.Columns.Count; i++)
                 * {
                 *  window.musicFileList.AutoResizeColumn(i, i != 0 ? ColumnHeaderAutoResizeStyle.HeaderSize : ColumnHeaderAutoResizeStyle.ColumnContent);
                 * }*/
            });
        }
예제 #4
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);
                    }
                }
            }
        }
예제 #5
0
        //private static MenuItem[] folderMenu = new MenuItem[] { new MenuItem(MusicFolder.GetFolderName(MusicFolder.Folders.ALBUM)), new MenuItem(MusicFolder.GetFolderName(MusicFolder.Folders.FILMMUSIK)), new MenuItem(MusicFolder.GetFolderName(MusicFolder.Folders.PODCASTS)) };

        public MainWindow()
        {
            InitializeComponent();

            buttonCopy.Enabled = false;
            AllowOverride      = true;

            musicDirectory    = Application.StartupPath;
            playlistDirectory = MusicFolder.GetPath(musicDirectory, MusicFolder.Folders.PLAYLISTS);

            musicFolderField.Text    = musicDirectory;
            playlistFolderField.Text = playlistDirectory;
        }
예제 #6
0
        public string PrintSong(string song)
        {
            FileInfo file = new System.IO.FileInfo(song);

            song = file.FullName;

            if (ShortenPaths)
            {
                List <string> folders   = MusicFolder.GetAllFolderNames();
                DirectoryInfo directory = file.Directory;

                bool searchingHierachy = true;

                while (searchingHierachy && directory.Parent != null)
                {
                    foreach (String folder in folders)
                    {
                        if (directory.Name.Equals(folder))
                        {
                            searchingHierachy = false;
                            break;
                        }
                    }

                    if (searchingHierachy)
                    {
                        directory = directory.Parent;
                    }
                    else
                    {
                        break;
                    }

                    //Console.WriteLine(directory.FullName);
                }

                //Console.WriteLine("Result " + directory.FullName);
                if (!searchingHierachy)
                {
                    song = ".." + file.FullName.Replace(directory.Parent.FullName, "");
                    song = song.Replace("\\", "/");
                }
            }

            //Console.WriteLine("Path " + song);

            return(song);
        }
예제 #7
0
 public override string ToString()
 {
     return(FormatDiscNr() + FormatTrackNr() + " - " + Artist + " - " + Title + " (from '" + Album + "', Genre: " + Genre + ") File: " + Source + " Sorted into: " + MusicFolder.GetFolderName(Folder));
 }
예제 #8
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!");
                }
            });
        }