Flow.Launcher/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
Kevin Zhang 7854cf348b Finishing editing logic, and add a few interactive for ActionKeywordSetting.xaml
1. It will automatically focus on the textbox
2. Enter will trigger the done button
2021-06-06 11:01:50 +08:00

56 lines
1.9 KiB
C#

using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Infrastructure.Storage;
using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using System.Diagnostics;
using System.Threading.Tasks;
namespace Flow.Launcher.Plugin.Explorer.ViewModels
{
public class SettingsViewModel
{
internal Settings Settings { get; set; }
internal PluginInitContext Context { get; set; }
public SettingsViewModel(PluginInitContext context, Settings settings)
{
Context = context;
Settings = settings;
}
public void Save()
{
Context.API.SaveSettingJsonStorage<Settings>();
}
internal void RemoveLinkFromQuickAccess(AccessLink selectedRow) => Settings.QuickAccessLinks.Remove(selectedRow);
internal void RemoveAccessLinkFromExcludedIndexPaths(AccessLink selectedRow) => Settings.IndexSearchExcludedSubdirectoryPaths.Remove(selectedRow);
internal void OpenWindowsIndexingOptions()
{
var psi = new ProcessStartInfo
{
FileName = "control.exe",
UseShellExecute = true,
Arguments = Constants.WindowsIndexingOptions
};
Process.Start(psi);
}
internal void UpdateActionKeyword(Settings.ActionKeyword modifiedActionKeyword, string newActionKeyword, string oldActionKeyword)
{
PluginManager.ReplaceActionKeyword(Context.CurrentPluginMetadata.ID, oldActionKeyword, newActionKeyword);
}
internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword)
{
return PluginManager.ActionKeywordRegistered(newActionKeyword);
}
internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign;
}
}