mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-06 03:07:54 +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>
|
/// </summary>
|
||||||
public partial class AddProgramSource
|
public partial class AddProgramSource
|
||||||
{
|
{
|
||||||
|
private PluginInitContext _context;
|
||||||
private Settings.ProgramSource _editing;
|
private Settings.ProgramSource _editing;
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
|
|
||||||
public AddProgramSource(Settings settings)
|
public AddProgramSource(PluginInitContext context, Settings settings)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_context = context;
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
Directory.Focus();
|
Directory.Focus();
|
||||||
}
|
}
|
||||||
@ -40,7 +42,13 @@ namespace Wox.Plugin.Program
|
|||||||
|
|
||||||
private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
|
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
|
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_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_plugin_description">Search programs in Wox</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="wox_plugin_program_invalid_path">Invalid Path</system:String>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
@ -35,4 +35,6 @@
|
|||||||
<system:String x:Key="wox_plugin_program_plugin_name">程序</system:String>
|
<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_plugin_description">在Wox中搜索程序</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="wox_plugin_program_invalid_path">无效路径</system:String>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
@ -42,7 +42,7 @@ namespace Wox.Plugin.Program
|
|||||||
|
|
||||||
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
|
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var add = new AddProgramSource(_settings);
|
var add = new AddProgramSource(context, _settings);
|
||||||
if(add.ShowDialog() ?? false)
|
if(add.ShowDialog() ?? false)
|
||||||
{
|
{
|
||||||
ReIndexing();
|
ReIndexing();
|
||||||
|
Loading…
Reference in New Issue
Block a user