mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 12:46:47 +02:00
@@ -12,7 +12,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Google",
|
Title = "Google",
|
||||||
ActionKeyword = "g",
|
ActionKeyword = "g",
|
||||||
IconPath = "Images\\google.png",
|
IconPath = "google.png",
|
||||||
Url = "https://www.google.com/search?q={q}",
|
Url = "https://www.google.com/search?q={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -20,7 +20,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Wikipedia",
|
Title = "Wikipedia",
|
||||||
ActionKeyword = "wiki",
|
ActionKeyword = "wiki",
|
||||||
IconPath = "Images\\wiki.png",
|
IconPath = "wiki.png",
|
||||||
Url = "http://en.wikipedia.org/wiki/{q}",
|
Url = "http://en.wikipedia.org/wiki/{q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -28,7 +28,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "FindIcon",
|
Title = "FindIcon",
|
||||||
ActionKeyword = "findicon",
|
ActionKeyword = "findicon",
|
||||||
IconPath = "Images\\pictures.png",
|
IconPath = "pictures.png",
|
||||||
Url = "http://findicons.com/search/{q}",
|
Url = "http://findicons.com/search/{q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -36,7 +36,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Facebook",
|
Title = "Facebook",
|
||||||
ActionKeyword = "facebook",
|
ActionKeyword = "facebook",
|
||||||
IconPath = "Images\\facebook.png",
|
IconPath = "facebook.png",
|
||||||
Url = "http://www.facebook.com/search/?q={q}",
|
Url = "http://www.facebook.com/search/?q={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -44,7 +44,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Twitter",
|
Title = "Twitter",
|
||||||
ActionKeyword = "twitter",
|
ActionKeyword = "twitter",
|
||||||
IconPath = "Images\\twitter.png",
|
IconPath = "twitter.png",
|
||||||
Url = "http://twitter.com/search?q={q}",
|
Url = "http://twitter.com/search?q={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -52,7 +52,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Google Maps",
|
Title = "Google Maps",
|
||||||
ActionKeyword = "maps",
|
ActionKeyword = "maps",
|
||||||
IconPath = "Images\\google_maps.png",
|
IconPath = "google_maps.png",
|
||||||
Url = "http://maps.google.com/maps?q={q}",
|
Url = "http://maps.google.com/maps?q={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -60,7 +60,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Google Translate",
|
Title = "Google Translate",
|
||||||
ActionKeyword = "translate",
|
ActionKeyword = "translate",
|
||||||
IconPath = "Images\\google_translate.png",
|
IconPath = "google_translate.png",
|
||||||
Url = "http://translate.google.com/#auto|en|{q}",
|
Url = "http://translate.google.com/#auto|en|{q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -68,7 +68,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Duckduckgo",
|
Title = "Duckduckgo",
|
||||||
ActionKeyword = "duckduckgo",
|
ActionKeyword = "duckduckgo",
|
||||||
IconPath = "Images\\duckduckgo.png",
|
IconPath = "duckduckgo.png",
|
||||||
Url = "https://duckduckgo.com/?q={q}",
|
Url = "https://duckduckgo.com/?q={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -76,7 +76,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Github",
|
Title = "Github",
|
||||||
ActionKeyword = "github",
|
ActionKeyword = "github",
|
||||||
IconPath = "Images\\github.png",
|
IconPath = "github.png",
|
||||||
Url = "https://github.com/search?q={q}",
|
Url = "https://github.com/search?q={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -84,7 +84,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Github Gist",
|
Title = "Github Gist",
|
||||||
ActionKeyword = "gist",
|
ActionKeyword = "gist",
|
||||||
IconPath = "Images\\gist.png",
|
IconPath = "gist.png",
|
||||||
Url = "https://gist.github.com/search?q={q}",
|
Url = "https://gist.github.com/search?q={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -92,7 +92,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Gmail",
|
Title = "Gmail",
|
||||||
ActionKeyword = "gmail",
|
ActionKeyword = "gmail",
|
||||||
IconPath = "Images\\gmail.png",
|
IconPath = "gmail.png",
|
||||||
Url = "https://mail.google.com/mail/ca/u/0/#apps/{q}",
|
Url = "https://mail.google.com/mail/ca/u/0/#apps/{q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -100,7 +100,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Google Drive",
|
Title = "Google Drive",
|
||||||
ActionKeyword = "drive",
|
ActionKeyword = "drive",
|
||||||
IconPath = "Images\\google_drive.png",
|
IconPath = "google_drive.png",
|
||||||
Url = "http://drive.google.com/?hl=en&tab=bo#search/{q}",
|
Url = "http://drive.google.com/?hl=en&tab=bo#search/{q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -108,7 +108,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Wolframalpha",
|
Title = "Wolframalpha",
|
||||||
ActionKeyword = "wolframalpha",
|
ActionKeyword = "wolframalpha",
|
||||||
IconPath = "Images\\wolframalpha.png",
|
IconPath = "wolframalpha.png",
|
||||||
Url = "http://www.wolframalpha.com/input/?i={q}",
|
Url = "http://www.wolframalpha.com/input/?i={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -116,7 +116,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Stackoverflow",
|
Title = "Stackoverflow",
|
||||||
ActionKeyword = "stackoverflow",
|
ActionKeyword = "stackoverflow",
|
||||||
IconPath = "Images\\stackoverflow.png",
|
IconPath = "stackoverflow.png",
|
||||||
Url = "http://stackoverflow.com/search?q={q}",
|
Url = "http://stackoverflow.com/search?q={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -124,7 +124,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "I'm Feeling Lucky",
|
Title = "I'm Feeling Lucky",
|
||||||
ActionKeyword = "lucky",
|
ActionKeyword = "lucky",
|
||||||
IconPath = "Images\\google.png",
|
IconPath = "google.png",
|
||||||
Url = "http://google.com/search?q={q}&btnI=I",
|
Url = "http://google.com/search?q={q}&btnI=I",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -132,7 +132,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Google Image",
|
Title = "Google Image",
|
||||||
ActionKeyword = "image",
|
ActionKeyword = "image",
|
||||||
IconPath = "Images\\google.png",
|
IconPath = "google.png",
|
||||||
Url = "https://www.google.com/search?q={q}&tbm=isch",
|
Url = "https://www.google.com/search?q={q}&tbm=isch",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -140,7 +140,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Youtube",
|
Title = "Youtube",
|
||||||
ActionKeyword = "youtube",
|
ActionKeyword = "youtube",
|
||||||
IconPath = "Images\\youtube.png",
|
IconPath = "youtube.png",
|
||||||
Url = "http://www.youtube.com/results?search_query={q}",
|
Url = "http://www.youtube.com/results?search_query={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -148,7 +148,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Bing",
|
Title = "Bing",
|
||||||
ActionKeyword = "bing",
|
ActionKeyword = "bing",
|
||||||
IconPath = "Images\\bing.png",
|
IconPath = "bing.png",
|
||||||
Url = "https://www.bing.com/search?q={q}",
|
Url = "https://www.bing.com/search?q={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
},
|
},
|
||||||
@@ -156,7 +156,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
Title = "Yahoo",
|
Title = "Yahoo",
|
||||||
ActionKeyword = "yahoo",
|
ActionKeyword = "yahoo",
|
||||||
IconPath = "Images\\yahoo.png",
|
IconPath = "yahoo.png",
|
||||||
Url = "http://www.search.yahoo.com/search?p={q}",
|
Url = "http://www.search.yahoo.com/search?p={q}",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,27 +18,25 @@
|
|||||||
<ColumnDefinition></ColumnDefinition>
|
<ColumnDefinition></ColumnDefinition>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_title}"></TextBlock>
|
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_title}"></TextBlock>
|
||||||
<TextBox x:Name="tbTitle" Margin="10" Grid.Row="0" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
|
<TextBox x:Name="WebSearchName" Margin="10" Grid.Row="0" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
|
||||||
|
|
||||||
<TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_url}"></TextBlock>
|
<TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_url}"></TextBlock>
|
||||||
<TextBox x:Name="tbUrl" Margin="10" Grid.Row="1" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
|
<TextBox x:Name="Url" Margin="10" Grid.Row="1" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
|
||||||
|
|
||||||
<TextBlock Margin="10" FontSize="14" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_action_keyword}"></TextBlock>
|
<TextBlock Margin="10" FontSize="14" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_action_keyword}"></TextBlock>
|
||||||
<TextBox x:Name="tbActionword" Margin="10" Grid.Row="2" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
|
<TextBox x:Name="Actionword" Margin="10" Grid.Row="2" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
|
||||||
|
|
||||||
<TextBlock Margin="10" FontSize="14" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_enable}"></TextBlock>
|
<TextBlock Margin="10" FontSize="14" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_enable}"></TextBlock>
|
||||||
<CheckBox x:Name="cbEnable" IsChecked="True" Margin="10" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"></CheckBox>
|
<CheckBox x:Name="EnableCheckBox" IsChecked="True" Margin="10" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"></CheckBox>
|
||||||
|
|
||||||
<TextBlock Margin="10" FontSize="14" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_icon}"></TextBlock>
|
<TextBlock Margin="10" FontSize="14" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_icon}"></TextBlock>
|
||||||
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="1" Margin="10">
|
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="1" Margin="10">
|
||||||
<Image x:Name="imgIcon" Width="24" Height="24" Margin="0 0 10 0" />
|
<Image x:Name="WebSearchIcon" Width="24" Height="24" Margin="0 0 10 0" />
|
||||||
<Button x:Name="btnSelectIcon" Height="24" Click="BtnSelectIcon_OnClick" Content="{DynamicResource wox_plugin_websearch_select_icon}"></Button>
|
<Button x:Name="SelectIconButton" Height="24" Click="SelectIconButtonOnClick" Content="{DynamicResource wox_plugin_websearch_select_icon}"></Button>
|
||||||
<TextBlock x:Name="tbIconPath" Visibility="Hidden"></TextBlock>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="5" Grid.Column="1">
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="5" Grid.Column="1">
|
||||||
<Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 10 0" Width="80" Height="25" Content="{DynamicResource wox_plugin_websearch_cancel}"></Button>
|
<Button x:Name="CancelButton" Click="CancelButtonOnClick" Margin="10 0 10 0" Width="80" Height="25" Content="{DynamicResource wox_plugin_websearch_cancel}"/>
|
||||||
<Button x:Name="btnConfirm" Margin="10 0 10 0" Width="80" Height="25" Click="btnConfirm_OnClick">
|
<Button x:Name="ConfirmButton" Margin="10 0 10 0" Width="80" Height="25" Click="ConfirmButtonOnClick" Content="{DynamicResource wox_plugin_websearch_add}"/>
|
||||||
<TextBlock x:Name="lblAdd" Text="{DynamicResource wox_plugin_websearch_add}"></TextBlock></Button>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -2,37 +2,41 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Infrastructure.Exception;
|
using Wox.Infrastructure.Exception;
|
||||||
|
using Wox.Infrastructure.Image;
|
||||||
|
|
||||||
namespace Wox.Plugin.WebSearch
|
namespace Wox.Plugin.WebSearch
|
||||||
{
|
{
|
||||||
public partial class WebSearchSetting : Window
|
public partial class WebSearchSetting : Window
|
||||||
{
|
{
|
||||||
private const string _imageDirectoryName = "Images";
|
private const string ImageDirectory = "Images";
|
||||||
private string _pluginDirectory = WoxDirectroy.Executable;
|
private const string DefaultIcon = "web_search.png";
|
||||||
|
private readonly string _pluginDirectory;
|
||||||
private readonly WebSearchesSetting _settingWindow;
|
private readonly WebSearchesSetting _settingWindow;
|
||||||
private bool _isUpdate;
|
private bool _isUpdate;
|
||||||
private WebSearch _updateWebSearch;
|
private WebSearch _webSearch;
|
||||||
private readonly PluginInitContext _context;
|
private readonly PluginInitContext _context;
|
||||||
private readonly WebSearchPlugin _plugin;
|
private readonly WebSearchPlugin _plugin;
|
||||||
private Settings _settings;
|
private readonly Settings _settings;
|
||||||
|
|
||||||
public WebSearchSetting(WebSearchesSetting settingWidow, Settings settings)
|
public WebSearchSetting(WebSearchesSetting settingWidow, Settings settings)
|
||||||
{
|
{
|
||||||
|
InitializeComponent();
|
||||||
_plugin = settingWidow.Plugin;
|
_plugin = settingWidow.Plugin;
|
||||||
_context = settingWidow.Context;
|
_context = settingWidow.Context;
|
||||||
_settingWindow = settingWidow;
|
_settingWindow = settingWidow;
|
||||||
InitializeComponent();
|
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
|
_pluginDirectory = _settingWindow.Context.CurrentPluginMetadata.PluginDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateItem(WebSearch webSearch)
|
public void UpdateItem(WebSearch webSearch)
|
||||||
{
|
{
|
||||||
_updateWebSearch = _settings.WebSearches.FirstOrDefault(o => o == webSearch);
|
_webSearch = _settings.WebSearches.FirstOrDefault(o => o == webSearch);
|
||||||
if (_updateWebSearch == null || string.IsNullOrEmpty(_updateWebSearch.Url))
|
if (_webSearch == null || string.IsNullOrEmpty(_webSearch.Url))
|
||||||
{
|
{
|
||||||
|
|
||||||
string warning = _context.API.GetTranslation("wox_plugin_websearch_invalid_web_search");
|
string warning = _context.API.GetTranslation("wox_plugin_websearch_invalid_web_search");
|
||||||
@@ -42,31 +46,61 @@ namespace Wox.Plugin.WebSearch
|
|||||||
}
|
}
|
||||||
|
|
||||||
_isUpdate = true;
|
_isUpdate = true;
|
||||||
lblAdd.Text = "Update";
|
ConfirmButton.Content = "Update";
|
||||||
tbIconPath.Text = webSearch.IconPath;
|
WebSearchIcon.Source = LoadIcon(webSearch.IconPath);
|
||||||
ShowIcon(webSearch.IconPath);
|
EnableCheckBox.IsChecked = webSearch.Enabled;
|
||||||
cbEnable.IsChecked = webSearch.Enabled;
|
WebSearchName.Text = webSearch.Title;
|
||||||
tbTitle.Text = webSearch.Title;
|
Url.Text = webSearch.Url;
|
||||||
tbUrl.Text = webSearch.Url;
|
Actionword.Text = webSearch.ActionKeyword;
|
||||||
tbActionword.Text = webSearch.ActionKeyword;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowIcon(string path)
|
public void AddItem(WebSearch websearch)
|
||||||
{
|
{
|
||||||
imgIcon.Source = new BitmapImage(new Uri(Path.Combine(_pluginDirectory, path), UriKind.Absolute));
|
_webSearch = websearch;
|
||||||
|
if (string.IsNullOrEmpty(_webSearch.IconPath))
|
||||||
|
{
|
||||||
|
_webSearch.IconPath = DefaultIcon;
|
||||||
|
WebSearchIcon.Source = LoadIcon(_webSearch.IconPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
|
private void CancelButtonOnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ImageSource LoadIcon(string path)
|
||||||
|
{
|
||||||
|
if (path != null)
|
||||||
|
{
|
||||||
|
var releativePath = Path.Combine(_pluginDirectory, ImageDirectory, Path.GetFileName(path));
|
||||||
|
if (File.Exists(releativePath))
|
||||||
|
{
|
||||||
|
_webSearch.IconPath = path;
|
||||||
|
var source = ImageLoader.Load(releativePath);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_webSearch.IconPath = path;
|
||||||
|
var source = ImageLoader.Load(path);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var source = ImageLoader.Load(Path.Combine(_pluginDirectory, ImageDirectory, DefaultIcon));
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Confirm button for both add and update
|
/// Confirm button for both add and update
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void btnConfirm_OnClick(object sender, RoutedEventArgs e)
|
private void ConfirmButtonOnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
string title = tbTitle.Text;
|
string title = WebSearchName.Text;
|
||||||
if (string.IsNullOrEmpty(title))
|
if (string.IsNullOrEmpty(title))
|
||||||
{
|
{
|
||||||
string warning = _context.API.GetTranslation("wox_plugin_websearch_input_title");
|
string warning = _context.API.GetTranslation("wox_plugin_websearch_input_title");
|
||||||
@@ -74,7 +108,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string url = tbUrl.Text;
|
string url = Url.Text;
|
||||||
if (string.IsNullOrEmpty(url))
|
if (string.IsNullOrEmpty(url))
|
||||||
{
|
{
|
||||||
string warning = _context.API.GetTranslation("wox_plugin_websearch_input_url");
|
string warning = _context.API.GetTranslation("wox_plugin_websearch_input_url");
|
||||||
@@ -82,24 +116,19 @@ namespace Wox.Plugin.WebSearch
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string newActionKeyword = tbActionword.Text.Trim();
|
string newActionKeyword = Actionword.Text.Trim();
|
||||||
|
|
||||||
if (_isUpdate)
|
if (_isUpdate)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_plugin.NotifyActionKeywordsUpdated(_updateWebSearch.ActionKeyword, newActionKeyword);
|
_plugin.NotifyActionKeywordsUpdated(_webSearch.ActionKeyword, newActionKeyword);
|
||||||
}
|
}
|
||||||
catch (WoxPluginException exception)
|
catch (WoxPluginException exception)
|
||||||
{
|
{
|
||||||
MessageBox.Show(exception.Message);
|
MessageBox.Show(exception.Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateWebSearch.ActionKeyword = newActionKeyword;
|
|
||||||
_updateWebSearch.IconPath = tbIconPath.Text;
|
|
||||||
_updateWebSearch.Enabled = cbEnable.IsChecked ?? false;
|
|
||||||
_updateWebSearch.Url = url;
|
|
||||||
_updateWebSearch.Title = title;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -112,42 +141,34 @@ namespace Wox.Plugin.WebSearch
|
|||||||
MessageBox.Show(exception.Message);
|
MessageBox.Show(exception.Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_settings.WebSearches.Add(new WebSearch
|
|
||||||
{
|
_settings.WebSearches.Add(_webSearch);
|
||||||
ActionKeyword = newActionKeyword,
|
|
||||||
Enabled = cbEnable.IsChecked ?? false,
|
|
||||||
IconPath = tbIconPath.Text,
|
|
||||||
Url = url,
|
|
||||||
Title = title
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_webSearch.ActionKeyword = newActionKeyword;
|
||||||
|
_webSearch.Enabled = EnableCheckBox.IsChecked ?? false;
|
||||||
|
_webSearch.Url = url;
|
||||||
|
_webSearch.Title = title;
|
||||||
|
|
||||||
_settingWindow.ReloadWebSearchView();
|
_settingWindow.ReloadWebSearchView();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnSelectIcon_OnClick(object sender, RoutedEventArgs e)
|
private void SelectIconButtonOnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(_pluginDirectory))
|
|
||||||
{
|
|
||||||
_pluginDirectory =
|
|
||||||
Path.GetDirectoryName(WoxDirectroy.Executable);
|
|
||||||
}
|
|
||||||
|
|
||||||
var dlg = new OpenFileDialog
|
var dlg = new OpenFileDialog
|
||||||
{
|
{
|
||||||
InitialDirectory = Path.Combine(_pluginDirectory, _imageDirectoryName),
|
InitialDirectory = Path.Combine(_pluginDirectory, ImageDirectory),
|
||||||
Filter = "Image files (*.jpg, *.jpeg, *.gif, *.png, *.bmp) |*.jpg; *.jpeg; *.gif; *.png; *.bmp"
|
Filter = "Image files (*.jpg, *.jpeg, *.gif, *.png, *.bmp) |*.jpg; *.jpeg; *.gif; *.png; *.bmp"
|
||||||
};
|
};
|
||||||
|
|
||||||
bool? result = dlg.ShowDialog();
|
bool? result = dlg.ShowDialog();
|
||||||
if (result == true)
|
if (result != null && result == true)
|
||||||
{
|
{
|
||||||
string filename = dlg.FileName;
|
string fullpath = dlg.FileName;
|
||||||
if (filename != null)
|
if (fullpath != null)
|
||||||
{
|
{
|
||||||
tbIconPath.Text = Path.Combine(_imageDirectoryName, Path.GetFileName(filename));
|
WebSearchIcon.Source = LoadIcon(fullpath);
|
||||||
ShowIcon(tbIconPath.Text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,12 @@ namespace Wox.Plugin.WebSearch
|
|||||||
|
|
||||||
private void btnAddWebSearch_OnClick(object sender, RoutedEventArgs e)
|
private void btnAddWebSearch_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
WebSearchSetting webSearch = new WebSearchSetting(this, _settings);
|
var setting = new WebSearchSetting(this, _settings);
|
||||||
webSearch.ShowDialog();
|
var webSearch = new WebSearch();
|
||||||
|
|
||||||
|
|
||||||
|
setting.AddItem(webSearch);
|
||||||
|
setting.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnDeleteWebSearch_OnClick(object sender, RoutedEventArgs e)
|
private void btnDeleteWebSearch_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ namespace Wox.Core.Updater
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Error(e);
|
|
||||||
updManager.CleanUp();
|
updManager.CleanUp();
|
||||||
|
Log.Error(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ using Wox.Infrastructure.Storage;
|
|||||||
|
|
||||||
namespace Wox.Infrastructure.Image
|
namespace Wox.Infrastructure.Image
|
||||||
{
|
{
|
||||||
public class ImageLoader
|
public static class ImageLoader
|
||||||
{
|
{
|
||||||
private readonly ConcurrentDictionary<string, ImageSource> _imageSources = new ConcurrentDictionary<string, ImageSource>();
|
private static readonly ConcurrentDictionary<string, ImageSource> _imageSources = new ConcurrentDictionary<string, ImageSource>();
|
||||||
|
|
||||||
private readonly List<string> ImageExts = new List<string>
|
private static readonly List<string> ImageExts = new List<string>
|
||||||
{
|
{
|
||||||
".png",
|
".png",
|
||||||
".jpg",
|
".jpg",
|
||||||
@@ -28,7 +28,7 @@ namespace Wox.Infrastructure.Image
|
|||||||
".ico"
|
".ico"
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly List<string> SelfExts = new List<string>
|
private static readonly List<string> SelfExts = new List<string>
|
||||||
{
|
{
|
||||||
".exe",
|
".exe",
|
||||||
".lnk",
|
".lnk",
|
||||||
@@ -38,21 +38,21 @@ namespace Wox.Infrastructure.Image
|
|||||||
".appref-ms"
|
".appref-ms"
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly ImageCache _cache;
|
private static readonly ImageCache _cache;
|
||||||
private readonly BinaryStorage<ImageCache> _storage;
|
private static readonly BinaryStorage<ImageCache> _storage;
|
||||||
|
|
||||||
public ImageLoader()
|
static ImageLoader()
|
||||||
{
|
{
|
||||||
_storage = new BinaryStorage<ImageCache>();
|
_storage = new BinaryStorage<ImageCache>();
|
||||||
_cache = _storage.Load();
|
_cache = _storage.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
~ImageLoader()
|
public static void Save()
|
||||||
{
|
{
|
||||||
_storage.Save();
|
_storage.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageSource GetIcon(string fileName)
|
private static ImageSource GetIcon(string fileName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -69,7 +69,7 @@ namespace Wox.Infrastructure.Image
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PreloadImages()
|
public static void PreloadImages()
|
||||||
{
|
{
|
||||||
Stopwatch.Debug($"Preload {_cache.TopUsedImages.Count} images", () =>
|
Stopwatch.Debug($"Preload {_cache.TopUsedImages.Count} images", () =>
|
||||||
{
|
{
|
||||||
@@ -89,10 +89,15 @@ namespace Wox.Infrastructure.Image
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageSource Load(string path, bool addToCache = true)
|
public static ImageSource Load(string path, bool addToCache = true)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path)) return null;
|
|
||||||
ImageSource image = null;
|
ImageSource image = null;
|
||||||
|
if (string.IsNullOrEmpty(path))
|
||||||
|
{
|
||||||
|
path = Path.Combine(WoxDirectroy.Executable, "Images", "app.png");
|
||||||
|
image = new BitmapImage(new Uri(path));
|
||||||
|
return image;
|
||||||
|
}
|
||||||
Stopwatch.Debug($"Loading image path: {path}", () =>
|
Stopwatch.Debug($"Loading image path: {path}", () =>
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -152,7 +157,7 @@ namespace Wox.Infrastructure.Image
|
|||||||
}
|
}
|
||||||
|
|
||||||
// http://blogs.msdn.com/b/oldnewthing/archive/2011/01/27/10120844.aspx
|
// http://blogs.msdn.com/b/oldnewthing/archive/2011/01/27/10120844.aspx
|
||||||
private Icon GetFileIcon(string name)
|
private static Icon GetFileIcon(string name)
|
||||||
{
|
{
|
||||||
SHFILEINFO shfi = new SHFILEINFO();
|
SHFILEINFO shfi = new SHFILEINFO();
|
||||||
uint flags = SHGFI_SYSICONINDEX;
|
uint flags = SHGFI_SYSICONINDEX;
|
||||||
|
|||||||
@@ -73,13 +73,13 @@ namespace Wox.Infrastructure.Storage
|
|||||||
}
|
}
|
||||||
catch (SerializationException e)
|
catch (SerializationException e)
|
||||||
{
|
{
|
||||||
Log.Error(e);
|
|
||||||
LoadDefault();
|
LoadDefault();
|
||||||
|
Log.Error(e);
|
||||||
}
|
}
|
||||||
catch (InvalidCastException e)
|
catch (InvalidCastException e)
|
||||||
{
|
{
|
||||||
Log.Error(e);
|
|
||||||
LoadDefault();
|
LoadDefault();
|
||||||
|
Log.Error(e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
private const string Unique = "Wox_Unique_Application_Mutex";
|
private const string Unique = "Wox_Unique_Application_Mutex";
|
||||||
public static MainWindow Window { get; private set; }
|
public static MainWindow Window { get; private set; }
|
||||||
public static ImageLoader ImageLoader;
|
|
||||||
public static PublicAPIInstance API { get; private set; }
|
public static PublicAPIInstance API { get; private set; }
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
@@ -44,7 +43,6 @@ namespace Wox
|
|||||||
WoxDirectroy.Executable = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString();
|
WoxDirectroy.Executable = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString();
|
||||||
RegisterUnhandledException();
|
RegisterUnhandledException();
|
||||||
|
|
||||||
ImageLoader = new ImageLoader();
|
|
||||||
Task.Factory.StartNew(ImageLoader.PreloadImages);
|
Task.Factory.StartNew(ImageLoader.PreloadImages);
|
||||||
PluginManager.Initialize();
|
PluginManager.Initialize();
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
using Wox.Infrastructure.Image;
|
||||||
|
|
||||||
namespace Wox.Converters
|
namespace Wox.Converters
|
||||||
{
|
{
|
||||||
@@ -13,7 +14,7 @@ namespace Wox.Converters
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var image = App.ImageLoader.Load(value.ToString());
|
var image = ImageLoader.Load(value.ToString());
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Windows.Media.Animation;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
|
using Wox.Infrastructure.Image;
|
||||||
|
|
||||||
namespace Wox
|
namespace Wox
|
||||||
{
|
{
|
||||||
@@ -37,7 +38,7 @@ namespace Wox
|
|||||||
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
|
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
|
||||||
fadeOutStoryboard.Children.Add(fadeOutAnimation);
|
fadeOutStoryboard.Children.Add(fadeOutAnimation);
|
||||||
|
|
||||||
imgClose.Source = App.ImageLoader.Load(Path.Combine(WoxDirectroy.Executable, "Images\\close.png"));
|
imgClose.Source = ImageLoader.Load(Path.Combine(WoxDirectroy.Executable, "Images\\close.png"));
|
||||||
imgClose.MouseUp += imgClose_MouseUp;
|
imgClose.MouseUp += imgClose_MouseUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,10 +66,10 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
if (!File.Exists(iconPath))
|
if (!File.Exists(iconPath))
|
||||||
{
|
{
|
||||||
imgIco.Source = App.ImageLoader.Load(Path.Combine(WoxDirectroy.Executable, "Images\\app.png"));
|
imgIco.Source = ImageLoader.Load(Path.Combine(WoxDirectroy.Executable, "Images\\app.png"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
imgIco.Source = App.ImageLoader.Load(iconPath);
|
imgIco.Source = ImageLoader.Load(iconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ using Wox.Core.Updater;
|
|||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
using Wox.Infrastructure.Hotkey;
|
using Wox.Infrastructure.Hotkey;
|
||||||
|
using Wox.Infrastructure.Image;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using Wox.ViewModel;
|
using Wox.ViewModel;
|
||||||
using Application = System.Windows.Forms.Application;
|
using Application = System.Windows.Forms.Application;
|
||||||
@@ -550,7 +551,7 @@ namespace Wox
|
|||||||
pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " + pair.Metadata.Author;
|
pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " + pair.Metadata.Author;
|
||||||
pluginSubTitle.Text = pair.Metadata.Description;
|
pluginSubTitle.Text = pair.Metadata.Description;
|
||||||
pluginId = pair.Metadata.ID;
|
pluginId = pair.Metadata.ID;
|
||||||
pluginIcon.Source = App.ImageLoader.Load(pair.Metadata.FullIcoPath);
|
pluginIcon.Source = ImageLoader.Load(pair.Metadata.FullIcoPath);
|
||||||
|
|
||||||
var customizedPluginConfig = _settings.PluginSettings[pluginId];
|
var customizedPluginConfig = _settings.PluginSettings[pluginId];
|
||||||
cbDisablePlugin.IsChecked = customizedPluginConfig != null && customizedPluginConfig.Disabled;
|
cbDisablePlugin.IsChecked = customizedPluginConfig != null && customizedPluginConfig.Disabled;
|
||||||
|
|||||||
Reference in New Issue
Block a user