2020-08-05 14:06:55 -07:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
2020-07-20 11:22:03 -07:00
|
|
|
|
using System.Windows.Input;
|
2020-08-05 14:06:55 -07:00
|
|
|
|
using Microsoft.PowerLauncher.Telemetry;
|
|
|
|
|
|
using Microsoft.PowerToys.Telemetry;
|
2020-07-20 11:22:03 -07:00
|
|
|
|
using Wox.Plugin;
|
|
|
|
|
|
|
|
|
|
|
|
namespace PowerLauncher.ViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public class ContextMenuItemViewModel : BaseModel
|
|
|
|
|
|
{
|
|
|
|
|
|
private ICommand _command;
|
|
|
|
|
|
|
|
|
|
|
|
public string PluginName { get; set; }
|
2020-08-05 14:06:55 -07:00
|
|
|
|
|
2021-01-20 11:23:56 +02:00
|
|
|
|
private string _title;
|
2020-08-05 14:06:55 -07:00
|
|
|
|
|
2021-01-20 11:23:56 +02:00
|
|
|
|
public string Title
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _title;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_title != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
_title = value;
|
|
|
|
|
|
OnPropertyChanged(nameof(Title));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string _glyph;
|
2020-08-05 14:06:55 -07:00
|
|
|
|
|
2021-01-20 11:23:56 +02:00
|
|
|
|
public string Glyph
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _glyph;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_glyph != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
_glyph = value;
|
|
|
|
|
|
OnPropertyChanged(nameof(Glyph));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string _fontFamily;
|
|
|
|
|
|
|
|
|
|
|
|
public string FontFamily
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _fontFamily;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_fontFamily != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
_fontFamily = value;
|
|
|
|
|
|
OnPropertyChanged(nameof(FontFamily));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-08-05 14:06:55 -07:00
|
|
|
|
|
2020-07-22 13:27:17 -07:00
|
|
|
|
public ICommand Command
|
|
|
|
|
|
{
|
2020-07-20 11:22:03 -07:00
|
|
|
|
get
|
|
|
|
|
|
{
|
2020-08-14 09:22:24 -07:00
|
|
|
|
return _command;
|
2020-07-20 11:22:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
// ICommand does not implement the INotifyPropertyChanged interface and must call OnPropertyChanged() to prevent memory leaks
|
2020-08-14 09:22:24 -07:00
|
|
|
|
if (value != _command)
|
2020-07-20 11:22:03 -07:00
|
|
|
|
{
|
2020-08-14 09:22:24 -07:00
|
|
|
|
_command = value;
|
2020-07-20 11:22:03 -07:00
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Key AcceleratorKey { get; set; }
|
2020-08-05 14:06:55 -07:00
|
|
|
|
|
2020-07-20 11:22:03 -07:00
|
|
|
|
public ModifierKeys AcceleratorModifiers { get; set; }
|
2020-08-05 14:06:55 -07:00
|
|
|
|
|
2020-07-20 11:22:03 -07:00
|
|
|
|
public bool IsAcceleratorKeyEnabled { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public void SendTelemetryEvent(LauncherResultActionEvent.TriggerType triggerType)
|
|
|
|
|
|
{
|
|
|
|
|
|
var eventData = new LauncherResultActionEvent()
|
|
|
|
|
|
{
|
|
|
|
|
|
PluginName = PluginName,
|
|
|
|
|
|
Trigger = triggerType.ToString(),
|
2020-08-13 15:32:12 -07:00
|
|
|
|
ActionName = Title,
|
2020-07-20 11:22:03 -07:00
|
|
|
|
};
|
|
|
|
|
|
PowerToysTelemetry.Log.WriteEvent(eventData);
|
|
|
|
|
|
}
|
2020-09-02 13:34:07 -07:00
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Title;
|
|
|
|
|
|
}
|
2020-07-20 11:22:03 -07:00
|
|
|
|
}
|
2020-08-05 14:06:55 -07:00
|
|
|
|
}
|