Example #1
0
        /// <summary>
        /// Initialize the searches list from from what's in the config file.
        /// </summary>
        private void SetupSearchMethods()
        {
            lstSearches.Items.Clear();

            /// <summary>
            /// The list of search methods to use.
            /// </summary>
            foreach (SearchMethods sm in Settings.Instance.Searches)
            {
                WallpaperAbyssApiV2.CollectionListItem item = null;

                switch (sm.Method)
                {
                case WallpaperAbyssApiV2.LookupMethods.search:
                    lstSearches.Items.Add(sm.Method + " " + sm.SearchTerm);
                    break;

                case WallpaperAbyssApiV2.LookupMethods.category:
                    if (Settings.Instance.APIKey != null)
                    {
                        item = WallpaperAbyssApiV2.WallpaperAbyss.GetCategoryList().Find((x => x.Id == sm.Id));
                    }
                    if (item != null)
                    {
                        lstSearches.Items.Add(sm.Method + " " + item.Name);
                    }
                    else
                    {
                        lstSearches.Items.Add(sm.Method);
                    }
                    break;

                case WallpaperAbyssApiV2.LookupMethods.collection:
                    if (Settings.Instance.APIKey != null)
                    {
                        item = WallpaperAbyssApiV2.WallpaperAbyss.GetCollectionList().Find((x => x.Id == sm.Id));
                    }
                    if (item != null)
                    {
                        lstSearches.Items.Add(sm.Method + " " + item.Name);
                    }
                    else
                    {
                        lstSearches.Items.Add(sm.Method);
                    }
                    break;

                case WallpaperAbyssApiV2.LookupMethods.group:
                    if (Settings.Instance.APIKey != null)
                    {
                        item = WallpaperAbyssApiV2.WallpaperAbyss.GetGroupList(sm.Id).Find((x => x.Id == sm.SubId));
                        if (item != null)
                        {
                            lstSearches.Items.Add(sm.Method + " " + item.Name);
                        }
                        else
                        {
                            lstSearches.Items.Add(sm.Method + " " + sm.Id + " " + sm.SubId);
                        }
                    }
                    else
                    {
                        lstSearches.Items.Add(sm.Method + " " + sm.Id + " " + sm.SubId);
                    }
                    break;

                case WallpaperAbyssApiV2.LookupMethods.sub_category:
                    if (Settings.Instance.APIKey != null)
                    {
                        item = WallpaperAbyssApiV2.WallpaperAbyss.GetSubCategoryList(sm.Id).Find((x => x.Id == sm.SubId));
                        if (item != null)
                        {
                            lstSearches.Items.Add(sm.Method + " " + item.Name);
                        }
                        else
                        {
                            lstSearches.Items.Add(sm.Method + " " + sm.Id + " " + sm.SubId);
                        }
                    }
                    else
                    {
                        lstSearches.Items.Add(sm.Method + " " + sm.Id + " " + sm.SubId);
                    }
                    break;

                default:
                    lstSearches.Items.Add(sm.Method);
                    break;
                }

                //sm.Height;
                //sm.Width;
                //sm.Id;
                //sm.Method;
                //sm.SizeOp;
                //sm.SortBy;
                //sm.SearchTerm;
            }
            lstSearches.SelectedIndex = 0;
        }
