mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 03:37:10 +08:00
validate path before save (fix #1869)
This commit is contained in:
parent
3dd7a82dcc
commit
3fddb77564
@ -9,12 +9,14 @@ namespace Wox.Plugin.Program
|
||||
/// </summary>
|
||||
public partial class AddProgramSource
|
||||
{
|
||||
private PluginInitContext _context;
|
||||
private Settings.ProgramSource _editing;
|
||||
private Settings _settings;
|
||||
|
||||
public AddProgramSource(Settings settings)
|
||||
public AddProgramSource(PluginInitContext context, Settings settings)
|
||||
{
|
||||
InitializeComponent();
|
||||
_context = context;
|
||||
_settings = settings;
|
||||
Directory.Focus();
|
||||
}
|
||||
@ -40,7 +42,13 @@ namespace Wox.Plugin.Program
|
||||
|
||||
private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(_editing == null)
|
||||
string s = Directory.Text;
|
||||
if (!System.IO.Directory.Exists(s))
|
||||
{
|
||||
System.Windows.MessageBox.Show(_context.API.GetTranslation("wox_plugin_program_invalid_path"));
|
||||
return;
|
||||
}
|
||||
if (_editing == null)
|
||||
{
|
||||
var source = new Settings.ProgramSource
|
||||
{
|
||||
|
@ -35,4 +35,6 @@
|
||||
<system:String x:Key="wox_plugin_program_plugin_name">Program</system:String>
|
||||
<system:String x:Key="wox_plugin_program_plugin_description">Search programs in Wox</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_invalid_path">Invalid Path</system:String>
|
||||
|
||||
</ResourceDictionary>
|
@ -35,4 +35,6 @@
|
||||
<system:String x:Key="wox_plugin_program_plugin_name">程序</system:String>
|
||||
<system:String x:Key="wox_plugin_program_plugin_description">在Wox中搜索程序</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_invalid_path">无效路径</system:String>
|
||||
|
||||
</ResourceDictionary>
|
@ -42,7 +42,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var add = new AddProgramSource(_settings);
|
||||
var add = new AddProgramSource(context, _settings);
|
||||
if(add.ShowDialog() ?? false)
|
||||
{
|
||||
ReIndexing();
|
||||
|
Loading…
Reference in New Issue
Block a user