2016-03-26 09:20:42 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Wox.Core.Plugin;
|
2016-02-19 23:26:13 +08:00
|
|
|
|
using Wox.Core.Resource;
|
|
|
|
|
using Wox.Infrastructure;
|
2016-02-18 19:31:15 +08:00
|
|
|
|
using Wox.Infrastructure.Hotkey;
|
|
|
|
|
using Wox.Plugin;
|
|
|
|
|
using Wox.Storage;
|
|
|
|
|
|
|
|
|
|
namespace Wox.ViewModel
|
|
|
|
|
{
|
2016-02-21 23:19:42 +08:00
|
|
|
|
public class ResultViewModel : BaseViewModel
|
2016-02-18 19:31:15 +08:00
|
|
|
|
{
|
|
|
|
|
#region Private Fields
|
|
|
|
|
|
2016-02-19 21:36:44 +08:00
|
|
|
|
private bool _isSelected;
|
2016-02-18 19:31:15 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructor
|
|
|
|
|
|
2016-02-21 23:19:42 +08:00
|
|
|
|
public ResultViewModel(Result result)
|
2016-02-18 19:31:15 +08:00
|
|
|
|
{
|
2016-02-23 05:47:10 +08:00
|
|
|
|
if (result != null)
|
2016-02-18 19:31:15 +08:00
|
|
|
|
{
|
2016-02-21 23:42:37 +08:00
|
|
|
|
RawResult = result;
|
2016-02-18 19:31:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-19 23:26:13 +08:00
|
|
|
|
|
2016-02-18 19:31:15 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ViewModel Properties
|
|
|
|
|
|
2016-02-21 23:42:37 +08:00
|
|
|
|
public string Title => RawResult.Title;
|
2016-02-18 19:31:15 +08:00
|
|
|
|
|
2016-02-21 23:42:37 +08:00
|
|
|
|
public string SubTitle => RawResult.SubTitle;
|
2016-02-18 19:31:15 +08:00
|
|
|
|
|
2016-02-21 23:42:37 +08:00
|
|
|
|
public string FullIcoPath => RawResult.FullIcoPath;
|
2016-02-18 19:31:15 +08:00
|
|
|
|
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public string PluginID => RawResult.PluginID;
|
|
|
|
|
public int Score
|
|
|
|
|
{
|
|
|
|
|
get { return RawResult.Score; }
|
|
|
|
|
set { RawResult.Score = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Query OriginQuery
|
|
|
|
|
{
|
|
|
|
|
get { return RawResult.OriginQuery; }
|
|
|
|
|
set { RawResult.OriginQuery = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Func<ActionContext, bool> Action
|
|
|
|
|
{
|
|
|
|
|
get { return RawResult.Action; }
|
|
|
|
|
set { RawResult.Action = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-19 21:36:44 +08:00
|
|
|
|
public bool IsSelected
|
|
|
|
|
{
|
|
|
|
|
get { return _isSelected; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isSelected = value;
|
2016-02-27 08:09:12 +08:00
|
|
|
|
OnPropertyChanged();
|
2016-02-19 21:36:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-18 19:31:15 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
2016-04-21 08:53:21 +08:00
|
|
|
|
internal Result RawResult { get; }
|
2016-02-18 19:31:15 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public void Update(ResultViewModel newResult)
|
|
|
|
|
{
|
|
|
|
|
RawResult.Score = newResult.RawResult.Score;
|
|
|
|
|
RawResult.OriginQuery = newResult.RawResult.OriginQuery;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-18 22:53:41 +08:00
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
2016-02-21 23:19:42 +08:00
|
|
|
|
ResultViewModel r = obj as ResultViewModel;
|
2016-02-18 22:53:41 +08:00
|
|
|
|
if (r != null)
|
|
|
|
|
{
|
2016-02-21 23:42:37 +08:00
|
|
|
|
return RawResult.Equals(r.RawResult);
|
2016-02-18 22:53:41 +08:00
|
|
|
|
}
|
2016-02-21 22:40:10 +08:00
|
|
|
|
|
2016-02-19 22:55:58 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
2016-02-21 23:42:37 +08:00
|
|
|
|
return RawResult.GetHashCode();
|
2016-02-19 22:55:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
2016-02-21 23:42:37 +08:00
|
|
|
|
return RawResult.ToString();
|
2016-02-18 22:53:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-18 19:31:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|