コード例 #1
0
        private void OpenFolder()
        {
            using (FolderBrowserDialog dialog = new FolderBrowserDialog())
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var files = Directory.EnumerateFiles(dialog.SelectedPath, "*.*", SearchOption.TopDirectoryOnly)
                                .Where(s => s.EndsWith(".mp3") || s.EndsWith(".wav") || s.EndsWith(".wma") || s.EndsWith(".flac") || s.EndsWith(".ogg") || s.EndsWith(".m4a"));
                    PathToFolder = dialog.SelectedPath;
                    listBoxMedia.Items.Clear();

                    foreach (var str in files)
                    {
                        PathHolder item = new PathHolder(str);
                        listBoxMedia.Items.Add(item);
                    }
                    if (listBoxMedia.Items.Count != 0)
                    {
                        LoadTitleImage();
                    }
                    else
                    {
                        LoadDefaultImage();
                    }
                }
            }
        }
コード例 #2
0
 private void LoadPreviousAudioList()
 {
     if (SavePathToFolder)
     {
         bool pathToFolderNotEmpty = !String.IsNullOrEmpty(Properties.Settings.Default.pathToFolder);
         if (pathToFolderNotEmpty)
         {
             PathToFolder = Properties.Settings.Default.pathToFolder;
             if (Directory.Exists(PathToFolder))
             {
                 pathToFolderNotEmpty = true;
                 var files = Directory.EnumerateFiles(PathToFolder, "*.*", SearchOption.TopDirectoryOnly)
                             .Where(s => s.EndsWith(".mp3") || s.EndsWith(".wav") || s.EndsWith(".wma") || s.EndsWith(".flac") || s.EndsWith(".ogg") || s.EndsWith(".m4a"));
                 foreach (var str in files)
                 {
                     PathHolder item = new PathHolder(str);
                     listBoxMedia.Items.Add(item);
                 }
             }
             if (!pathToFolderNotEmpty)
             {
                 PathToFolder = null;
             }
         }
     }
 }
コード例 #3
0
        private void ListBoxMedia_DragDrop(object sender, DragEventArgs e)
        {
            string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            foreach (var str in FileList)
            {
                if (AcceptedFormat(str))
                {
                    PathHolder item = new PathHolder(str);
                    listBoxMedia.Items.Add(item);
                }
            }
        }
コード例 #4
0
        private void OpenWithCommandLine(string[] args)
        {
            if (args != null)
            {
                this.listBoxMedia.Items.Clear();
                SavePathToFolder = false;

                PathToFolder = null;
                PathToImage  = null;

                foreach (var str in args)
                {
                    if (AcceptedFormat(str))
                    {
                        PathHolder item = new PathHolder(str);
                        this.listBoxMedia.Items.Add(item);
                    }
                }
                PlaySound();
            }
        }
コード例 #5
0
 private void OpenFiles()
 {
     using (OpenFileDialog fileDialog = new OpenFileDialog())
     {
         fileDialog.Multiselect = true;
         fileDialog.Filter      = FormatFilter;
         if (fileDialog.ShowDialog() == DialogResult.OK)
         {
             if (fileDialog.FileNames.Length != 0)
             {
                 foreach (var str in fileDialog.FileNames)
                 {
                     PathHolder item = new PathHolder(str);
                     listBoxMedia.Items.Add(item);
                 }
             }
             if (fileDialog.FileNames.Length == 1)
             {
                 PlaySoundEvent();
             }
         }
     }
 }