PowerToys/Plugins/Wox.Plugin.WebSearch/Settings.cs

226 lines
7.7 KiB
C#
Raw Normal View History

using System;
using System.Collections.ObjectModel;
using Newtonsoft.Json;
using Wox.Plugin.WebSearch.SuggestionSources;
namespace Wox.Plugin.WebSearch
{
public class Settings : BaseModel
{
public Settings()
{
SelectedSuggestion = Suggestions[0];
if (SearchSources.Count > 0)
2016-01-08 09:13:36 +08:00
{
SelectedSearchSource = SearchSources[0];
}
}
public ObservableCollection<SearchSource> SearchSources { get; set; } = new ObservableCollection<SearchSource>
{
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Google",
ActionKeyword = "g",
Icon = "google.png",
2016-02-15 13:03:04 +08:00
Url = "https://www.google.com/search?q={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
{
Title = "Google Scholar",
ActionKeyword = "sc",
Icon = "google.png",
Url = "https://scholar.google.com/scholar?q={q}",
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Wikipedia",
ActionKeyword = "wiki",
Icon = "wiki.png",
Url = "https://en.wikipedia.org/wiki/{q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "FindIcon",
ActionKeyword = "findicon",
Icon = "pictures.png",
2016-02-15 13:03:04 +08:00
Url = "http://findicons.com/search/{q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Facebook",
ActionKeyword = "facebook",
Icon = "facebook.png",
Url = "https://www.facebook.com/search/?q={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Twitter",
ActionKeyword = "twitter",
Icon = "twitter.png",
Url = "https://twitter.com/search?q={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Google Maps",
ActionKeyword = "maps",
Icon = "google_maps.png",
Url = "https://maps.google.com/maps?q={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Google Translate",
ActionKeyword = "translate",
Icon = "google_translate.png",
Url = "https://translate.google.com/#auto|en|{q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Duckduckgo",
ActionKeyword = "duckduckgo",
Icon = "duckduckgo.png",
2016-02-15 13:03:04 +08:00
Url = "https://duckduckgo.com/?q={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Github",
ActionKeyword = "github",
Icon = "github.png",
2016-02-15 13:03:04 +08:00
Url = "https://github.com/search?q={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Github Gist",
ActionKeyword = "gist",
Icon = "gist.png",
2016-02-15 13:03:04 +08:00
Url = "https://gist.github.com/search?q={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Gmail",
ActionKeyword = "gmail",
Icon = "gmail.png",
2016-02-15 13:03:04 +08:00
Url = "https://mail.google.com/mail/ca/u/0/#apps/{q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Google Drive",
ActionKeyword = "drive",
Icon = "google_drive.png",
Url = "https://drive.google.com/?hl=en&tab=bo#search/{q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Wolframalpha",
ActionKeyword = "wolframalpha",
Icon = "wolframalpha.png",
Url = "https://www.wolframalpha.com/input/?i={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Stackoverflow",
ActionKeyword = "stackoverflow",
Icon = "stackoverflow.png",
Url = "https://stackoverflow.com/search?q={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "I'm Feeling Lucky",
ActionKeyword = "lucky",
Icon = "google.png",
Url = "https://google.com/search?q={q}&btnI=I",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Google Image",
ActionKeyword = "image",
Icon = "google.png",
2016-02-15 13:03:04 +08:00
Url = "https://www.google.com/search?q={q}&tbm=isch",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Youtube",
ActionKeyword = "youtube",
Icon = "youtube.png",
Url = "https://www.youtube.com/results?search_query={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Bing",
ActionKeyword = "bing",
Icon = "bing.png",
2016-02-15 13:03:04 +08:00
Url = "https://www.bing.com/search?q={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
2016-01-08 09:13:36 +08:00
{
Title = "Yahoo",
ActionKeyword = "yahoo",
Icon = "yahoo.png",
Url = "https://www.search.yahoo.com/search?p={q}",
2016-01-08 09:13:36 +08:00
Enabled = true
},
new SearchSource
{
Title = "Baidu",
ActionKeyword = "bd",
Icon = "baidu.png",
Url = "https://www.baidu.com/#ie=UTF-8&wd={q}",
Enabled = true
2016-01-08 09:13:36 +08:00
}
};
[JsonIgnore]
public SearchSource SelectedSearchSource { get; set; }
public bool EnableSuggestion { get; set; }
[JsonIgnore]
public SuggestionSource[] Suggestions { get; set; } = {
new Google(),
new Baidu()
};
[JsonIgnore]
public SuggestionSource SelectedSuggestion { get; set; }
/// <summary>
/// used to store Settings.json only
/// </summary>
public string Suggestion
{
get
{
return SelectedSuggestion.ToString();
}
set
{
foreach (var s in Suggestions)
{
if (string.Equals(s.ToString(), value, StringComparison.OrdinalIgnoreCase))
{
SelectedSuggestion = s;
}
}
}
}
2016-01-08 09:13:36 +08:00
}
2016-01-08 09:13:36 +08:00
}