Example #2
0
        /// <summary>
        /// Called when Apply button is clicked (btnApplyMatch_Click)
        /// Applies search method changes
        /// </summary>
        private void UpdateCollectionList()
        {
            WallpaperAbyssApiV2.CollectionListItem item = null;

            if (lstCollectionLabels.Items.Count == 0)
            {
                cboLookupMethods_SelectedIndexChanged(null, null);

                //cboLookupMethods.SelectedIndex = 0;
                if (lstCollectionLabels.Items.Count > 0)
                {
                    lstCollectionLabels.SelectedItem = lstCollectionLabels.Items[0];
                }
            }
            SearchMethods search = new SearchMethods();

            search.Height = (int)txtHeight.Value;
            search.Width  = (int)txtWidth.Value;

            switch (cboSortMethods.SelectedItem.ToString().ToLower())
            {
            case "newest":
                search.SortBy = WallpaperAbyssApiV2.SortMethods.Newest;
                break;

            case "rating":
                search.SortBy = WallpaperAbyssApiV2.SortMethods.Rating;
                break;

            case "views":
                search.SortBy = WallpaperAbyssApiV2.SortMethods.Views;
                break;

            case "favorites":
                search.SortBy = WallpaperAbyssApiV2.SortMethods.Favorites;
                break;
            }

            switch (cboSizeOperators.SelectedItem.ToString().ToLower())
            {
            case "equal":
                search.SizeOp = WallpaperAbyssApiV2.SizeOperators.Equal;
                break;

            case "max":
                search.SizeOp = WallpaperAbyssApiV2.SizeOperators.Max;
                break;

            case "min":
                search.SizeOp = WallpaperAbyssApiV2.SizeOperators.Min;
                break;
            }

            switch (cboLookupMethods.SelectedItem.ToString().ToLower())
            {
            default:
            case "newest":
                search.Method = WallpaperAbyssApiV2.LookupMethods.newest;

                if (lstCollectionLabels.Items.Count > 0)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetCategoryList().Find((x => x.Name.Equals(lstCollectionLabels.SelectedItem.ToString(), StringComparison.InvariantCultureIgnoreCase)));
                }
                if (item != null)
                {
                    search.Id = item.Id;
                }
                break;

            case "highest rated":
                search.Method = WallpaperAbyssApiV2.LookupMethods.highest_rated;
                break;

            case "by views":
                search.Method = WallpaperAbyssApiV2.LookupMethods.by_views;
                break;

            case "by favorites":
                search.Method = WallpaperAbyssApiV2.LookupMethods.by_favorites;
                break;

            case "featured":
                search.Method = WallpaperAbyssApiV2.LookupMethods.featured;
                break;

            case "popular":
                search.Method = WallpaperAbyssApiV2.LookupMethods.popular;
                break;

            case "random":
                search.Method = WallpaperAbyssApiV2.LookupMethods.random;
                break;

            case "category":
                search.Method = WallpaperAbyssApiV2.LookupMethods.category;
                if (lstCollectionLabels.Items.Count > 0)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetCategoryList().Find((x => x.Name.Equals(lstCollectionLabels.SelectedItem.ToString(), StringComparison.InvariantCultureIgnoreCase)));
                }
                if (item != null)
                {
                    search.Id = item.Id;
                }
                break;

            case "collection":
                search.Method = WallpaperAbyssApiV2.LookupMethods.collection;
                if (lstCollectionLabels.Items.Count > 0)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetCategoryList().Find((x => x.Name.Equals(lstCollectionLabels.SelectedItem.ToString(), StringComparison.InvariantCultureIgnoreCase)));
                }
                if (item != null)
                {
                    search.Id = item.Id;
                }
                break;

            case "search":
                search.Method = WallpaperAbyssApiV2.LookupMethods.search;
                if (lstCollectionLabels.Items.Count > 0)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetCategoryList().Find((x => x.Name.Equals(lstCollectionLabels.SelectedItem.ToString(), StringComparison.InvariantCultureIgnoreCase)));
                }
                if (item != null)
                {
                    search.Id = item.Id;
                }
                search.SearchTerm = txtSearchTerm.Text;
                break;

            case "user":
                search.Method = WallpaperAbyssApiV2.LookupMethods.user;
                if (lstCollectionLabels.Items.Count > 0)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetCategoryList().Find((x => x.Name.Equals(lstCollectionLabels.SelectedItem.ToString(), StringComparison.InvariantCultureIgnoreCase)));
                }
                if (item != null)
                {
                    search.Id = item.Id;
                }
                search.SearchTerm = txtSearchTerm.Text;
                break;

            case "sub category":     //Needs Collection
                search.Method = WallpaperAbyssApiV2.LookupMethods.sub_category;
                if (lstCollectionLabels.Items.Count > 0)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetCategoryList().Find((x => x.Name.Equals(lstCollectionLabels.SelectedItem.ToString(), StringComparison.InvariantCultureIgnoreCase)));
                }
                if (item != null)
                {
                    search.Id = item.Id;
                }

                if (lstSubCollection.Items.Count > 0)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetSubCategoryList(item.Id).Find((x => x.Name.Equals(lstSubCollection.SelectedItem.ToString(), StringComparison.InvariantCultureIgnoreCase)));
                }
                if (item != null)
                {
                    search.SubId = item.Id;
                }
                break;

            case "group":     //Needs Collection
                search.Method = WallpaperAbyssApiV2.LookupMethods.group;
                if (lstCollectionLabels.Items.Count > 0)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetCategoryList().Find((x => x.Name.Equals(lstCollectionLabels.SelectedItem.ToString(), StringComparison.InvariantCultureIgnoreCase)));
                }
                if (item != null)
                {
                    search.Id = item.Id;
                }

                if (lstSubCollection.Items.Count > 0)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetGroupList(item.Id).Find((x => x.Name.Equals(lstSubCollection.SelectedItem.ToString(), StringComparison.InvariantCultureIgnoreCase)));
                }
                if (item != null)
                {
                    search.SubId = item.Id;
                }
                break;
            }

            Settings.Instance.Searches[lstSearches.SelectedIndex] = search;

            //SetupSearchMethods();
            //SetupSearchMethod(lstSearches.SelectedIndex);
        }
