From 6e3ca5391adf3b0749b35cc1b22d9cf27e0a8059 Mon Sep 17 00:00:00 2001
From: 716 <525223688@qq.com>
Date: Fri, 9 Jan 2015 10:23:48 +0800
Subject: [PATCH] 1,fix ImageLoader GetIcon() trigger FileNotFoundException
when file not exist; 2,In FolderPluginSettings when trigger Delete Action
need confirm; 3,Add drag and drop functionality in ProgramSetting and
FileSystemSettings.
Signed-off-by: 716 <525223688@qq.com>
---
.../FolderPluginSettings.xaml | 6 ++-
.../FolderPluginSettings.xaml.cs | 50 ++++++++++++++++++-
Plugins/Wox.Plugin.Folder/Languages/en.xaml | 1 +
.../Wox.Plugin.Folder/Languages/zh-cn.xaml | 3 +-
.../Wox.Plugin.Folder/Languages/zh-tw.xaml | 1 +
.../Wox.Plugin.Program/ProgramSetting.xaml | 4 +-
.../Wox.Plugin.Program/ProgramSetting.xaml.cs | 36 +++++++++++++
Wox/ImageLoader/ImageLoader.cs | 2 +
8 files changed, 97 insertions(+), 6 deletions(-)
diff --git a/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml b/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml
index 4f2270dbd6..93b9178e01 100644
--- a/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml
+++ b/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml
@@ -10,8 +10,10 @@
-
-
+
+
diff --git a/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs b/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs
index 6fda77e312..64845005ea 100644
--- a/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs
+++ b/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs
@@ -27,8 +27,13 @@ namespace Wox.Plugin.Folder
var selectedFolder = lbxFolders.SelectedItem as FolderLink;
if (selectedFolder != null)
{
- FolderStorage.Instance.FolderLinks.Remove(selectedFolder);
- lbxFolders.Items.Refresh();
+ string msg = string.Format(context.API.GetTranslation("wox_plugin_folder_delete_folder_link"), selectedFolder.Path);
+
+ if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
+ {
+ FolderStorage.Instance.FolderLinks.Remove(selectedFolder);
+ lbxFolders.Items.Refresh();
+ }
}
else
{
@@ -82,5 +87,46 @@ namespace Wox.Plugin.Folder
lbxFolders.Items.Refresh();
}
+
+ private void lbxFolders_Drop(object sender, System.Windows.DragEventArgs e)
+ {
+ string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);
+
+ if (files != null && files.Count() > 0)
+ {
+ if (FolderStorage.Instance.FolderLinks == null)
+ {
+ FolderStorage.Instance.FolderLinks = new List();
+ }
+
+ foreach (string s in files)
+ {
+ if (System.IO.Directory.Exists(s) == true)
+ {
+ var newFolder = new FolderLink()
+ {
+ Path = s
+ };
+
+ FolderStorage.Instance.FolderLinks.Add(newFolder);
+ FolderStorage.Instance.Save();
+ }
+
+ lbxFolders.Items.Refresh();
+ }
+ }
+ }
+
+ private void lbxFolders_DragEnter(object sender, System.Windows.DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
+ {
+ e.Effects = System.Windows.DragDropEffects.Link;
+ }
+ else
+ {
+ e.Effects = System.Windows.DragDropEffects.None;
+ }
+ }
}
}
diff --git a/Plugins/Wox.Plugin.Folder/Languages/en.xaml b/Plugins/Wox.Plugin.Folder/Languages/en.xaml
index 7ad2760390..f9bbd6b3b9 100644
--- a/Plugins/Wox.Plugin.Folder/Languages/en.xaml
+++ b/Plugins/Wox.Plugin.Folder/Languages/en.xaml
@@ -7,5 +7,6 @@
Add
Folder Path
Please select a folder link
+ Are your sure to delete {0}?
\ No newline at end of file
diff --git a/Plugins/Wox.Plugin.Folder/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.Folder/Languages/zh-cn.xaml
index 9f1ccabe99..559b9f4906 100644
--- a/Plugins/Wox.Plugin.Folder/Languages/zh-cn.xaml
+++ b/Plugins/Wox.Plugin.Folder/Languages/zh-cn.xaml
@@ -7,5 +7,6 @@
添加
文件夹路径
请选择一个文件夹
-
+ 你确定要删除{0}吗?
+
\ No newline at end of file
diff --git a/Plugins/Wox.Plugin.Folder/Languages/zh-tw.xaml b/Plugins/Wox.Plugin.Folder/Languages/zh-tw.xaml
index ddc0809a64..27ac719140 100644
--- a/Plugins/Wox.Plugin.Folder/Languages/zh-tw.xaml
+++ b/Plugins/Wox.Plugin.Folder/Languages/zh-tw.xaml
@@ -7,5 +7,6 @@
添加
文件夾路徑
請選擇一個文件夾
+ 你確認要刪除{0}嗎?
\ No newline at end of file
diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml
index 3b268f5755..18b6b9f843 100644
--- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml
+++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml
@@ -16,7 +16,9 @@
-
+
diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
index 42be6196b4..3037997dfa 100644
--- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
+++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
@@ -106,5 +106,41 @@ namespace Wox.Plugin.Program
ProgramSuffixes p = new ProgramSuffixes(context);
p.ShowDialog();
}
+
+ private void programSourceView_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(DataFormats.FileDrop))
+ {
+ e.Effects = DragDropEffects.Link;
+ }
+ else
+ {
+ e.Effects = DragDropEffects.None;
+ }
+ }
+
+ private void programSourceView_Drop(object sender, DragEventArgs e)
+ {
+ string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
+
+ if (files != null && files.Length > 0)
+ {
+ foreach (string s in files)
+ {
+ if (System.IO.Directory.Exists(s) == true)
+ {
+ ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
+ {
+ Location = s,
+ Type = "FileSystemProgramSource",
+ Enabled = true
+ });
+
+ ProgramStorage.Instance.Save();
+ ReIndexing();
+ }
+ }
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Wox/ImageLoader/ImageLoader.cs b/Wox/ImageLoader/ImageLoader.cs
index c10e880c92..474b47edff 100644
--- a/Wox/ImageLoader/ImageLoader.cs
+++ b/Wox/ImageLoader/ImageLoader.cs
@@ -37,6 +37,8 @@ namespace Wox.ImageLoader
private static ImageSource GetIcon(string fileName)
{
+ if (System.IO.File.Exists(fileName) == false) return null;
+
Icon icon = GetFileIcon(fileName);
if (icon == null) icon = Icon.ExtractAssociatedIcon(fileName);