private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0)
     {
         SoundSourceFilePathModel ssfpm = (SoundSourceFilePathModel)e.AddedItems[0];
         imgFrontCover.Source = ssfpm.ImageSource;
         ((TextBlock)lblArtist.FindName("txtArtist")).Text       = ssfpm.Artist;
         ((TextBlock)lblSongTitle.FindName("txtSongTitle")).Text = ssfpm.Title;
         lblFileSize.Content = ssfpm.FileSize;
         lblType.Content     = ssfpm.FileType;
     }
 }
        public MainWindow()
        {
            InitializeComponent();

            SoundSourceFilePathModel dummy = new SoundSourceFilePathModel();

            dummy.FileName      = "Drag & Drop Your Files Here!!";
            dummy.Artist        = "Sound Source Cover Apply Tool - Freeware";
            dummy.Title         = "Made by AK Cafe - LightEach";
            listBox.ItemsSource = new List <SoundSourceFilePathModel>()
            {
                dummy
            };
        }
        private async void ListBoxBind()
        {
            m_AllFilesHasTagImage = true;
            m_FilesPath.Clear();
            listBox.Resources.Clear();

            #region 길어서 접어둠
            m_DeliveredPath.Cast <string>().ToList().ForEach(p =>
            {
                FileAttributes fa = System.IO.File.GetAttributes(p);
                if (fa == FileAttributes.Directory)
                {
                    string[] files = Directory.GetFiles(p).Where(s => IsExtensionAllowed(s)).ToArray();
                    files.ToList().ForEach(f => { m_FilesPath.Add(f); });
                }
                else
                {
                    if (IsExtensionAllowed(p))
                    {
                        m_FilesPath.Add(p);
                    }
                }
            });

            List <SoundSourceFilePathModel> lstSSFPM = new List <SoundSourceFilePathModel>();
            #endregion

            var mySettings = new MetroDialogSettings()
            {
                NegativeButtonText = "Close now",
                AnimateShow        = false,
                AnimateHide        = false
            };
            var controller = await this.ShowProgressAsync("Sound Source List Update", "Preparing...", settings : mySettings);

            controller.SetIndeterminate();
            controller.SetCancelable(true);
            controller.Maximum = Convert.ToDouble(m_FilesPath.Count);
            double dblCnt = 0.0;

            foreach (string fPath in m_FilesPath)
            {
                SoundSourceFilePathModel ssfpm = new SoundSourceFilePathModel();
                ssfpm.ImageSource = new BitmapImage(new Uri(DEFAULT_TAG_IMG_URI));
                ssfpm.FileName    = System.IO.Path.GetFileName(fPath);

                TagLib.File tlFile = TagLib.File.Create(fPath);

                ssfpm.Artist = tlFile.Tag.FirstArtist;
                ssfpm.Title  = tlFile.Tag.Title;

                int pictureLen = tlFile.Tag.Pictures.Length;
                if (pictureLen > 0)
                {
                    TagLib.IPicture pic = tlFile.Tag.Pictures[0];

                    MemoryStream ms = new MemoryStream(pic.Data.Data);
                    ms.Seek(0, SeekOrigin.Begin);
                    BitmapImage bi = new BitmapImage();
                    bi.BeginInit();
                    bi.StreamSource = ms;
                    bi.EndInit();

                    ssfpm.ImageSource = bi;
                    ssfpm.FileSize    = pic.Data.Data.Length;
                    ssfpm.FileType    = pic.Type + ", " + pic.MimeType;
                }
                else
                {
                    m_AllFilesHasTagImage = false;
                }

                lstSSFPM.Add(ssfpm);

                controller.SetProgress(dblCnt);
                controller.SetMessage("Completed : " + ssfpm.Title);
                dblCnt += 1.0;
                await Task.Delay(50);
            }

            listBox.ItemsSource = lstSSFPM;

            await controller.CloseAsync();

            this.TaskbarItemInfo.Description = "Total Sound Sources : " + lstSSFPM.Count.ToString();
            // 맨 상단에 있는 항목 하나를 선택해준다.
            if (lstSSFPM.Count > 0)
            {
                listBox.SelectedItem = listBox.Items[0];
            }

            SetFooterMsg("ListBox Updated!!", "Count : " + int.Parse(dblCnt.ToString()).ToString());
        }