Example #3
0
        /// <summary>
        /// When a search method (search list) is clicked update the frames to show the appropriate fields for the search type
        /// </summary>
        /// <param name="index">Index of the settings searches</param>
        private void SetupSearchMethodName(int index)
        {
            if (index < 0 || index >= Settings.Instance.Searches.Count)
            {
                return;
            }

            SearchMethods sm = Settings.Instance.Searches[index];

            WallpaperAbyssApiV2.CollectionListItem item = null;

            switch (sm.Method)
            {
            case WallpaperAbyssApiV2.LookupMethods.search:
                lstSearches.Items[index] = (sm.Method + " " + sm.SearchTerm);
                break;

            case WallpaperAbyssApiV2.LookupMethods.category:
                if (Settings.Instance.APIKey != null)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetCategoryList().Find((x => x.Id == sm.Id));
                }
                if (item != null)
                {
                    lstSearches.Items[index] = (sm.Method + " " + item.Name);
                }
                else
                {
                    lstSearches.Items[index] = (sm.Method);
                }
                break;

            case WallpaperAbyssApiV2.LookupMethods.collection:
                if (Settings.Instance.APIKey != null)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetCollectionList().Find((x => x.Id == sm.Id));
                }
                if (item != null)
                {
                    lstSearches.Items[index] = (sm.Method + " " + item.Name);
                }
                else
                {
                    lstSearches.Items[index] = (sm.Method);
                }
                break;

            case WallpaperAbyssApiV2.LookupMethods.group:
                if (Settings.Instance.APIKey != null)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetGroupList(sm.Id).Find((x => x.Id == sm.SubId));
                    if (item != null)
                    {
                        lstSearches.Items[index] = (sm.Method + " " + item.Name);
                    }
                    else
                    {
                        lstSearches.Items[index] = (sm.Method + " " + sm.Id + " " + sm.SubId);
                    }
                }
                else
                {
                    lstSearches.Items[index] = (sm.Method + " " + sm.Id + " " + sm.SubId);
                }
                break;

            case WallpaperAbyssApiV2.LookupMethods.sub_category:
                if (Settings.Instance.APIKey != null)
                {
                    item = WallpaperAbyssApiV2.WallpaperAbyss.GetSubCategoryList(sm.Id).Find((x => x.Id == sm.SubId));
                    if (item != null)
                    {
                        lstSearches.Items[index] = (sm.Method + " " + item.Name);
                    }
                    else
                    {
                        lstSearches.Items[index] = (sm.Method + " " + sm.Id + " " + sm.SubId);
                    }
                }
                else
                {
                    lstSearches.Items[index] = (sm.Method + " " + sm.Id + " " + sm.SubId);
                }
                break;

            default:
                lstSearches.Items[index] = (sm.Method);
                break;
            }
        }