mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 14:41:21 +08:00
Add browse more plugin and theme link to setting dialog.
This commit is contained in:
parent
088c3984d8
commit
5c373f0d25
@ -182,7 +182,7 @@ namespace Wox.Plugin.PluginManagement {
|
||||
private void UnInstalledPlugins(PluginMetadata plugin) {
|
||||
string content = string.Format("Do you want to uninstall following plugin?\r\n\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}", plugin.Name, plugin.Version, plugin.Author);
|
||||
if (MessageBox.Show(content, "Wox", MessageBoxButtons.YesNo) == DialogResult.Yes) {
|
||||
File.Create(Path.Combine(plugin.PluginDirecotry, "NeedDelete.txt")).Close();
|
||||
File.Create(Path.Combine(plugin.PluginDirectory, "NeedDelete.txt")).Close();
|
||||
MessageBox.Show("This plugin has been removed, restart Wox to take effect");
|
||||
}
|
||||
}
|
||||
@ -224,7 +224,7 @@ namespace Wox.Plugin.PluginManagement {
|
||||
try {
|
||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||
metadata.PluginType = PluginType.ThirdParty;
|
||||
metadata.PluginDirecotry = pluginDirectory;
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
}
|
||||
catch (Exception) {
|
||||
string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
@ -14,6 +15,19 @@ namespace Wox.Plugin.SystemPlugins
|
||||
public virtual string Description { get { return "System workflow"; } }
|
||||
public virtual string IcoPath { get { return null; } }
|
||||
|
||||
public string FullIcoPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IcoPath.StartsWith("data:"))
|
||||
{
|
||||
return IcoPath;
|
||||
}
|
||||
|
||||
return Path.Combine(PluginDirectory, IcoPath);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract List<Result> QueryInternal(Query query);
|
||||
|
||||
protected abstract void InitInternal(PluginInitContext context);
|
||||
|
@ -81,7 +81,7 @@ namespace Wox.Plugin.SystemPlugins
|
||||
IcoPath = "Images\\app.png",
|
||||
Action = (c) =>
|
||||
{
|
||||
context.CloseApp();
|
||||
context.API.CloseApp();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -99,7 +99,7 @@ namespace Wox.Plugin.SystemPlugins
|
||||
Info.CreateNoWindow = true;
|
||||
Info.FileName = "cmd.exe";
|
||||
Process.Start(Info);
|
||||
context.CloseApp();
|
||||
context.API.CloseApp();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -111,7 +111,7 @@ namespace Wox.Plugin.SystemPlugins
|
||||
IcoPath = "Images\\app.png",
|
||||
Action = (c) =>
|
||||
{
|
||||
context.OpenSettingDialog();
|
||||
context.API.OpenSettingDialog();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -31,14 +31,27 @@ namespace Wox.Plugin
|
||||
|
||||
public string ExecuteFilePath
|
||||
{
|
||||
get { return Path.Combine(PluginDirecotry, ExecuteFileName); }
|
||||
get { return Path.Combine(PluginDirectory, ExecuteFileName); }
|
||||
}
|
||||
|
||||
public string ExecuteFileName { get; set; }
|
||||
public string PluginDirecotry { get; set; }
|
||||
public string PluginDirectory { get; set; }
|
||||
public string ActionKeyword { get; set; }
|
||||
public PluginType PluginType { get; set; }
|
||||
|
||||
public string IcoPath { get; set; }
|
||||
|
||||
public string FullIcoPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IcoPath.StartsWith("data:"))
|
||||
{
|
||||
return IcoPath;
|
||||
}
|
||||
|
||||
return Path.Combine(PluginDirectory, IcoPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,17 +13,12 @@ namespace Wox.Converters
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null || value == DependencyProperty.UnsetValue) return null;
|
||||
|
||||
string fullPath = value.ToString();
|
||||
|
||||
if (fullPath.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
|
||||
if (value == null || value == DependencyProperty.UnsetValue)
|
||||
{
|
||||
return new BitmapImage(new Uri(fullPath));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return ImageLoader.Load(fullPath);
|
||||
return ImageLoader.Load(value.ToString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
|
@ -55,28 +55,28 @@ namespace Wox.Helper
|
||||
|
||||
public static ImageSource Load(string path)
|
||||
{
|
||||
ImageSource img = null;
|
||||
if (path == null) return null;
|
||||
if (string.IsNullOrEmpty(path)) return null;
|
||||
if (imageCache.ContainsKey(path))
|
||||
{
|
||||
return imageCache[path];
|
||||
}
|
||||
|
||||
ImageSource img = null;
|
||||
string ext = Path.GetExtension(path).ToLower();
|
||||
string resolvedPath = string.Empty;
|
||||
if (!string.IsNullOrEmpty(path) && path.Contains(":\\") && File.Exists(path))
|
||||
|
||||
if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
resolvedPath = path;
|
||||
img = new BitmapImage(new Uri(path));
|
||||
}
|
||||
else if (selfExts.Contains(ext))
|
||||
{
|
||||
img = GetIcon(path);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(path) && imageExts.Contains(ext) && File.Exists(path))
|
||||
{
|
||||
img = new BitmapImage(new Uri(path));
|
||||
}
|
||||
|
||||
if (selfExts.Contains(ext))
|
||||
{
|
||||
img = GetIcon(resolvedPath);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(resolvedPath) && imageExts.Contains(ext) && File.Exists(resolvedPath))
|
||||
{
|
||||
img = new BitmapImage(new Uri(resolvedPath));
|
||||
}
|
||||
|
||||
if (img != null)
|
||||
{
|
||||
|
@ -60,9 +60,9 @@ namespace Wox.Helper
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
if (existingPlugin != null && Directory.Exists(existingPlugin.Metadata.PluginDirecotry))
|
||||
if (existingPlugin != null && Directory.Exists(existingPlugin.Metadata.PluginDirectory))
|
||||
{
|
||||
File.Create(Path.Combine(existingPlugin.Metadata.PluginDirecotry, "NeedDelete.txt")).Close();
|
||||
File.Create(Path.Combine(existingPlugin.Metadata.PluginDirectory, "NeedDelete.txt")).Close();
|
||||
}
|
||||
|
||||
UnZip(path, newPluginPath, true);
|
||||
@ -106,7 +106,7 @@ namespace Wox.Helper
|
||||
{
|
||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||
metadata.PluginType = PluginType.ThirdParty;
|
||||
metadata.PluginDirecotry = pluginDirectory;
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ namespace Wox
|
||||
{
|
||||
results.ForEach(o =>
|
||||
{
|
||||
o.PluginDirectory = plugin.PluginDirecotry;
|
||||
o.PluginDirectory = plugin.PluginDirectory;
|
||||
o.OriginQuery = query;
|
||||
});
|
||||
OnUpdateResultView(results);
|
||||
|
@ -32,7 +32,7 @@ namespace Wox.PluginLoader {
|
||||
|
||||
var sys = pair.Plugin as BaseSystemPlugin;
|
||||
if (sys != null) {
|
||||
sys.PluginDirectory = metadata.PluginDirecotry;
|
||||
sys.PluginDirectory = metadata.PluginDirectory;
|
||||
}
|
||||
|
||||
plugins.Add(pair);
|
||||
|
@ -40,7 +40,7 @@ namespace Wox.PluginLoader {
|
||||
PluginType = PluginType.System,
|
||||
ActionKeyword = "*",
|
||||
ExecuteFileName = "Wox.Plugin.SystemPlugins.dll",
|
||||
PluginDirecotry = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
|
||||
PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
|
||||
});
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ namespace Wox.PluginLoader {
|
||||
try {
|
||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||
metadata.PluginType = PluginType.ThirdParty;
|
||||
metadata.PluginDirecotry = pluginDirectory;
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
}
|
||||
catch (Exception) {
|
||||
string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath);
|
||||
|
@ -12,12 +12,12 @@
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Height="600" Width="800">
|
||||
<Window.Resources>
|
||||
<converters:ImagePathConverter x:Key="ImagePathConverter"/>
|
||||
<ListBoxItem HorizontalContentAlignment="Stretch"
|
||||
IsEnabled="False"
|
||||
IsHitTestVisible="False" x:Key="FeatureBoxSeperator">
|
||||
<Separator Width="{Binding ElementName=lbPlugins, Path=ActualWidth}"/>
|
||||
</ListBoxItem>
|
||||
<converters:ImagePathConverter x:Key="ImageConverter" />
|
||||
</Window.Resources>
|
||||
<TabControl Height="auto" >
|
||||
<TabItem Header="General">
|
||||
@ -38,62 +38,49 @@
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListBox x:Name="lbPlugins" Grid.Column="0" Margin="0" SelectionChanged="lbPlugins_OnSelectionChanged" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.IsSharedSizeScope="True" >
|
||||
<ListBox.Resources>
|
||||
<DataTemplate DataType="{x:Type system:BaseSystemPlugin}">
|
||||
<Grid Height="36" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="32"></ColumnDefinition>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Width="32" Height="32" HorizontalAlignment="Left">
|
||||
<Image.Source>
|
||||
<MultiBinding Converter="{StaticResource ImagePathConverter}">
|
||||
<MultiBinding.Bindings>
|
||||
<Binding Path="IcoPath" />
|
||||
<Binding Path="PluginDirectory" />
|
||||
</MultiBinding.Bindings>
|
||||
</MultiBinding>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Grid Margin="3 0 3 0" Grid.Column="1" HorizontalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" ToolTip="{Binding Name}" x:Name="tbTitle" Text="{Binding Name}"></TextBlock>
|
||||
<TextBlock ToolTip="{Binding Description}" Visibility="{Binding Description, Converter={converters:StringNullOrEmptyToVisibilityConverter}}" Grid.Row="1" x:Name="tbSubTitle" Text="{Binding Description}" Opacity="0.5"></TextBlock>
|
||||
<DockPanel Grid.Column="0" >
|
||||
<TextBlock DockPanel.Dock="Top" Margin="6" HorizontalAlignment="Left" Cursor="Hand" MouseUp="tbMorePlugins_MouseUp" x:Name="tbMorePlugins" Foreground="Blue" Text="Browse more plugins"></TextBlock>
|
||||
<ListBox x:Name="lbPlugins" Margin="0" SelectionChanged="lbPlugins_OnSelectionChanged" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.IsSharedSizeScope="True" >
|
||||
<ListBox.Resources>
|
||||
<DataTemplate DataType="{x:Type system:BaseSystemPlugin}">
|
||||
<Grid Height="36" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="32"></ColumnDefinition>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Width="32" Height="32" HorizontalAlignment="Left" Source="{Binding FullIcoPath,Converter={StaticResource ImageConverter},IsAsync=True}">
|
||||
</Image>
|
||||
<Grid Margin="3 0 3 0" Grid.Column="1" HorizontalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" ToolTip="{Binding Name}" x:Name="tbTitle" Text="{Binding Name}"></TextBlock>
|
||||
<TextBlock ToolTip="{Binding Description}" Visibility="{Binding Description, Converter={converters:StringNullOrEmptyToVisibilityConverter}}" Grid.Row="1" x:Name="tbSubTitle" Text="{Binding Description}" Opacity="0.5"></TextBlock>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type woxPlugin:PluginPair}">
|
||||
<Grid Height="36" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="32"></ColumnDefinition>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Width="32" Height="32" HorizontalAlignment="Left">
|
||||
<Image.Source>
|
||||
<MultiBinding Converter="{StaticResource ImagePathConverter}">
|
||||
<MultiBinding.Bindings>
|
||||
<Binding Path="Metadata.IcoPath" />
|
||||
<Binding Path="Metadata.PluginDirecotry" />
|
||||
</MultiBinding.Bindings>
|
||||
</MultiBinding>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Grid Margin="3 0 3 0" Grid.Column="1" HorizontalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" ToolTip="{Binding Metadata.Name}" x:Name="tbTitle" Text="{Binding Metadata.Name}"></TextBlock>
|
||||
<TextBlock ToolTip="{Binding Metadata.Description}" Visibility="{Binding Metadata.Description, Converter={converters:StringNullOrEmptyToVisibilityConverter}}" Grid.Row="1" x:Name="tbSubTitle" Text="{Binding Metadata.Description}" Opacity="0.5"></TextBlock>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type woxPlugin:PluginPair}">
|
||||
<Grid Height="36" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="32"></ColumnDefinition>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Width="32" Height="32" HorizontalAlignment="Left" Source="{Binding Metadata.FullIcoPath,Converter={StaticResource ImageConverter},IsAsync=True}">
|
||||
</Image>
|
||||
<Grid Margin="3 0 3 0" Grid.Column="1" HorizontalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" ToolTip="{Binding Metadata.Name}" x:Name="tbTitle" Text="{Binding Metadata.Name}"></TextBlock>
|
||||
<TextBlock ToolTip="{Binding Metadata.Description}" Visibility="{Binding Metadata.Description, Converter={converters:StringNullOrEmptyToVisibilityConverter}}" Grid.Row="1" x:Name="tbSubTitle" Text="{Binding Metadata.Description}" Opacity="0.5"></TextBlock>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.Resources>
|
||||
</ListBox>
|
||||
</DataTemplate>
|
||||
</ListBox.Resources>
|
||||
</ListBox>
|
||||
</DockPanel>
|
||||
<Grid Margin="0" Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@ -140,7 +127,10 @@
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListBox x:Name="themeComboBox" Grid.Column="0" Margin="10" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="180"/>
|
||||
<DockPanel Grid.Column="0" >
|
||||
<TextBlock DockPanel.Dock="Top" Margin="6" HorizontalAlignment="Left" Cursor="Hand" MouseUp="tbMoreThemes_MouseUp" x:Name="tbMoreThemes" Foreground="Blue" Text="Browse more themes"></TextBlock>
|
||||
<ListBox x:Name="themeComboBox" Margin="0" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="180"/>
|
||||
</DockPanel>
|
||||
<Grid Margin="0" Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
|
@ -22,6 +22,7 @@ using Application = System.Windows.Forms.Application;
|
||||
using File = System.IO.File;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using System.Windows.Data;
|
||||
using Label = System.Windows.Forms.Label;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
@ -32,11 +33,6 @@ namespace Wox
|
||||
bool settingsLoaded = false;
|
||||
private Dictionary<ISettingProvider, Control> featureControls = new Dictionary<ISettingProvider, Control>();
|
||||
|
||||
public SettingWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public SettingWindow(MainWindow mainWindow)
|
||||
{
|
||||
this.MainWindow = mainWindow;
|
||||
@ -419,14 +415,7 @@ namespace Wox
|
||||
pluginSubTitle.Text = pair.Metadata.Description;
|
||||
pluginId = pair.Metadata.ID;
|
||||
SyntaxSugars.CallOrRescueDefault(
|
||||
() =>
|
||||
pluginIcon.Source = (ImageSource)new ImagePathConverter().Convert(
|
||||
new object[]
|
||||
{
|
||||
pair.Metadata.IcoPath,
|
||||
pair.Metadata.PluginDirecotry
|
||||
}, null, null,
|
||||
null));
|
||||
() => pluginIcon.Source = ImageLoader.Load(pair.Metadata.FullIcoPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -443,13 +432,7 @@ namespace Wox
|
||||
tbOpenPluginDirecoty.Visibility = Visibility.Collapsed;
|
||||
pluginActionKeywordTitle.Visibility = Visibility.Collapsed;
|
||||
pluginTitle.Cursor = Cursors.Arrow;
|
||||
SyntaxSugars.CallOrRescueDefault(
|
||||
() =>
|
||||
pluginIcon.Source = (ImageSource)new ImagePathConverter().Convert(new object[]
|
||||
{
|
||||
sys.IcoPath,
|
||||
sys.PluginDirectory
|
||||
}, null, null, null));
|
||||
SyntaxSugars.CallOrRescueDefault(() => pluginIcon.Source = ImageLoader.Load(sys.FullIcoPath));
|
||||
}
|
||||
}
|
||||
|
||||
@ -565,7 +548,7 @@ namespace Wox
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(pair.Metadata.PluginDirecotry);
|
||||
Process.Start(pair.Metadata.PluginDirectory);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
@ -573,5 +556,15 @@ namespace Wox
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tbMorePlugins_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Process.Start("http://www.getwox.com/plugin");
|
||||
}
|
||||
|
||||
private void tbMoreThemes_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Process.Start("http://www.getwox.com/theme");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user