Merge pull request #232 from allanpk716/V1.2.0

1,fix ImageLoader GetIcon() trigger FileNotFoundException when file not ...
This commit is contained in:
qianlifeng 2015-01-09 10:43:02 +08:00
commit 06a9478555
8 changed files with 97 additions and 6 deletions

View File

@ -10,7 +10,9 @@
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<ListView x:Name="lbxFolders" Grid.Row="0">
<ListView x:Name="lbxFolders" Grid.Row="0" AllowDrop="True"
Drop="lbxFolders_Drop"
DragEnter="lbxFolders_DragEnter">
<ListView.View>
<GridView>
<GridViewColumn Header="{DynamicResource wox_plugin_folder_folder_path}" Width="180">

View File

@ -26,10 +26,15 @@ namespace Wox.Plugin.Folder
{
var selectedFolder = lbxFolders.SelectedItem as FolderLink;
if (selectedFolder != null)
{
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
{
string warning = context.API.GetTranslation("wox_plugin_folder_select_folder_link_warning");
@ -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<FolderLink>();
}
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;
}
}
}
}

View File

@ -7,5 +7,6 @@
<system:String x:Key="wox_plugin_folder_add">Add</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">Folder Path</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">Please select a folder link</system:String>
<system:String x:Key="wox_plugin_folder_delete_folder_link">Are your sure to delete {0}?</system:String>
</ResourceDictionary>

View File

@ -7,5 +7,6 @@
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">文件夹路径</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">请选择一个文件夹</system:String>
<system:String x:Key="wox_plugin_folder_delete_folder_link">你确定要删除{0}吗?</system:String>
</ResourceDictionary>

View File

@ -7,5 +7,6 @@
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">文件夾路徑</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">請選擇一個文件夾</system:String>
<system:String x:Key="wox_plugin_folder_delete_folder_link">你確認要刪除{0}嗎?</system:String>
</ResourceDictionary>

View File

@ -16,7 +16,9 @@
<Button Height="30" HorizontalAlignment="Right" x:Name="btnProgramSuffixes" Width="130" Click="BtnProgramSuffixes_OnClick" Content="{DynamicResource wox_plugin_program_suffixes}"></Button>
<Button Height="30" HorizontalAlignment="Right" Margin="10 0 0 0" x:Name="btnReindex" Width="100" Click="btnReindex_Click" Content="{DynamicResource wox_plugin_program_reindex}"></Button>
</StackPanel>
<ListView x:Name="programSourceView" Grid.Row="1">
<ListView x:Name="programSourceView" Grid.Row="1" AllowDrop="True"
DragEnter="programSourceView_DragEnter"
Drop="programSourceView_Drop" >
<ListView.View>
<GridView>
<GridViewColumn Header="{DynamicResource wox_plugin_program_location}" Width="400">

View File

@ -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();
}
}
}
}
}
}

View File

@ -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);