mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
move properties into models
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Wox.Infrastructure.Image;
|
||||
using Wox.Plugin;
|
||||
|
||||
@@ -9,86 +7,39 @@ namespace Wox.ViewModel
|
||||
{
|
||||
public class ResultViewModel : BaseModel
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private bool _isSelected;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public ResultViewModel(Result result)
|
||||
{
|
||||
if (result != null)
|
||||
{
|
||||
RawResult = result;
|
||||
Result = result;
|
||||
}
|
||||
}
|
||||
|
||||
public ImageSource Image => ImageLoader.Load(Result.IcoPath);
|
||||
|
||||
#endregion
|
||||
|
||||
#region ViewModel Properties
|
||||
|
||||
public string Title => RawResult.Title;
|
||||
|
||||
public string SubTitle => RawResult.SubTitle;
|
||||
|
||||
public string PluginID => RawResult.PluginID;
|
||||
|
||||
public ImageSource Image => ImageLoader.Load(RawResult.IcoPath);
|
||||
|
||||
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; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
internal Result RawResult { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
public void Update(ResultViewModel newResult)
|
||||
{
|
||||
RawResult.Score = newResult.RawResult.Score;
|
||||
RawResult.OriginQuery = newResult.RawResult.OriginQuery;
|
||||
}
|
||||
public Result Result { get; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
ResultViewModel r = obj as ResultViewModel;
|
||||
if (r != null)
|
||||
{
|
||||
return RawResult.Equals(r.RawResult);
|
||||
return Result.Equals(r.Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return RawResult.GetHashCode();
|
||||
return Result.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return RawResult.ToString();
|
||||
return Result.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user