Ejemplo n.º 1
0
        private void GetSingleAlbumPicture()
        {
            if (SongList[SourceTAR].AlbumURL.IndexOf("music-default") <= 0)
            {
                this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
                {
                    AlbumPicture.Source = new BitmapImage(new Uri(SongList[SourceTAR].AlbumURL2, UriKind.RelativeOrAbsolute));
                    CheckBox1.IsEnabled = true;
                    CheckBox1.IsChecked = INIClass.IniReadValue("CheckBox1");
                });
                return;
            }
            else
            {
                this.Dispatcher.BeginInvoke(DispatcherPriority.Send, (ThreadStart) delegate()
                {
                    AlbumPicture.Source = null;
                    CheckBox1.IsEnabled = false;
                    CheckBox1.IsChecked = false;
                });
            }
            string DouBanAPI = "http://api.douban.com/music/subjects?start-index=1&max-results=1&apikey=058a7fc77af5da75109f7f5670e18f5f&q="; //豆瓣API

            DouBanAPI += AlbumName;
            string code  = WebHelper.GetPageHTMLSource(DouBanAPI);
            Regex  regex = new Regex("rel=\"alternate\"/>(.*?)<link href=\"(?<data>.*?)\" rel=\"image\"/>", RegexOptions.IgnoreCase);

            if (regex.IsMatch(code))
            {
                try
                {
                    this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() //低优先级 下载专辑图片并载入
                    {
                        string PicURL = regex.Match(code).Groups["data"].Value /*.Replace("/spic/", "/lpic/")*/;
                        if ((PicURL == null) || PicURL.IndexOf("music-default") > 0)
                        {
                            return;
                        }
                        //new BitmapImage(new Uri(@regex.Match(code).Groups["data"].Value, UriKind.Absolute));
                        SongList[SourceTAR].AlbumURL  = PicURL;
                        SongList[SourceTAR].AlbumURL2 = PicURL.Replace("/spic/", "/lpic/");
                        AlbumPicture.Source           = new BitmapImage(new Uri(SongList[SourceTAR].AlbumURL2, UriKind.RelativeOrAbsolute));
                        CheckBox1.IsEnabled           = true;
                        CheckBox1.IsChecked           = INIClass.IniReadValue("CheckBox1");
                    });
                }
                catch
                {
                    //Do Nothing
                }
            }
        }
Ejemplo n.º 2
0
        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            CheckBox cb = (CheckBox)sender;

            if (cb.IsChecked == true)
            {
                INIClass.IniWriteValue(cb.Name, "true");
            }
            else
            {
                INIClass.IniWriteValue(cb.Name, "false");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// DataListbox 双击搜索结果项目
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (DataListBox.SelectedIndex < 0)
            {
                return;
            }
            if (DataListBox.ItemsSource == DownLoadList)
            {
                //打开目录并选中文件
                string   FileName = System.Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) + "\\" + DownLoadList[DataListBox.SelectedIndex].SongTitle + ".mp3";
                FileInfo f        = new FileInfo(FileName);

                if (f.Exists)
                {
                    ShowSelectedInExplorer.FileOrFolder(FileName);
                }
                else
                {
                    System.Diagnostics.Process.Start("explorer.exe", System.Environment.GetFolderPath(Environment.SpecialFolder.MyMusic));
                }
                return;
            }
            //MessageBox.Show(SongList[DataListBox.SelectedIndex].SongTitle);
            //AlbumPicture.Source = new BitmapImage(new Uri(SongList[DataListBox.SelectedIndex].AlbumURL2, UriKind.RelativeOrAbsolute));
            LabelSongTitle.Content = "歌曲:" + SongList[DataListBox.SelectedIndex].SongTitle;
            LabelArtist.Content    = "歌手:" + SongList[DataListBox.SelectedIndex].Artist;
            LabelAlbumName.Content = "专辑:" + SongList[DataListBox.SelectedIndex].Album;
            //TextBoxAlbumName.Text = SongList[DataListBox.SelectedIndex].Album;
            DataListBoxDoubleClick.Begin();   //StoryBoard

            //判断是否存在iTunes的目录
            string MyMusicDir = System.Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);

            MyMusicDir += @"\iTunes\iTunes Media\自动添加到 iTunes";
            if (!Directory.Exists(MyMusicDir))
            {
                CheckBox4.IsEnabled = false;
                CheckBox4.IsChecked = false;
            }
            else
            {
                CheckBox4.IsEnabled = true;
                CheckBox4.IsChecked = /*true*/ INIClass.IniReadValue("CheckBox4");;
            }

            swich.Visibility = Visibility.Hidden;
        }
Ejemplo n.º 4
0
        private void GetLyrics()
        {
            this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
            {
                CheckBox2.IsEnabled = false;
                CheckBox2.IsChecked = false;
                CheckBox3.IsEnabled = false;
                CheckBox3.IsChecked = false;
            });
            StringBuilder Resulta = new StringBuilder();

            Resulta.Capacity = 65536;
            string SongTitle = SongList[SourceTAR].SongTitle;
            string Artist    = SongList[SourceTAR].Artist;



            //ふわふわ时间 (#23『放课后!』Mix)
            Regex r = new Regex(@"(\(|().*?(\)|))");

            SongTitle = r.Replace(SongTitle, "");
            Artist    = r.Replace(Artist, "");
            GetLyrics(SongTitle, Artist, INIClass.IniReadValue("LyricsServer") ? 1 : 0, Resulta);
            DynamicLyrics = Resulta.ToString();
            if (!string.IsNullOrEmpty(DynamicLyrics))
            {
                Regex regex = new Regex(@"\[.*?\]",
                                        RegexOptions.IgnoreCase);

                StaticLyrics = regex.Replace(DynamicLyrics, "").Trim();

                this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
                {
                    CheckBox2.IsEnabled = true;
                    CheckBox2.IsChecked = INIClass.IniReadValue("CheckBox2");
                    CheckBox3.IsEnabled = true;
                    CheckBox3.IsChecked = INIClass.IniReadValue("CheckBox3");
                });
            }
            else
            {
                StaticLyrics = "";
            }
        }