/// <summary>
        /// Convert a fso music file into a song
        /// </summary>
        /// <param name="files"></param>
        /// <returns></returns>
        public static Song MusicFileToSong(fso file)
        {
            Song newSong = new Song();

            newSong.Name = file.Name;
            newSong.Path = file.Path;

            return newSong;
        }
 /// <summary>
 /// The selected file in the file browser changed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="file"></param>
 void Browser_OnFileChanged(object sender, fso file)
 {
     switch (file.FileType)
     {
         case fsoType.Music:
             //Insert all songs in the currrent directory into the musicQueue and play the selected one
             Session.CurMusicQueue.AddNPlay(
                 CarPC.Helper.MusicConverter.MusicFileToSong(Session.Browser.Files),
                 CarPC.Helper.MusicConverter.MusicFileToSong(file)
                 );
             break;
     }
 }
示例#3
0
        //Default Constructor
        public Folder(string folderPath, fso fsoParent)
        {
            //Name
            name = folderPath.Substring(folderPath.LastIndexOf(System.IO.Path.DirectorySeparatorChar) + 1);

            //Path
            path = folderPath;
            parent = fsoParent;

            //Generic folder icon
            BitmapImage imgThumb = new BitmapImage();
            imgThumb.BeginInit();
            imgThumb.UriSource = new Uri(@"pack://siteoforigin:,,,/Images/folder-blue.png");
            imgThumb.EndInit();
            thumbnail = imgThumb;
        }
示例#4
0
        /// <summary>
        /// Returns a filtered list of files and folders in the specified
        /// </summary>
        /// <param name="folder">The full folder path</param>
        /// <returns></returns>
        public List<fso> GetFilesInFolder(string folder, fso parent, List<string> audioFormats, List<string> videoFormats)
        {
            List<fso> files = new List<fso>();

            foreach (string d in Directory.GetDirectories(folder))
            {
                files.Add(new Folder(d, parent));
            }

            //Add supported files to our list
            foreach (string f in Directory.GetFiles(folder, "*"))
            {
                if (audioFormats.Contains(FileExtension(f)))
                {
                    files.Add(new MusicFile(f, parent));
                }
                else if (videoFormats.Contains(FileExtension(f)))
                {
                    files.Add(new VideoFile(f, parent));
                }
            }

            return files;
        }
 /// <summary>
 /// File browser directory changed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="Directory"></param>
 void Browser_OnDirectoryChanged(object sender, fso Directory)
 {
     toolbarMain.ToggleBackButton(Session.Browser.BackNavEnabled);
 }
示例#6
0
 /// <summary>
 /// Create a new audio file from the given file
 /// </summary>
 /// <param name="file"></param>
 /// <returns></returns>
 public MusicFile(string file, fso fsoParent)
 {
     path = file;
     parent = fsoParent;
     GetSongInfo();
 }
示例#7
0
 /// <summary>
 /// Create a new video file from the given file
 /// </summary>
 /// <param name="file"></param>
 /// <returns></returns>
 public VideoFile(string file, fso fsoParent)
 {
     path = file;
     parent = fsoParent;
     GetVideoInfo();
 }
        /// <summary>
        /// Selected item changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lstFiles_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            //Convert the selected item to a fso
            curItem = (fso)lstFiles.SelectedItem;

            //Check for a null value
            if (curItem == null)
            {
                return;
            }

            //If the selected item is a folder, browse to it
            if (curItem.FileType == fsoType.Folder || curItem.FileType == fsoType.Source)
            {
                BrowseDirectory(curItem.Path, curItem);
            }
            else if (curItem.FileType == fsoType.Music)
            {
                //Fire the file changed event
                OnFileChanged(this, curItem);
            }
        }
        /// <summary>
        /// Navigate back in the directory structure
        /// </summary>
        public void NavigateBack()
        {
            //Update the current item
            curItem = curItem.Parent;

            if (curItem == null)
            {
                //We don't know where to go, so go back to the source list
                DisplaySourceList();
            }
            else if (curItem.Path == "")
            {
                //We don't know where to go, so go back to the source list
                DisplaySourceList();
            }
            else if (curItem.Path == "MediaSource")
            {
                //Display the source list
                DisplaySourceList();
            }
            else
            {
                //Get the parent files
                BrowseDirectory(curItem.Path, curItem);
            }
        }
        /// <summary>
        /// Browse to the given directory and contained display all files and folders
        /// </summary>
        /// <param name="path"></param>
        public void BrowseDirectory(string path, fso parent)
        {
            using (FileBrowserVM browser = new FileBrowserVM())
            {
                files = browser.GetFilesInFolder(path, parent, audioFormats, videoFormats);
            }

            lstFiles.ItemsSource = null;
            lstFiles.ItemsSource = files;
            backNavEnabled = true;

            CallOnDirectoryChanged();
        }