2016-02-18 19:31:15 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Wox.Infrastructure.Hotkey;
|
|
|
|
|
using Wox.Plugin;
|
|
|
|
|
using Wox.Storage;
|
|
|
|
|
|
|
|
|
|
namespace Wox.ViewModel
|
|
|
|
|
{
|
|
|
|
|
public class ResultItemViewModel : BaseViewModel
|
|
|
|
|
{
|
|
|
|
|
#region Private Fields
|
|
|
|
|
|
|
|
|
|
private Result _result;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructor
|
|
|
|
|
|
|
|
|
|
public ResultItemViewModel(Result result)
|
|
|
|
|
{
|
|
|
|
|
if(null!= result)
|
|
|
|
|
{
|
|
|
|
|
this._result = result;
|
|
|
|
|
|
2016-02-12 14:21:12 +08:00
|
|
|
|
this.OpenResultCommand = new RelayCommand((parameter) => {
|
2016-02-18 19:31:15 +08:00
|
|
|
|
|
|
|
|
|
bool hideWindow = result.Action(new ActionContext
|
|
|
|
|
{
|
|
|
|
|
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (null != this.ResultOpened)
|
|
|
|
|
{
|
|
|
|
|
this.ResultOpened(this, new ResultOpenedEventArgs(hideWindow));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-02-12 14:21:12 +08:00
|
|
|
|
this.OpenResultActionPanelCommand = new RelayCommand((parameter) => {
|
2016-02-18 19:31:15 +08:00
|
|
|
|
|
|
|
|
|
if(null!= ResultActionPanelOpened)
|
|
|
|
|
{
|
|
|
|
|
this.ResultActionPanelOpened(this, new EventArgs());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ViewModel Properties
|
|
|
|
|
|
|
|
|
|
public string Title
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._result.Title;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string SubTitle
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._result.SubTitle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string FullIcoPath
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._result.FullIcoPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RelayCommand OpenResultCommand
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RelayCommand OpenResultActionPanelCommand
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
|
|
|
|
public Result RawResult
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2016-02-18 22:53:41 +08:00
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
ResultItemViewModel r = obj as ResultItemViewModel;
|
|
|
|
|
if (r != null)
|
|
|
|
|
{
|
|
|
|
|
var equality = string.Equals(r.Title, Title) &&
|
|
|
|
|
string.Equals(r.SubTitle, SubTitle);
|
|
|
|
|
return equality;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-18 19:31:15 +08:00
|
|
|
|
public event EventHandler<ResultOpenedEventArgs> ResultOpened;
|
|
|
|
|
|
|
|
|
|
public event EventHandler ResultActionPanelOpened;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ResultOpenedEventArgs : EventArgs
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public bool HideWindow
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
private set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResultOpenedEventArgs(bool hideWindow)
|
|
|
|
|
{
|
|
|
|
|
this.HideWindow = hideWindow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|