private void Add_favorite_Click(object sender, RoutedEventArgs e)
        {
            result_playlist.SelectedItem = (e.OriginalSource as FrameworkElement).DataContext;
            if (result_playlist.SelectedIndex != -1)
            {
                PlaylistItem item = (PlaylistItem)result_playlist.SelectedItem;

                foreach (var it in myFavoriteMgr.MyfavoriteCollection)
                {
                    if (it.name.Equals(item.name))
                    {
                        MessageBoxOrange.ShowDialog("Warning", "The item is overlap in your favorite list.");

                        return;
                    }
                }
                url = "http://115.71.236.224:8081/getPlayList?title=" + item.name;
                ProgressRing.IsActive   = true;
                progressGrid.Visibility = Visibility.Visible;
                Thread thread = new Thread(new ThreadStart(ParsingThread_For_addfavorite));
                thread.Start();

                if (!IsFavoritePanel)
                {
                    ShowFavoriteList();
                }
            }
        }
        private void myfavPlayList_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Delete:
                if (favorite_playlist.SelectedIndex != -1)
                {
                    List <PlaylistItem> it = new List <PlaylistItem>();
                    // myPlayList.DataContext = null;
                    foreach (PlaylistItem item in favorite_playlist.SelectedItems)
                    {
                        it.Add(item);
                    }
                    foreach (PlaylistItem item in it)
                    {
                        try
                        {
                            String path          = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                            string filedirectory = path + @"\OrangePlayer\favoritePlaylist";
                            //string filedirectory = System.AppDomain.CurrentDomain.BaseDirectory + "/favoritePlaylist";

                            string filepath = string.Format("{0}/{1}.orm", filedirectory, item.name);

                            if (File.Exists(filepath))
                            {
                                myFavoriteMgr.MyfavoriteCollection.Remove(item);
                                File.Delete(filepath);
                            }
                            else
                            {
                                myFavoriteMgr.MyfavoriteCollection.Remove(item);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBoxOrange.ShowDialog("Exception", ex.Message);
                        }
                    }
                    it.Clear();
                }
                break;
            }
        }
        private void ParsingThread()
        {
            Thread.Sleep(1000);
            try
            {
                JsonArrayCollection items = JSONHelper.getJSONArray(url_yotube);

                Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
                {
                    foreach (JsonObjectCollection item in items)
                    {
                        string title = item["title"].GetValue().ToString();

                        ////수정해야
                        // string mUrl = item["singer"].GetValue().ToString();
                        // string playTime = item["singer"].GetValue().ToString();
                        string mUrl     = item["url"].GetValue().ToString().Replace("http://www.youtube.com/watch?v=", "");;
                        string playTime = item["time"].GetValue().ToString();


                        MusicItem mitem = new MusicItem();
                        mitem.title     = title;
                        mitem.url       = mUrl;
                        mitem.time      = playTime;
                        musicCollection.Add(mitem);
                    }
                }));

                Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
                {
                    HideDrawerMenu();
                }));
            }
            catch (Exception e) {
                Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
                {
                    MessageBoxOrange.ShowDialog("Exception", e.Message);
                    HideDrawerMenu();
                }));
            }
        }
        private void SearchingThread()
        {
            try
            {
                MusicJson       playerList = Newtonsoft.Json.JsonConvert.DeserializeObject <MusicJson>(JSONHelper.getJsondata(query));
                List <JsonItem> items      = playerList.play_list;
                int             total_page = Int32.Parse(playerList.page_cnt);
//                Console.WriteLine("{0}", total);
//                foreach(var it in items)
//                {
//                    Console.WriteLine("{0} {1}", it.title, it.hits_count);
//
//                }
                if (items.Count > 0)
                {
                    //MessageBoxOrange.ShowDialog(col.Count.ToString());

                    Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
                    {
                        foreach (JsonItem item in items)
                        {
                            string resultTitle    = item.title;
                            string resultHitcount = item.hits_count;
                            PlaylistItem mitem    = new PlaylistItem();
                            mitem.name            = resultTitle;
                            mitem.hits_count      = resultHitcount;
                            playCollection.Add(mitem);
                        }

                        if (cur_page < total_page)
                        {
                            morebtn.Visibility = Visibility.Visible;
                        }
                        else if (cur_page == total_page)
                        {
                            morebtn.Visibility = Visibility.Collapsed;
                        }

                        ProgressRing.IsActive   = false;
                        progressGrid.Visibility = Visibility.Collapsed;
                    }));
                }
                else
                {
                    Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
                    {
                        MessageBoxOrange.ShowDialog("Warning", "There is no any the result.");
                        ProgressRing.IsActive   = false;
                        progressGrid.Visibility = Visibility.Collapsed;
                    }));
                }
            }
            catch (Exception e)
            {
                Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
                {
                    MessageBoxOrange.ShowDialog("Warning", e.Message);
                    ProgressRing.IsActive   = false;
                    progressGrid.Visibility = Visibility.Collapsed;
                }));
            }
        }
        private void ParsingThread_For_addfavorite()
        {
            Thread.Sleep(1000);
            try
            {
                JsonArrayCollection items = JSONHelper.getJSONArray(url);
                MusicCollection     tmp_musicCollection = new MusicCollection();
                Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
                {
                    foreach (JsonObjectCollection item in items)
                    {
                        string title = item["title"].GetValue().ToString();
                        ////수정해야
                        // string mUrl = item["singer"].GetValue().ToString();
                        // string playTime = item["singer"].GetValue().ToString();
                        string mUrl     = item["url"].GetValue().ToString().Replace("http://www.youtube.com/watch?v=", "");;
                        string playTime = item["time"].GetValue().ToString();


                        MusicItem mitem = new MusicItem();
                        mitem.title     = title;
                        mitem.url       = mUrl;
                        mitem.time      = playTime;
                        tmp_musicCollection.Add(mitem);
                    }

                    PlaylistItem pitem   = (PlaylistItem)result_playlist.SelectedItem;
                    String path          = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    string filedirectory = path + @"\OrangePlayer\favoritePlaylist";
                    // string filedirectory = System.AppDomain.CurrentDomain.BaseDirectory + "/favoritePlaylist";

                    if (!Directory.Exists(filedirectory))
                    {
                        Directory.CreateDirectory(filedirectory);
                    }


                    string filepath = string.Format("{0}/{1}.orm", filedirectory, pitem.name);
                    //System.AppDomain.CurrentDomain.BaseDirectory
                    //System.IO.Directory.GetCurrentDirectory();
                    File.WriteAllText(filepath, Security.Encrypt(Newtonsoft.Json.JsonConvert.SerializeObject(tmp_musicCollection)));

                    if (File.Exists(filepath))
                    {
                        PlaylistItem item = new PlaylistItem();
                        item.name         = pitem.name;
                        item.filePath     = filepath;

                        myFavoriteMgr.MyfavoriteCollection.Add(item);
                    }
                    else
                    {
                        MessageBoxOrange.ShowDialog("Exception", "failed to create the file");
                    }
                }));
            }
            catch (Exception e)
            {
                Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
                {
                    MessageBoxOrange.ShowDialog("Exception", e.Message);
                }));
            }
            Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
            {
                ProgressRing.IsActive   = false;
                progressGrid.Visibility = Visibility.Collapsed;
            }));
        }