mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-15 03:59:15 +08:00
Merge pull request #232 from allanpk716/V1.2.0
1,fix ImageLoader GetIcon() trigger FileNotFoundException when file not ...
This commit is contained in:
commit
06a9478555
@ -10,8 +10,10 @@
|
|||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="50"/>
|
<RowDefinition Height="50"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ListView x:Name="lbxFolders" Grid.Row="0">
|
<ListView x:Name="lbxFolders" Grid.Row="0" AllowDrop="True"
|
||||||
<ListView.View>
|
Drop="lbxFolders_Drop"
|
||||||
|
DragEnter="lbxFolders_DragEnter">
|
||||||
|
<ListView.View>
|
||||||
<GridView>
|
<GridView>
|
||||||
<GridViewColumn Header="{DynamicResource wox_plugin_folder_folder_path}" Width="180">
|
<GridViewColumn Header="{DynamicResource wox_plugin_folder_folder_path}" Width="180">
|
||||||
<GridViewColumn.CellTemplate>
|
<GridViewColumn.CellTemplate>
|
||||||
|
@ -27,8 +27,13 @@ namespace Wox.Plugin.Folder
|
|||||||
var selectedFolder = lbxFolders.SelectedItem as FolderLink;
|
var selectedFolder = lbxFolders.SelectedItem as FolderLink;
|
||||||
if (selectedFolder != null)
|
if (selectedFolder != null)
|
||||||
{
|
{
|
||||||
FolderStorage.Instance.FolderLinks.Remove(selectedFolder);
|
string msg = string.Format(context.API.GetTranslation("wox_plugin_folder_delete_folder_link"), selectedFolder.Path);
|
||||||
lbxFolders.Items.Refresh();
|
|
||||||
|
if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
FolderStorage.Instance.FolderLinks.Remove(selectedFolder);
|
||||||
|
lbxFolders.Items.Refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -82,5 +87,46 @@ namespace Wox.Plugin.Folder
|
|||||||
|
|
||||||
lbxFolders.Items.Refresh();
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,6 @@
|
|||||||
<system:String x:Key="wox_plugin_folder_add">Add</system:String>
|
<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_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_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>
|
</ResourceDictionary>
|
@ -7,5 +7,6 @@
|
|||||||
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
|
<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_folder_path">文件夹路径</system:String>
|
||||||
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">请选择一个文件夹</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>
|
</ResourceDictionary>
|
@ -7,5 +7,6 @@
|
|||||||
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
|
<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_folder_path">文件夾路徑</system:String>
|
||||||
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">請選擇一個文件夾</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>
|
</ResourceDictionary>
|
@ -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" 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>
|
<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>
|
</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>
|
<ListView.View>
|
||||||
<GridView>
|
<GridView>
|
||||||
<GridViewColumn Header="{DynamicResource wox_plugin_program_location}" Width="400">
|
<GridViewColumn Header="{DynamicResource wox_plugin_program_location}" Width="400">
|
||||||
|
@ -106,5 +106,41 @@ namespace Wox.Plugin.Program
|
|||||||
ProgramSuffixes p = new ProgramSuffixes(context);
|
ProgramSuffixes p = new ProgramSuffixes(context);
|
||||||
p.ShowDialog();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -37,6 +37,8 @@ namespace Wox.ImageLoader
|
|||||||
|
|
||||||
private static ImageSource GetIcon(string fileName)
|
private static ImageSource GetIcon(string fileName)
|
||||||
{
|
{
|
||||||
|
if (System.IO.File.Exists(fileName) == false) return null;
|
||||||
|
|
||||||
Icon icon = GetFileIcon(fileName);
|
Icon icon = GetFileIcon(fileName);
|
||||||
if (icon == null) icon = Icon.ExtractAssociatedIcon(fileName);
|
if (icon == null) icon = Icon.ExtractAssociatedIcon(fileName);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user