Ejemplo n.º 1
0
 public static List <SearchListItem> ParseAlbums(string json)
 {
     try
     {
         List <SearchListItem> results = new List <SearchListItem>();
         JObject obj   = JObject.Parse(json);
         JArray  array = obj["results"] as JArray;
         for (int i = 0; i < array.Count; i++)
         {
             JObject        itemObject = array[i] as JObject;
             SearchListItem item       = new SearchListItem();
             item.Name        = TextTools.GetTidyText(itemObject["collectionName"].ToString());
             item.Info        = TextTools.GetTidyText(itemObject["artistName"].ToString());
             item.ImageSource = new ImageSource()
             {
                 Sizex30  = itemObject["artworkUrl30"].ToString(),
                 Sizex60  = itemObject["artworkUrl60"].ToString(),
                 Sizex100 = itemObject["artworkUrl100"].ToString()
             };
             item.Type = "Album";
         }
         return(results);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
 private void lbSearchResults_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (lbSearchResults.SelectedItem != null)
     {
         SearchListItem item   = (SearchListItem)lbSearchResults.SelectedItem;
         CodeEditor     editor = (CodeEditor)EditorsManager.GetEditor(item.File.ToString());
         editor.Edit();
         editor.ToLine(item.Line);
     }
 }
Ejemplo n.º 3
0
        public static List <SearchListItem> ParseAll(string json)
        {
            try
            {
                List <SearchListItem> results = new List <SearchListItem>();
                JObject obj   = JObject.Parse(json);
                JArray  array = obj["results"] as JArray;
                for (int i = 0; i < array.Count; i++)
                {
                    JObject        itemObject = array[i] as JObject;
                    SearchListItem item       = new SearchListItem();
                    if (itemObject["wrapperType"].ToString() == "artist")
                    {
                        item.Id   = Convert.ToInt32(itemObject["artistId"].ToString());
                        item.Name = TextTools.GetTidyText(itemObject["artistName"].ToString());
                        item.Type = "Artist";
                    }
                    else if (itemObject["wrapperType"].ToString() == "collection")
                    {
                        item.Id   = Convert.ToInt32(itemObject["collectionId"].ToString());
                        item.Name = TextTools.GetTidyText(itemObject["collectionName"].ToString());
                        item.Info = TextTools.GetTidyText(itemObject["artistName"].ToString());
                        item.Type = "Album";
                    }
                    else if (itemObject["wrapperType"].ToString() == "track")
                    {
                        item.Id   = Convert.ToInt32(itemObject["trackId"].ToString());
                        item.Name = TextTools.GetTidyText(itemObject["trackName"].ToString());
                        item.Info = TextTools.GetTidyText(itemObject["artistName"].ToString());
                        item.Type = "Song";
                    }

                    try
                    {
                        item.ImageSource = new ImageSource()
                        {
                            Sizex30  = itemObject["artworkUrl30"].ToString(),
                            Sizex60  = itemObject["artworkUrl60"].ToString(),
                            Sizex100 = itemObject["artworkUrl100"].ToString()
                        };
                    }
                    catch (Exception) { }
                    results.Add(item);
                }
                return(results);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
 private bool ShouldBeVisible(SearchListItem item, bool useTags)
 {
     if (_filterValue != "")
     {
         if (item.Name.ToLower().IndexOf(_filterValue.ToLower()) == -1)
         {
             return(false);
         }
     }
     if (useTags && (item.TagProvider == null || !item.TagProvider.Checked))
     {
         return(false);
     }
     return(true);
 }