mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
MVVM refactoring for web search plugin, part 1
1. #486 2. fix #778 #763 #742 3. MVVM refactoring 4. remove IMultipleActionKeywords interface, use PluginManager directly
This commit is contained in:
@@ -1,40 +1,43 @@
|
||||
using System.IO;
|
||||
using System.Windows.Media;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Wox.Infrastructure.Image;
|
||||
|
||||
namespace Wox.Plugin.WebSearch
|
||||
{
|
||||
public class WebSearch
|
||||
public class SearchSource : BaseModel
|
||||
{
|
||||
public const string DefaultIcon = "web_search.png";
|
||||
public string Title { get; set; }
|
||||
public string ActionKeyword { get; set; }
|
||||
[NotNull]
|
||||
private string _icon = DefaultIcon;
|
||||
|
||||
[NotNull]
|
||||
public string Icon
|
||||
{
|
||||
get { return _icon; }
|
||||
set
|
||||
{
|
||||
_icon = value;
|
||||
IconPath = Path.Combine(Main.ImagesDirectory, value);
|
||||
}
|
||||
}
|
||||
public string Icon { private get; set; } = DefaultIcon;
|
||||
|
||||
/// <summary>
|
||||
/// All icon should be put under Images directory
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
[JsonIgnore]
|
||||
internal string IconPath { get; private set; } = Path.Combine
|
||||
(
|
||||
Main.ImagesDirectory, DefaultIcon
|
||||
);
|
||||
internal string IconPath => Path.Combine(Main.ImagesDirectory, Icon);
|
||||
[JsonIgnore]
|
||||
public ImageSource Image => ImageLoader.Load(IconPath);
|
||||
|
||||
public string Url { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public SearchSource DeepCopy()
|
||||
{
|
||||
var webSearch = new SearchSource
|
||||
{
|
||||
Title = string.Copy(Title),
|
||||
ActionKeyword = string.Copy(ActionKeyword),
|
||||
Url = string.Copy(Url),
|
||||
Icon = string.Copy(Icon),
|
||||
Enabled = Enabled
|
||||
};
|
||||
return webSearch;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user