mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Fixed Image Errors + Handing Bad ShellRun
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="Themes/Default.xaml"></ResourceDictionary>
|
<!--<ResourceDictionary Source="Themes/Default.xaml"></ResourceDictionary>-->
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
// First time app is launched
|
// First time app is launched
|
||||||
app = new App();
|
app = new App();
|
||||||
app.InitializeComponent();
|
//app.InitializeComponent();
|
||||||
app.Run();
|
app.Run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -455,6 +455,12 @@ namespace Wox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void SetTheme(string themeName) {
|
public void SetTheme(string themeName) {
|
||||||
|
//Uri uri = new Uri("Themes/Default.xaml", UriKind.Relative);
|
||||||
|
//System.Windows.Resources.StreamResourceInfo info = Application.GetResourceStream(uri);
|
||||||
|
//System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var dict = new ResourceDictionary {
|
var dict = new ResourceDictionary {
|
||||||
Source = new Uri(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Themes\\" + themeName + ".xaml"), UriKind.Absolute)
|
Source = new Uri(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Themes\\" + themeName + ".xaml"), UriKind.Absolute)
|
||||||
};
|
};
|
||||||
|
|||||||
111
Wox/Msg.xaml.cs
111
Wox/Msg.xaml.cs
@@ -15,70 +15,65 @@ using System.Windows.Media.Imaging;
|
|||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using Timer = System.Threading.Timer;
|
using Timer = System.Threading.Timer;
|
||||||
|
|
||||||
namespace Wox
|
namespace Wox {
|
||||||
{
|
public partial class Msg : Window {
|
||||||
public partial class Msg : Window
|
Storyboard fadeOutStoryboard = new Storyboard();
|
||||||
{
|
private bool closing = false;
|
||||||
Storyboard fadeOutStoryboard = new Storyboard();
|
|
||||||
private bool closing = false;
|
|
||||||
|
|
||||||
public Msg()
|
public Msg() {
|
||||||
{
|
InitializeComponent();
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
Left = Screen.PrimaryScreen.WorkingArea.Right - this.Width;
|
Left = Screen.PrimaryScreen.WorkingArea.Right - this.Width;
|
||||||
Top = Screen.PrimaryScreen.Bounds.Bottom;
|
Top = Screen.PrimaryScreen.Bounds.Bottom;
|
||||||
showAnimation.From = Screen.PrimaryScreen.Bounds.Bottom;
|
showAnimation.From = Screen.PrimaryScreen.Bounds.Bottom;
|
||||||
showAnimation.To = Screen.PrimaryScreen.WorkingArea.Bottom - Height;
|
showAnimation.To = Screen.PrimaryScreen.WorkingArea.Bottom - Height;
|
||||||
|
|
||||||
// Create the fade out storyboard
|
// Create the fade out storyboard
|
||||||
fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed);
|
fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed);
|
||||||
DoubleAnimation fadeOutAnimation = new DoubleAnimation(Screen.PrimaryScreen.WorkingArea.Bottom - Height, Screen.PrimaryScreen.Bounds.Bottom, new Duration(TimeSpan.FromSeconds(0.3)))
|
DoubleAnimation fadeOutAnimation = new DoubleAnimation(Screen.PrimaryScreen.WorkingArea.Bottom - Height, Screen.PrimaryScreen.Bounds.Bottom, new Duration(TimeSpan.FromSeconds(0.3))) {
|
||||||
{
|
AccelerationRatio = 0.2
|
||||||
AccelerationRatio = 0.2
|
};
|
||||||
};
|
Storyboard.SetTarget(fadeOutAnimation, this);
|
||||||
Storyboard.SetTarget(fadeOutAnimation, this);
|
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
|
||||||
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
|
fadeOutStoryboard.Children.Add(fadeOutAnimation);
|
||||||
fadeOutStoryboard.Children.Add(fadeOutAnimation);
|
|
||||||
|
|
||||||
imgClose.Source = new BitmapImage(new Uri(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\close.png")));
|
|
||||||
imgClose.MouseUp += imgClose_MouseUp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void imgClose_MouseUp(object sender, MouseButtonEventArgs e)
|
imgClose.Source = new BitmapImage(new Uri("Images\\close.pn", UriKind.Relative));
|
||||||
{
|
//imgClose.Source = new BitmapImage(new Uri(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\close.png")));
|
||||||
if (!closing)
|
imgClose.MouseUp += imgClose_MouseUp;
|
||||||
{
|
}
|
||||||
closing = true;
|
|
||||||
fadeOutStoryboard.Begin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fadeOutStoryboard_Completed(object sender, EventArgs e)
|
void imgClose_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||||
{
|
if (!closing) {
|
||||||
Close();
|
closing = true;
|
||||||
}
|
fadeOutStoryboard.Begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Show(string title, string subTitle, string icopath)
|
private void fadeOutStoryboard_Completed(object sender, EventArgs e) {
|
||||||
{
|
Close();
|
||||||
tbTitle.Text = title;
|
}
|
||||||
tbSubTitle.Text = subTitle;
|
|
||||||
if (!File.Exists(icopath))
|
|
||||||
{
|
|
||||||
icopath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\app.png");
|
|
||||||
}
|
|
||||||
imgIco.Source = new BitmapImage(new Uri(icopath));
|
|
||||||
Show();
|
|
||||||
|
|
||||||
Dispatcher.DelayInvoke("ShowMsg",
|
public void Show(string title, string subTitle, string icopath) {
|
||||||
o =>
|
tbTitle.Text = title;
|
||||||
{
|
tbSubTitle.Text = subTitle;
|
||||||
if (!closing)
|
if (!File.Exists(icopath)) {
|
||||||
{
|
//icopath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\app.png");
|
||||||
closing = true;
|
imgIco.Source = new BitmapImage(new Uri("Images\\app.png", UriKind.Relative));
|
||||||
Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin));
|
}
|
||||||
}
|
else {
|
||||||
}, TimeSpan.FromSeconds(3));
|
imgIco.Source = new BitmapImage(new Uri(icopath));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Show();
|
||||||
|
|
||||||
|
Dispatcher.DelayInvoke("ShowMsg",
|
||||||
|
o => {
|
||||||
|
if (!closing) {
|
||||||
|
closing = true;
|
||||||
|
Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin));
|
||||||
|
}
|
||||||
|
}, TimeSpan.FromSeconds(3));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,97 +10,90 @@ using Wox.Infrastructure.Storage;
|
|||||||
using Wox.Infrastructure.Storage.UserSettings;
|
using Wox.Infrastructure.Storage.UserSettings;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
namespace Wox.PluginLoader
|
namespace Wox.PluginLoader {
|
||||||
{
|
public static class Plugins {
|
||||||
public static class Plugins
|
//private static string debuggerMode = null;
|
||||||
{
|
public static String DebuggerMode { get; private set; }
|
||||||
private static string debuggerMode = null;
|
|
||||||
private static List<PluginPair> plugins = new List<PluginPair>();
|
|
||||||
private static ManualResetEvent initializing = null;
|
|
||||||
|
|
||||||
public static void Init()
|
private static List<PluginPair> plugins = new List<PluginPair>();
|
||||||
{
|
private static ManualResetEvent initializing = null;
|
||||||
if (initializing != null) return;
|
|
||||||
|
|
||||||
initializing = new ManualResetEvent(false);
|
public static void Init() {
|
||||||
plugins.Clear();
|
if (initializing != null) return;
|
||||||
BasePluginLoader.ParsePluginsConfig();
|
|
||||||
|
|
||||||
if (UserSettingStorage.Instance.EnablePythonPlugins)
|
initializing = new ManualResetEvent(false);
|
||||||
{
|
plugins.Clear();
|
||||||
plugins.AddRange(new PythonPluginLoader().LoadPlugin());
|
BasePluginLoader.ParsePluginsConfig();
|
||||||
}
|
|
||||||
|
|
||||||
plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
|
if (UserSettingStorage.Instance.EnablePythonPlugins) {
|
||||||
Forker forker = new Forker();
|
plugins.AddRange(new PythonPluginLoader().LoadPlugin());
|
||||||
foreach (IPlugin plugin in plugins.Select(pluginPair => pluginPair.Plugin))
|
}
|
||||||
{
|
|
||||||
IPlugin plugin1 = plugin;
|
|
||||||
PluginPair pluginPair = plugins.FirstOrDefault(o => o.Plugin == plugin1);
|
|
||||||
if (pluginPair != null)
|
|
||||||
{
|
|
||||||
PluginMetadata metadata = pluginPair.Metadata;
|
|
||||||
pluginPair.InitContext = new PluginInitContext()
|
|
||||||
{
|
|
||||||
Plugins = plugins,
|
|
||||||
CurrentPluginMetadata = metadata,
|
|
||||||
ChangeQuery = s => App.Window.Dispatcher.Invoke(new Action(() => App.Window.ChangeQuery(s))),
|
|
||||||
CloseApp = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.CloseApp())),
|
|
||||||
HideApp = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.HideApp())),
|
|
||||||
ShowApp = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.ShowApp())),
|
|
||||||
ShowMsg = (title, subTitle, iconPath) => App.Window.Dispatcher.Invoke(new Action(() =>
|
|
||||||
App.Window.ShowMsg(title, subTitle, iconPath))),
|
|
||||||
OpenSettingDialog = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.OpenSettingDialog())),
|
|
||||||
ShowCurrentResultItemTooltip = (msg) => App.Window.Dispatcher.Invoke(new Action(() => App.Window.ShowCurrentResultItemTooltip(msg))),
|
|
||||||
ReloadPlugins = () => App.Window.Dispatcher.Invoke(new Action(() => Init())),
|
|
||||||
InstallPlugin = (filePath) => App.Window.Dispatcher.Invoke(new Action(() =>
|
|
||||||
{
|
|
||||||
PluginInstaller.Install(filePath);
|
|
||||||
})),
|
|
||||||
StartLoadingBar = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.StartLoadingBar())),
|
|
||||||
StopLoadingBar = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.StopLoadingBar())),
|
|
||||||
ShellRun = (cmd) => (bool) App.Window.Dispatcher.Invoke(new Func<bool>(() => App.Window.ShellRun(cmd))),
|
|
||||||
};
|
|
||||||
forker.Fork(() => plugin1.Init(pluginPair.InitContext));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadPool.QueueUserWorkItem(o =>
|
plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
|
||||||
{
|
Forker forker = new Forker();
|
||||||
forker.Join();
|
foreach (IPlugin plugin in plugins.Select(pluginPair => pluginPair.Plugin)) {
|
||||||
initializing.Set();
|
IPlugin plugin1 = plugin;
|
||||||
initializing = null;
|
PluginPair pluginPair = plugins.FirstOrDefault(o => o.Plugin == plugin1);
|
||||||
});
|
if (pluginPair != null) {
|
||||||
}
|
PluginMetadata metadata = pluginPair.Metadata;
|
||||||
|
pluginPair.InitContext = new PluginInitContext() {
|
||||||
|
Plugins = plugins,
|
||||||
|
CurrentPluginMetadata = metadata,
|
||||||
|
ChangeQuery = s => App.Window.Dispatcher.Invoke(new Action(() => App.Window.ChangeQuery(s))),
|
||||||
|
CloseApp = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.CloseApp())),
|
||||||
|
HideApp = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.HideApp())),
|
||||||
|
ShowApp = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.ShowApp())),
|
||||||
|
ShowMsg = (title, subTitle, iconPath) => App.Window.Dispatcher.Invoke(new Action(() =>
|
||||||
|
App.Window.ShowMsg(title, subTitle, iconPath))),
|
||||||
|
OpenSettingDialog = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.OpenSettingDialog())),
|
||||||
|
ShowCurrentResultItemTooltip = (msg) => App.Window.Dispatcher.Invoke(new Action(() => App.Window.ShowCurrentResultItemTooltip(msg))),
|
||||||
|
ReloadPlugins = () => App.Window.Dispatcher.Invoke(new Action(() => Init())),
|
||||||
|
InstallPlugin = (filePath) => App.Window.Dispatcher.Invoke(new Action(() => {
|
||||||
|
PluginInstaller.Install(filePath);
|
||||||
|
})),
|
||||||
|
StartLoadingBar = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.StartLoadingBar())),
|
||||||
|
StopLoadingBar = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.StopLoadingBar())),
|
||||||
|
//ShellRun = (cmd) => (bool)App.Window.Dispatcher.Invoke(new Func<bool>(() => App.Window.ShellRun(cmd)))
|
||||||
|
};
|
||||||
|
|
||||||
public static List<PluginPair> AllPlugins
|
pluginPair.InitContext.ShellRun = (cmd) => {
|
||||||
{
|
try {
|
||||||
get
|
return (bool)App.Window.Dispatcher.Invoke(new Func<bool>(() => App.Window.ShellRun(cmd)));
|
||||||
{
|
}
|
||||||
var init = initializing;
|
catch (Exception) {
|
||||||
if (init != null)
|
return false;
|
||||||
{
|
}
|
||||||
init.WaitOne();
|
};
|
||||||
}
|
|
||||||
return plugins;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool HitThirdpartyKeyword(Query query)
|
forker.Fork(() => plugin1.Init(pluginPair.InitContext));
|
||||||
{
|
}
|
||||||
if (string.IsNullOrEmpty(query.ActionName)) return false;
|
}
|
||||||
|
|
||||||
return plugins.Any(o => o.Metadata.PluginType == PluginType.ThirdParty && o.Metadata.ActionKeyword == query.ActionName);
|
ThreadPool.QueueUserWorkItem(o => {
|
||||||
}
|
forker.Join();
|
||||||
|
initializing.Set();
|
||||||
|
initializing = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static void ActivatePluginDebugger(string path)
|
public static List<PluginPair> AllPlugins {
|
||||||
{
|
get {
|
||||||
debuggerMode = path;
|
var init = initializing;
|
||||||
}
|
if (init != null) {
|
||||||
|
init.WaitOne();
|
||||||
|
}
|
||||||
|
return plugins;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String DebuggerMode
|
public static bool HitThirdpartyKeyword(Query query) {
|
||||||
{
|
if (string.IsNullOrEmpty(query.ActionName)) return false;
|
||||||
get { return debuggerMode; }
|
|
||||||
}
|
return plugins.Any(o => o.Metadata.PluginType == PluginType.ThirdParty && o.Metadata.ActionKeyword == query.ActionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ActivatePluginDebugger(string path) {
|
||||||
|
DebuggerMode = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,21 +197,21 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<Page Include="Themes\Dark.xaml">
|
<None Include="Themes\Dark.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Page>
|
</None>
|
||||||
<None Include="Themes\Light.xaml">
|
<None Include="Themes\Light.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<Page Include="Themes\Default.xaml">
|
<None Include="Themes\Default.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Page>
|
</None>
|
||||||
<None Include="Themes\Pink.xaml">
|
<None Include="Themes\Pink.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|||||||
Reference in New Issue
Block a user