fixing most whitespace issues, reordering namespaces and adding in headers (#5677)

This commit is contained in:
Clint Rutkas
2020-08-05 14:06:55 -07:00
committed by GitHub
parent 92a2b83bc8
commit ff69f6ed7f
72 changed files with 942 additions and 624 deletions

View File

@@ -1,6 +1,10 @@
using Microsoft.PowerToys.Telemetry; // Copyright (c) Microsoft Corporation
using Microsoft.PowerToys.Telemetry.Events; // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Diagnostics.Tracing; using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
namespace Microsoft.PowerLauncher.Telemetry namespace Microsoft.PowerLauncher.Telemetry
{ {

View File

@@ -2,9 +2,9 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events; using Microsoft.PowerToys.Telemetry.Events;
using System.Diagnostics.Tracing;
namespace Microsoft.PowerLauncher.Telemetry namespace Microsoft.PowerLauncher.Telemetry
{ {

View File

@@ -2,9 +2,9 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events; using Microsoft.PowerToys.Telemetry.Events;
using System.Diagnostics.Tracing;
namespace Microsoft.PowerLauncher.Telemetry namespace Microsoft.PowerLauncher.Telemetry
{ {

View File

@@ -1,4 +1,8 @@
using System.Diagnostics.Tracing; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events; using Microsoft.PowerToys.Telemetry.Events;

View File

@@ -2,9 +2,9 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events; using Microsoft.PowerToys.Telemetry.Events;
using System.Diagnostics.Tracing;
namespace Microsoft.PowerLauncher.Telemetry namespace Microsoft.PowerLauncher.Telemetry
{ {
@@ -15,10 +15,11 @@ namespace Microsoft.PowerLauncher.Telemetry
public class LauncherQueryEvent : EventBase, IEvent public class LauncherQueryEvent : EventBase, IEvent
{ {
public double QueryTimeMs { get; set; } public double QueryTimeMs { get; set; }
public int QueryLength { get; set; } public int QueryLength { get; set; }
public int NumResults { get; set; } public int NumResults { get; set; }
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance; public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
} }
} }

View File

@@ -2,9 +2,9 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events; using Microsoft.PowerToys.Telemetry.Events;
using System.Diagnostics.Tracing;
namespace Microsoft.PowerLauncher.Telemetry namespace Microsoft.PowerLauncher.Telemetry
{ {
@@ -14,15 +14,16 @@ namespace Microsoft.PowerLauncher.Telemetry
[EventData] [EventData]
public class LauncherResultActionEvent : EventBase, IEvent public class LauncherResultActionEvent : EventBase, IEvent
{ {
public enum TriggerType public enum TriggerType
{ {
Click, Click,
KeyboardShortcut KeyboardShortcut,
} }
public string Trigger { get; set; } public string Trigger { get; set; }
public string PluginName { get; set; } public string PluginName { get; set; }
public string ActionName { get; set; } public string ActionName { get; set; }
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;

View File

@@ -2,9 +2,9 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events; using Microsoft.PowerToys.Telemetry.Events;
using System.Diagnostics.Tracing;
namespace Microsoft.PowerLauncher.Telemetry namespace Microsoft.PowerLauncher.Telemetry
{ {

View File

@@ -2,9 +2,9 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events; using Microsoft.PowerToys.Telemetry.Events;
using System.Diagnostics.Tracing;
namespace Microsoft.PowerLauncher.Telemetry namespace Microsoft.PowerLauncher.Telemetry
{ {

View File

@@ -18,5 +18,19 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj" /> <ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
<Link>StyleCop.json</Link>
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project> </Project>

View File

@@ -1,7 +1,10 @@
using System.Windows; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Windows;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Core.Resource; using Wox.Core.Resource;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.UserSettings; using Wox.Infrastructure.UserSettings;
using Wox.Plugin; using Wox.Plugin;

View File

@@ -1,24 +1,24 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.Windows;
using ManagedCommon; using ManagedCommon;
using Microsoft.PowerLauncher.Telemetry; using Microsoft.PowerLauncher.Telemetry;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using System; using PowerLauncher.Helper;
using System.Diagnostics; using PowerLauncher.ViewModel;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using Wox; using Wox;
using Wox.Core;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Core.Resource; using Wox.Core.Resource;
using PowerLauncher.Helper;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Http; using Wox.Infrastructure.Http;
using Wox.Infrastructure.Image; using Wox.Infrastructure.Image;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.UserSettings; using Wox.Infrastructure.UserSettings;
using Wox.Plugin; using Wox.Plugin;
using PowerLauncher.ViewModel;
using Stopwatch = Wox.Infrastructure.Stopwatch; using Stopwatch = Wox.Infrastructure.Stopwatch;
namespace PowerLauncher namespace PowerLauncher
@@ -26,6 +26,7 @@ namespace PowerLauncher
public partial class App : IDisposable, ISingleInstanceApp public partial class App : IDisposable, ISingleInstanceApp
{ {
public static PublicAPIInstance API { get; private set; } public static PublicAPIInstance API { get; private set; }
private const string Unique = "PowerLauncher_Unique_Application_Mutex"; private const string Unique = "PowerLauncher_Unique_Application_Mutex";
private static bool _disposed = false; private static bool _disposed = false;
private static int _powerToysPid; private static int _powerToysPid;
@@ -66,7 +67,6 @@ namespace PowerLauncher
} }
finally finally
{ {
Environment.Exit(0); Environment.Exit(0);
} }
}); });
@@ -122,7 +122,7 @@ namespace PowerLauncher
PowerToysTelemetry.Log.WriteEvent(new LauncherBootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds }); PowerToysTelemetry.Log.WriteEvent(new LauncherBootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds });
//[Conditional("RELEASE")] // [Conditional("RELEASE")]
// check update every 5 hours // check update every 5 hours
// check updates on startup // check updates on startup
@@ -156,7 +156,6 @@ namespace PowerLauncher
DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException; DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException;
} }
/// <summary> /// <summary>
/// let exception throw as normal is better for Debug /// let exception throw as normal is better for Debug
/// </summary> /// </summary>
@@ -212,4 +211,4 @@ namespace PowerLauncher
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
} }
} }

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
@@ -40,6 +44,7 @@ namespace PowerLauncher.Helper
public override string ContentType public override string ContentType
{ {
get { return m_contentType; } get { return m_contentType; }
set set
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -49,6 +54,7 @@ namespace PowerLauncher.Helper
public override long ContentLength public override long ContentLength
{ {
get { return m_data.Length; } get { return m_data.Length; }
set set
{ {
throw new NotSupportedException(); throw new NotSupportedException();

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Windows.Threading; using System.Windows.Threading;
using NLog; using NLog;
using Wox.Infrastructure; using Wox.Infrastructure;
@@ -22,15 +26,15 @@ namespace PowerLauncher.Helper
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e) public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
{ {
//handle non-ui thread exceptions // handle non-ui thread exceptions
Report((Exception)e?.ExceptionObject); Report((Exception)e?.ExceptionObject);
} }
public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{ {
//handle ui thread exceptions // handle ui thread exceptions
Report(e?.Exception); Report(e?.Exception);
//prevent application exist, so the user can copy prompted error info // prevent application exist, so the user can copy prompted error info
e.Handled = true; e.Handled = true;
} }

View File

@@ -1,6 +1,7 @@
using System; // Copyright (c) Microsoft Corporation
using System.Collections.Generic; // The Microsoft Corporation licenses this file to you under the MIT license.
using System.Text; // See the LICENSE file in the project root for more information.
using System.Windows.Input; using System.Windows.Input;
using Wox.Plugin; using Wox.Plugin;

View File

@@ -1,6 +1,10 @@
using PowerLauncher.ViewModel; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using PowerLauncher.ViewModel;
namespace PowerLauncher.Helper namespace PowerLauncher.Helper
{ {
@@ -42,4 +46,4 @@ namespace PowerLauncher.Helper
} }
} }
} }

View File

@@ -1,17 +1,18 @@
using System; // Copyright (c) Microsoft Corporation
using System.Collections; // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.IO.Pipes; using System.IO.Pipes;
using System.Runtime.Serialization.Formatters;
using System.Security; using System.Security;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Threading;
using static PowerLauncher.Helper.WindowsInteropHelper; using static PowerLauncher.Helper.WindowsInteropHelper;
// http://blogs.microsoft.co.il/arik/2010/05/28/wpf-single-instance-application/ // http://blogs.microsoft.co.il/arik/2010/05/28/wpf-single-instance-application/
@@ -99,7 +100,6 @@ namespace PowerLauncher.Helper
XBUTTONDBLCLK = 0x020D, XBUTTONDBLCLK = 0x020D,
MOUSEHWHEEL = 0x020E, MOUSEHWHEEL = 0x020E,
CAPTURECHANGED = 0x0215, CAPTURECHANGED = 0x0215,
ENTERSIZEMOVE = 0x0231, ENTERSIZEMOVE = 0x0231,
@@ -131,7 +131,7 @@ namespace PowerLauncher.Helper
// This is the hard-coded message value used by WinForms for Shell_NotifyIcon. // This is the hard-coded message value used by WinForms for Shell_NotifyIcon.
// It's relatively safe to reuse. // It's relatively safe to reuse.
TRAYMOUSEMESSAGE = 0x800, //WM_USER + 1024 TRAYMOUSEMESSAGE = 0x800, // WM_USER + 1024
APP = 0x8000 APP = 0x8000
} }
@@ -146,7 +146,6 @@ namespace PowerLauncher.Helper
[DllImport("shell32.dll", EntryPoint = "CommandLineToArgvW", CharSet = CharSet.Unicode)] [DllImport("shell32.dll", EntryPoint = "CommandLineToArgvW", CharSet = CharSet.Unicode)]
private static extern IntPtr _CommandLineToArgvW([MarshalAs(UnmanagedType.LPWStr)] string cmdLine, out int numArgs); private static extern IntPtr _CommandLineToArgvW([MarshalAs(UnmanagedType.LPWStr)] string cmdLine, out int numArgs);
[DllImport("kernel32.dll", EntryPoint = "LocalFree", SetLastError = true)] [DllImport("kernel32.dll", EntryPoint = "LocalFree", SetLastError = true)]
internal static extern IntPtr _LocalFree(IntPtr hMem); internal static extern IntPtr _LocalFree(IntPtr hMem);
@@ -201,7 +200,6 @@ namespace PowerLauncher.Helper
} }
finally finally
{ {
IntPtr p = _LocalFree(argv); IntPtr p = _LocalFree(argv);
// Otherwise LocalFree failed. // Otherwise LocalFree failed.
// Assert.AreEqual(IntPtr.Zero, p); // Assert.AreEqual(IntPtr.Zero, p);
@@ -216,7 +214,7 @@ namespace PowerLauncher.Helper
} }
/// <summary> /// <summary>
/// This class checks to make sure that only one instance of /// This class checks to make sure that only one instance of
/// this application is running at a time. /// this application is running at a time.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
@@ -256,7 +254,7 @@ namespace PowerLauncher.Helper
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// Checks if the instance of the application attempting to start is the first instance. /// Checks if the instance of the application attempting to start is the first instance.
/// If not, activates the first instance. /// If not, activates the first instance.
/// </summary> /// </summary>
/// <returns>True if this is the first instance of the application.</returns> /// <returns>True if this is the first instance of the application.</returns>
@@ -267,7 +265,7 @@ namespace PowerLauncher.Helper
string channelName = String.Concat(applicationIdentifier, Delimiter, ChannelNameSuffix); string channelName = String.Concat(applicationIdentifier, Delimiter, ChannelNameSuffix);
// Create mutex based on unique application Id to check if this is the first instance of the application. // Create mutex based on unique application Id to check if this is the first instance of the application.
bool firstInstance; bool firstInstance;
singleInstanceMutex = new Mutex(true, applicationIdentifier, out firstInstance); singleInstanceMutex = new Mutex(true, applicationIdentifier, out firstInstance);
if (firstInstance) if (firstInstance)
@@ -309,12 +307,11 @@ namespace PowerLauncher.Helper
} }
catch (NotSupportedException) catch (NotSupportedException)
{ {
// The application was clickonce deployed // The application was clickonce deployed
// Clickonce deployed apps cannot receive traditional commandline arguments // Clickonce deployed apps cannot receive traditional commandline arguments
// As a workaround commandline arguments can be written to a shared location before // As a workaround commandline arguments can be written to a shared location before
// the app is launched and the app can obtain its commandline arguments from the // the app is launched and the app can obtain its commandline arguments from the
// shared location // shared location
string appFolderPath = Path.Combine( string appFolderPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), uniqueApplicationName); Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), uniqueApplicationName);
@@ -345,7 +342,7 @@ namespace PowerLauncher.Helper
} }
/// <summary> /// <summary>
/// Creates a remote server pipe for communication. /// Creates a remote server pipe for communication.
/// Once receives signal from client, will activate first instance. /// Once receives signal from client, will activate first instance.
/// </summary> /// </summary>
/// <param name="channelName">Application's IPC channel name.</param> /// <param name="channelName">Application's IPC channel name.</param>

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Drawing; using System.Drawing;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
@@ -12,13 +16,13 @@ namespace PowerLauncher.Helper
{ {
public static class WindowsInteropHelper public static class WindowsInteropHelper
{ {
private const int GWL_STYLE = -16; //WPF's Message code for Title Bar's Style private const int GWL_STYLE = -16; // WPF's Message code for Title Bar's Style
private const int WS_SYSMENU = 0x80000; //WPF's Message code for System Menu private const int WS_SYSMENU = 0x80000; // WPF's Message code for System Menu
private static IntPtr _hwnd_shell; private static IntPtr _hwnd_shell;
private static IntPtr _hwnd_desktop; private static IntPtr _hwnd_desktop;
//Accessors for shell and desktop handlers // Accessors for shell and desktop handlers
//Will set the variables once and then will return them // Will set the variables once and then will return them
private static IntPtr HWND_SHELL private static IntPtr HWND_SHELL
{ {
get get
@@ -101,19 +105,19 @@ namespace PowerLauncher.Helper
public static bool IsWindowFullscreen() public static bool IsWindowFullscreen()
{ {
//get current active window // get current active window
IntPtr hWnd = NativeMethods.GetForegroundWindow(); IntPtr hWnd = NativeMethods.GetForegroundWindow();
if (hWnd != null && !hWnd.Equals(IntPtr.Zero)) if (hWnd != null && !hWnd.Equals(IntPtr.Zero))
{ {
//if current active window is NOT desktop or shell // if current active window is NOT desktop or shell
if (!(hWnd.Equals(HWND_DESKTOP) || hWnd.Equals(HWND_SHELL))) if (!(hWnd.Equals(HWND_DESKTOP) || hWnd.Equals(HWND_SHELL)))
{ {
StringBuilder sb = new StringBuilder(256); StringBuilder sb = new StringBuilder(256);
_ = NativeMethods.GetClassName(hWnd, sb, sb.Capacity); _ = NativeMethods.GetClassName(hWnd, sb, sb.Capacity);
string windowClass = sb.ToString(); string windowClass = sb.ToString();
//for Win+Tab (Flip3D) // for Win+Tab (Flip3D)
if (windowClass == WINDOW_CLASS_WINTAB) if (windowClass == WINDOW_CLASS_WINTAB)
{ {
return false; return false;
@@ -122,13 +126,13 @@ namespace PowerLauncher.Helper
RECT appBounds; RECT appBounds;
_ = NativeMethods.GetWindowRect(hWnd, out appBounds); _ = NativeMethods.GetWindowRect(hWnd, out appBounds);
//for console (ConsoleWindowClass), we have to check for negative dimensions // for console (ConsoleWindowClass), we have to check for negative dimensions
if (windowClass == WINDOW_CLASS_CONSOLE) if (windowClass == WINDOW_CLASS_CONSOLE)
{ {
return appBounds.Top < 0 && appBounds.Bottom < 0; return appBounds.Top < 0 && appBounds.Bottom < 0;
} }
//for desktop (Progman or WorkerW, depends on the system), we have to check // for desktop (Progman or WorkerW, depends on the system), we have to check
if (windowClass == WINDOW_CLASS_PROGMAN || windowClass == WINDOW_CLASS_WORKERW) if (windowClass == WINDOW_CLASS_PROGMAN || windowClass == WINDOW_CLASS_WORKERW)
{ {
IntPtr hWndDesktop = NativeMethods.FindWindowEx(hWnd, IntPtr.Zero, "SHELLDLL_DefView", null); IntPtr hWndDesktop = NativeMethods.FindWindowEx(hWnd, IntPtr.Zero, "SHELLDLL_DefView", null);
@@ -185,7 +189,6 @@ namespace PowerLauncher.Helper
return new Point((int)(matrix.M11 * unitX), (int)(matrix.M22 * unitY)); return new Point((int)(matrix.M11 * unitX), (int)(matrix.M22 * unitY));
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct RECT internal struct RECT
{ {
@@ -195,4 +198,4 @@ namespace PowerLauncher.Helper
public int Bottom; public int Bottom;
} }
} }
} }

View File

@@ -1,4 +1,8 @@
using System.Windows.Controls; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Windows.Controls;
namespace PowerLauncher namespace PowerLauncher
{ {
@@ -12,4 +16,4 @@ namespace PowerLauncher
InitializeComponent(); InitializeComponent();
} }
} }
} }

View File

@@ -1,23 +1,25 @@
using Microsoft.PowerLauncher.Telemetry; // Copyright (c) Microsoft Corporation
using Microsoft.PowerToys.Telemetry; // The Microsoft Corporation licenses this file to you under the MIT license.
using PowerLauncher.Helper; // See the LICENSE file in the project root for more information.
using PowerLauncher.ViewModel;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Timers; using System.Timers;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using Microsoft.PowerLauncher.Telemetry;
using Microsoft.PowerToys.Telemetry;
using PowerLauncher.Helper;
using PowerLauncher.ViewModel;
using Wox.Infrastructure.UserSettings; using Wox.Infrastructure.UserSettings;
using KeyEventArgs = System.Windows.Input.KeyEventArgs; using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using Screen = System.Windows.Forms.Screen; using Screen = System.Windows.Forms.Screen;
namespace PowerLauncher namespace PowerLauncher
{ {
public partial class MainWindow : IDisposable public partial class MainWindow : IDisposable
{ {
#region Private Fields #region Private Fields
private Settings _settings; private Settings _settings;
private MainViewModel _viewModel; private MainViewModel _viewModel;
@@ -53,6 +55,7 @@ namespace PowerLauncher
} }
} }
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
@@ -106,7 +109,7 @@ namespace PowerLauncher
{ {
var resultVM = result as ResultViewModel; var resultVM = result as ResultViewModel;
//This may be null if the tapped item was one of the context buttons (run as admin etc). // This may be null if the tapped item was one of the context buttons (run as admin etc).
if (resultVM != null) if (resultVM != null)
{ {
_viewModel.Results.SelectedItem = resultVM; _viewModel.Results.SelectedItem = resultVM;
@@ -122,7 +125,7 @@ namespace PowerLauncher
if (Visibility == System.Windows.Visibility.Visible) if (Visibility == System.Windows.Visibility.Visible)
{ {
// Not called on first launch // Not called on first launch
// Additionally called when deactivated by clicking on screen // Additionally called when deactivated by clicking on screen
UpdatePosition(); UpdatePosition();
BringProcessToForeground(); BringProcessToForeground();
@@ -170,7 +173,7 @@ namespace PowerLauncher
{ {
if (_settings.HideWhenDeactivated) if (_settings.HideWhenDeactivated)
{ {
//(this.FindResource("OutroStoryboard") as Storyboard).Begin(); // (this.FindResource("OutroStoryboard") as Storyboard).Begin();
Hide(); Hide();
} }
} }
@@ -304,7 +307,7 @@ namespace PowerLauncher
} }
// To populate the AutoCompleteTextBox as soon as the selection is changed or set. // To populate the AutoCompleteTextBox as soon as the selection is changed or set.
// Setting it here instead of when the text is changed as there is a delay in executing the query and populating the result // Setting it here instead of when the text is changed as there is a delay in executing the query and populating the result
if (_viewModel.Results != null) if (_viewModel.Results != null)
{ {
SearchBox.AutoCompleteTextBlock.Text = MainViewModel.GetAutoCompleteText( SearchBox.AutoCompleteTextBlock.Text = MainViewModel.GetAutoCompleteText(
@@ -396,7 +399,7 @@ namespace PowerLauncher
SearchBox.AutoCompleteTextBlock.FlowDirection = MainViewModel.GetLanguageFlowDirection(); SearchBox.AutoCompleteTextBlock.FlowDirection = MainViewModel.GetLanguageFlowDirection();
} }
private void SearchBox_InputLanguageChanged(object sender, InputLanguageEventArgs e) private void SearchBox_InputLanguageChanged(object sender, InputLanguageEventArgs e)
{ {
SearchBox_UpdateFlowDirection(); SearchBox_UpdateFlowDirection();
} }

View File

@@ -259,5 +259,19 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
</ItemGroup> </ItemGroup>
<!--<ItemGroup>
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
<Link>StyleCop.json</Link>
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>-->
</Project> </Project>

View File

@@ -1,8 +1,11 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Core.Resource; using Wox.Core.Resource;
@@ -60,7 +63,7 @@ namespace Wox
public void CheckForNewUpdate() public void CheckForNewUpdate()
{ {
//_settingsVM.UpdateApp(); // _settingsVM.UpdateApp();
} }
public void SaveAppAllSettings() public void SaveAppAllSettings()

View File

@@ -1,18 +1,21 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Text;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using PowerLauncher.Helper; using PowerLauncher.Helper;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Logger;
using System.Windows.Navigation;
using Wox.Infrastructure.Image; using Wox.Infrastructure.Image;
using System.Drawing; using Wox.Infrastructure.Logger;
using System.Windows.Media.Imaging;
namespace PowerLauncher namespace PowerLauncher
{ {

View File

@@ -1,4 +1,8 @@
using System.Windows.Controls; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Windows.Controls;
namespace PowerLauncher namespace PowerLauncher
{ {
@@ -12,4 +16,4 @@ namespace PowerLauncher
InitializeComponent(); InitializeComponent();
} }
} }
} }

View File

@@ -1,7 +1,9 @@
namespace PowerLauncher.Properties // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace PowerLauncher.Properties
{ {
// This class allows you to handle specific events on the settings class: // This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed. // The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed. // The PropertyChanged event is raised after a setting's value is changed.
@@ -9,7 +11,6 @@
// The SettingsSaving event is raised before the setting values are saved. // The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings internal sealed partial class Settings
{ {
public Settings() public Settings()
{ {
// // To add event handlers for saving and changing settings, uncomment the lines below: // // To add event handlers for saving and changing settings, uncomment the lines below:

View File

@@ -1,17 +1,17 @@
using System; // Copyright (c) Microsoft Corporation
using System.Collections.Generic; // The Microsoft Corporation licenses this file to you under the MIT license.
using System.Text; // See the LICENSE file in the project root for more information.
using Wox.Plugin;
using Microsoft.PowerToys.Settings.UI.Lib; using System;
using Wox.Infrastructure.UserSettings;
using Microsoft.PowerToys.Settings.UI.Lib.Utilities;
using System.Diagnostics; using System.Diagnostics;
using System.Threading;
using Wox.Infrastructure.Hotkey;
using System.Windows.Input;
using Wox.Core.Plugin;
using System.IO; using System.IO;
using System.Threading;
using System.Windows.Input;
using Microsoft.PowerToys.Settings.UI.Lib;
using Wox.Core.Plugin;
using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
namespace PowerLauncher namespace PowerLauncher
{ {
@@ -22,6 +22,7 @@ namespace PowerLauncher
private static object _watcherSyncObject = new object(); private static object _watcherSyncObject = new object();
private FileSystemWatcher _watcher; private FileSystemWatcher _watcher;
private Settings _settings; private Settings _settings;
public SettingsWatcher(Settings settings) public SettingsWatcher(Settings settings)
{ {
_settings = settings; _settings = settings;
@@ -89,7 +90,7 @@ namespace PowerLauncher
retry = false; retry = false;
} }
// the settings application can hold a lock on the settings.json file which will result in a IOException. // the settings application can hold a lock on the settings.json file which will result in a IOException.
// This should be changed to properly synch with the settings app instead of retrying. // This should be changed to properly synch with the settings app instead of retrying.
catch (IOException e) catch (IOException e)
{ {

View File

@@ -1,3 +1,7 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System; using System;
namespace PowerLauncher.Storage namespace PowerLauncher.Storage
@@ -5,6 +9,7 @@ namespace PowerLauncher.Storage
public class HistoryItem public class HistoryItem
{ {
public string Query { get; set; } public string Query { get; set; }
public DateTime ExecutedDateTime { get; set; } public DateTime ExecutedDateTime { get; set; }
public string GetTimeAgo() public string GetTimeAgo()
@@ -42,4 +47,4 @@ namespace PowerLauncher.Storage
return string.Empty; return string.Empty;
} }
} }
} }

View File

@@ -1,8 +1,10 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json;
using Wox.Plugin;
namespace PowerLauncher.Storage namespace PowerLauncher.Storage
{ {

View File

@@ -1,4 +1,8 @@
using System.Collections.Generic; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wox.Plugin; using Wox.Plugin;
@@ -18,7 +22,7 @@ namespace PowerLauncher.Storage
return false; return false;
} }
// since this dictionary should be very small (or empty) going over it should be pretty fast. // since this dictionary should be very small (or empty) going over it should be pretty fast.
return records.Any(o => o.Value.Title == result.Title return records.Any(o => o.Value.Title == result.Title
&& o.Value.SubTitle == result.SubTitle && o.Value.SubTitle == result.SubTitle
&& o.Value.PluginID == result.PluginID && o.Value.PluginID == result.PluginID
@@ -48,11 +52,12 @@ namespace PowerLauncher.Storage
} }
} }
public class Record public class Record
{ {
public string Title { get; set; } public string Title { get; set; }
public string SubTitle { get; set; } public string SubTitle { get; set; }
public string PluginID { get; set; } public string PluginID { get; set; }
} }
} }

View File

@@ -1,7 +1,10 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wox.Infrastructure.Storage;
using Wox.Plugin; using Wox.Plugin;
namespace PowerLauncher.Storage namespace PowerLauncher.Storage

View File

@@ -1,8 +1,10 @@
using Microsoft.PowerLauncher.Telemetry; // Copyright (c) Microsoft Corporation
using Microsoft.PowerToys.Telemetry; // The Microsoft Corporation licenses this file to you under the MIT license.
using System.Drawing; // See the LICENSE file in the project root for more information.
using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
using Microsoft.PowerLauncher.Telemetry;
using Microsoft.PowerToys.Telemetry;
using Wox.Plugin; using Wox.Plugin;
namespace PowerLauncher.ViewModel namespace PowerLauncher.ViewModel
@@ -12,9 +14,13 @@ namespace PowerLauncher.ViewModel
private ICommand _command; private ICommand _command;
public string PluginName { get; set; } public string PluginName { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string Glyph { get; set; } public string Glyph { get; set; }
public string FontFamily { get; set; } public string FontFamily { get; set; }
public ICommand Command public ICommand Command
{ {
get get
@@ -34,7 +40,9 @@ namespace PowerLauncher.ViewModel
} }
public Key AcceleratorKey { get; set; } public Key AcceleratorKey { get; set; }
public ModifierKeys AcceleratorModifiers { get; set; } public ModifierKeys AcceleratorModifiers { get; set; }
public bool IsAcceleratorKeyEnabled { get; set; } public bool IsAcceleratorKeyEnabled { get; set; }
public void SendTelemetryEvent(LauncherResultActionEvent.TriggerType triggerType) public void SendTelemetryEvent(LauncherResultActionEvent.TriggerType triggerType)
@@ -49,4 +57,4 @@ namespace PowerLauncher.ViewModel
PowerToysTelemetry.Log.WriteEvent(eventData); PowerToysTelemetry.Log.WriteEvent(eventData);
} }
} }
} }

View File

@@ -1,25 +1,29 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using interop;
using Microsoft.PowerLauncher.Telemetry;
using Microsoft.PowerToys.Telemetry;
using PowerLauncher.Helper;
using PowerLauncher.Storage;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Core.Resource; using Wox.Core.Resource;
using PowerLauncher.Helper;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey; using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using Wox.Infrastructure.UserSettings; using Wox.Infrastructure.UserSettings;
using Wox.Plugin; using Wox.Plugin;
using Microsoft.PowerLauncher.Telemetry;
using PowerLauncher.Storage;
using Microsoft.PowerToys.Telemetry;
using interop;
using System.Globalization;
namespace PowerLauncher.ViewModel namespace PowerLauncher.ViewModel
{ {
@@ -41,9 +45,12 @@ namespace PowerLauncher.ViewModel
private readonly TopMostRecord _topMostRecord; private readonly TopMostRecord _topMostRecord;
private CancellationTokenSource _updateSource { get; set; } private CancellationTokenSource _updateSource { get; set; }
private CancellationToken _updateToken; private CancellationToken _updateToken;
private bool _saved; private bool _saved;
private HotkeyManager _hotkeyManager { get; set; } private HotkeyManager _hotkeyManager { get; set; }
private ushort _hotkeyHandle; private ushort _hotkeyHandle;
private readonly Internationalization _translator = InternationalizationManager.Instance; private readonly Internationalization _translator = InternationalizationManager.Instance;
private System.Diagnostics.Stopwatch hotkeyTimer = new System.Diagnostics.Stopwatch(); private System.Diagnostics.Stopwatch hotkeyTimer = new System.Diagnostics.Stopwatch();
@@ -191,7 +198,7 @@ namespace PowerLauncher.ViewModel
if (results.SelectedItem != null) if (results.SelectedItem != null)
{ {
//If there is a context button selected fire the action for that button before the main command. // If there is a context button selected fire the action for that button before the main command.
bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton(); bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton();
if (!didExecuteContextButton) if (!didExecuteContextButton)
@@ -253,7 +260,7 @@ namespace PowerLauncher.ViewModel
if (!string.IsNullOrEmpty(QueryText)) if (!string.IsNullOrEmpty(QueryText))
{ {
ChangeQueryText(string.Empty, true); ChangeQueryText(string.Empty, true);
//Push Event to UI SystemQuery has changed // Push Event to UI SystemQuery has changed
OnPropertyChanged(nameof(SystemQueryText)); OnPropertyChanged(nameof(SystemQueryText));
} }
}); });
@@ -264,10 +271,13 @@ namespace PowerLauncher.ViewModel
#region ViewModel Properties #region ViewModel Properties
public Brush MainWindowBackground { get; set; } public Brush MainWindowBackground { get; set; }
public Brush MainWindowBorderBrush { get; set; } public Brush MainWindowBorderBrush { get; set; }
public ResultsViewModel Results { get; private set; } public ResultsViewModel Results { get; private set; }
public ResultsViewModel ContextMenu { get; private set; } public ResultsViewModel ContextMenu { get; private set; }
public ResultsViewModel History { get; private set; } public ResultsViewModel History { get; private set; }
public string SystemQueryText { get; set; } = String.Empty; public string SystemQueryText { get; set; } = String.Empty;
@@ -276,7 +286,7 @@ namespace PowerLauncher.ViewModel
/// <summary> /// <summary>
/// we need move cursor to end when we manually changed query /// we need move cursor to end when we manually changed query
/// but we don't want to move cursor to end when query is updated from TextBox. /// but we don't want to move cursor to end when query is updated from TextBox.
/// Also we don't want to force the results to change unless explicitly told to. /// Also we don't want to force the results to change unless explicitly told to.
/// </summary> /// </summary>
/// <param name="queryText"></param> /// <param name="queryText"></param>
@@ -291,12 +301,15 @@ namespace PowerLauncher.ViewModel
Query(); Query();
} }
} }
public bool LastQuerySelected { get; set; } public bool LastQuerySelected { get; set; }
private ResultsViewModel _selectedResults; private ResultsViewModel _selectedResults;
private ResultsViewModel SelectedResults private ResultsViewModel SelectedResults
{ {
get { return _selectedResults; } get { return _selectedResults; }
set set
{ {
_selectedResults = value; _selectedResults = value;
@@ -311,7 +324,6 @@ namespace PowerLauncher.ViewModel
Results.Visibility = Visibility.Hidden; Results.Visibility = Visibility.Hidden;
_queryTextBeforeLeaveResults = QueryText; _queryTextBeforeLeaveResults = QueryText;
// Because of Fody's optimization // Because of Fody's optimization
// setter won't be called when property value is not changed. // setter won't be called when property value is not changed.
// so we need manually call Query() // so we need manually call Query()
@@ -336,6 +348,7 @@ namespace PowerLauncher.ViewModel
public Visibility MainWindowVisibility public Visibility MainWindowVisibility
{ {
get { return _visibility; } get { return _visibility; }
set set
{ {
_visibility = value; _visibility = value;
@@ -352,24 +365,36 @@ namespace PowerLauncher.ViewModel
} }
public ICommand IgnoreCommand { get; set; } public ICommand IgnoreCommand { get; set; }
public ICommand EscCommand { get; set; } public ICommand EscCommand { get; set; }
public ICommand SelectNextItemCommand { get; set; } public ICommand SelectNextItemCommand { get; set; }
public ICommand SelectPrevItemCommand { get; set; } public ICommand SelectPrevItemCommand { get; set; }
public ICommand SelectNextContextMenuItemCommand { get; set; } public ICommand SelectNextContextMenuItemCommand { get; set; }
public ICommand SelectPreviousContextMenuItemCommand { get; set; } public ICommand SelectPreviousContextMenuItemCommand { get; set; }
public ICommand SelectNextTabItemCommand { get; set; } public ICommand SelectNextTabItemCommand { get; set; }
public ICommand SelectPrevTabItemCommand { get; set; } public ICommand SelectPrevTabItemCommand { get; set; }
public ICommand SelectNextPageCommand { get; set; } public ICommand SelectNextPageCommand { get; set; }
public ICommand SelectPrevPageCommand { get; set; }
public ICommand SelectFirstResultCommand { get; set; }
public ICommand StartHelpCommand { get; set; }
public ICommand LoadContextMenuCommand { get; set; }
public ICommand LoadHistoryCommand { get; set; }
public ICommand OpenResultCommand { get; set; }
public ICommand ClearQueryCommand { get; set; }
public ICommand SelectPrevPageCommand { get; set; }
public ICommand SelectFirstResultCommand { get; set; }
public ICommand StartHelpCommand { get; set; }
public ICommand LoadContextMenuCommand { get; set; }
public ICommand LoadHistoryCommand { get; set; }
public ICommand OpenResultCommand { get; set; }
public ICommand ClearQueryCommand { get; set; }
#endregion #endregion
@@ -548,7 +573,6 @@ namespace PowerLauncher.ViewModel
} }
} }
private bool SelectedIsFromQueryResults() private bool SelectedIsFromQueryResults()
{ {
var selected = SelectedResults == Results; var selected = SelectedResults == Results;
@@ -561,7 +585,6 @@ namespace PowerLauncher.ViewModel
return selected; return selected;
} }
private bool HistorySelected() private bool HistorySelected()
{ {
var selected = SelectedResults == History; var selected = SelectedResults == History;
@@ -604,7 +627,7 @@ namespace PowerLauncher.ViewModel
/// <returns></returns> /// <returns></returns>
private bool ShouldIgnoreHotkeys() private bool ShouldIgnoreHotkeys()
{ {
//double if to omit calling win32 function // double if to omit calling win32 function
if (_settings.IgnoreHotkeysOnFullscreen) if (_settings.IgnoreHotkeysOnFullscreen)
if (WindowsInteropHelper.IsWindowFullscreen()) if (WindowsInteropHelper.IsWindowFullscreen())
return true; return true;
@@ -635,7 +658,6 @@ namespace PowerLauncher.ViewModel
// If launcher window was hidden and the hotkey was pressed, start telemetry event // If launcher window was hidden and the hotkey was pressed, start telemetry event
if (MainWindowVisibility != Visibility.Visible) if (MainWindowVisibility != Visibility.Visible)
{ {
StartHotkeyTimer(); StartHotkeyTimer();
} }
if (_settings.LastQueryMode == LastQueryMode.Empty) if (_settings.LastQueryMode == LastQueryMode.Empty)
@@ -857,4 +879,4 @@ namespace PowerLauncher.ViewModel
#endregion #endregion
} }
} }

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Windows.Input; using System.Windows.Input;
namespace PowerLauncher.ViewModel namespace PowerLauncher.ViewModel

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
@@ -21,7 +25,9 @@ namespace PowerLauncher.ViewModel
public ObservableCollection<ContextMenuItemViewModel> ContextMenuItems { get; } = new ObservableCollection<ContextMenuItemViewModel>(); public ObservableCollection<ContextMenuItemViewModel> ContextMenuItems { get; } = new ObservableCollection<ContextMenuItemViewModel>();
public ICommand ActivateContextButtonsHoverCommand { get; set; } public ICommand ActivateContextButtonsHoverCommand { get; set; }
public ICommand ActivateContextButtonsSelectionCommand { get; set; } public ICommand ActivateContextButtonsSelectionCommand { get; set; }
public ICommand DeactivateContextButtonsHoverCommand { get; set; } public ICommand DeactivateContextButtonsHoverCommand { get; set; }
public ICommand DeactivateContextButtonsSelectionCommand { get; set; } public ICommand DeactivateContextButtonsSelectionCommand { get; set; }
@@ -61,6 +67,7 @@ namespace PowerLauncher.ViewModel
{ {
ActivateContextButtons(ActivationType.Selection); ActivateContextButtons(ActivationType.Selection);
} }
public void ActivateContextButtons(ActivationType activationType) public void ActivateContextButtons(ActivationType activationType)
{ {
// Result does not contain any context menu items - we don't need to show the context menu ListView at all. // Result does not contain any context menu items - we don't need to show the context menu ListView at all.
@@ -84,7 +91,6 @@ namespace PowerLauncher.ViewModel
} }
} }
private void DeactivateContextButtonsHoverAction(object sender) private void DeactivateContextButtonsHoverAction(object sender)
{ {
DeactivateContextButtons(ActivationType.Hover); DeactivateContextButtons(ActivationType.Hover);
@@ -118,7 +124,6 @@ namespace PowerLauncher.ViewModel
} }
} }
public void LoadContextMenu() public void LoadContextMenu()
{ {
var results = PluginManager.GetContextMenusForPlugin(Result); var results = PluginManager.GetContextMenusForPlugin(Result);
@@ -142,7 +147,7 @@ namespace PowerLauncher.ViewModel
if (hideWindow) if (hideWindow)
{ {
//TODO - Do we hide the window // TODO - Do we hide the window
// MainWindowVisibility = Visibility.Collapsed; // MainWindowVisibility = Visibility.Collapsed;
} }
}) })
@@ -191,7 +196,7 @@ namespace PowerLauncher.ViewModel
} }
} }
//Returns false if we've already reached the last item. // Returns false if we've already reached the last item.
public bool SelectNextContextButton() public bool SelectNextContextButton()
{ {
if (ContextMenuSelectedIndex == (ContextMenuItems.Count - 1)) if (ContextMenuSelectedIndex == (ContextMenuItems.Count - 1))
@@ -204,7 +209,7 @@ namespace PowerLauncher.ViewModel
return true; return true;
} }
//Returns false if we've already reached the first item. // Returns false if we've already reached the first item.
public bool SelectPrevContextButton() public bool SelectPrevContextButton()
{ {
if (ContextMenuSelectedIndex == NoSelectionIndex) if (ContextMenuSelectedIndex == NoSelectionIndex)

View File

@@ -1,184 +1,190 @@
using PowerLauncher.Helper; // Copyright (c) Microsoft Corporation
using System; // The Microsoft Corporation licenses this file to you under the MIT license.
using System.Collections.Generic; // See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using Wox.Infrastructure.UserSettings; using PowerLauncher.Helper;
using Wox.Plugin; using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
namespace PowerLauncher.ViewModel
{ namespace PowerLauncher.ViewModel
public class ResultsViewModel : BaseModel {
{ public class ResultsViewModel : BaseModel
#region Private Fields {
#region Private Fields
public ResultCollection Results { get; }
public ResultCollection Results { get; }
private readonly object _collectionLock = new object();
private readonly Settings _settings; private readonly object _collectionLock = new object();
// private int MaxResults => _settings?.MaxResultsToShow ?? 6; private readonly Settings _settings;
// private int MaxResults => _settings?.MaxResultsToShow ?? 6;
public ResultsViewModel()
{ public ResultsViewModel()
Results = new ResultCollection(); {
BindingOperations.EnableCollectionSynchronization(Results, _collectionLock); Results = new ResultCollection();
} BindingOperations.EnableCollectionSynchronization(Results, _collectionLock);
public ResultsViewModel(Settings settings) : this() }
{
_settings = settings ?? throw new ArgumentNullException(nameof(settings)); public ResultsViewModel(Settings settings) : this()
_settings.PropertyChanged += (s, e) => {
{ _settings = settings ?? throw new ArgumentNullException(nameof(settings));
if (e.PropertyName == nameof(_settings.MaxResultsToShow)) _settings.PropertyChanged += (s, e) =>
{ {
Application.Current.Dispatcher.Invoke(() => if (e.PropertyName == nameof(_settings.MaxResultsToShow))
{ {
OnPropertyChanged(nameof(MaxHeight)); Application.Current.Dispatcher.Invoke(() =>
}); {
} OnPropertyChanged(nameof(MaxHeight));
}; });
} }
};
#endregion }
#region Properties #endregion
public int MaxHeight #region Properties
{
get public int MaxHeight
{ {
return _settings.MaxResultsToShow * 75; get
} {
} return _settings.MaxResultsToShow * 75;
public int SelectedIndex { get; set; } }
}
private ResultViewModel _selectedItem;
public ResultViewModel SelectedItem public int SelectedIndex { get; set; }
{
get { return _selectedItem; } private ResultViewModel _selectedItem;
set
{ public ResultViewModel SelectedItem
//value can be null when selecting an item in a virtualized list {
if (value != null) get { return _selectedItem; }
{
if (_selectedItem != null) set
{ {
_selectedItem.DeactivateContextButtons(ResultViewModel.ActivationType.Selection); // value can be null when selecting an item in a virtualized list
} if (value != null)
{
_selectedItem = value; if (_selectedItem != null)
_selectedItem.ActivateContextButtons(ResultViewModel.ActivationType.Selection); {
} _selectedItem.DeactivateContextButtons(ResultViewModel.ActivationType.Selection);
else }
{
_selectedItem = value; _selectedItem = value;
} _selectedItem.ActivateContextButtons(ResultViewModel.ActivationType.Selection);
} }
} else
{
_selectedItem = value;
}
public Thickness Margin { get; set; } }
public Visibility Visibility { get; set; } = Visibility.Hidden; }
#endregion public Thickness Margin { get; set; }
#region Private Methods public Visibility Visibility { get; set; } = Visibility.Hidden;
private static int InsertIndexOf(int newScore, IList<ResultViewModel> list) #endregion
{
int index = 0; #region Private Methods
for (; index < list.Count; index++)
{ private static int InsertIndexOf(int newScore, IList<ResultViewModel> list)
var result = list[index]; {
if (newScore > result.Result.Score) int index = 0;
{ for (; index < list.Count; index++)
break; {
} var result = list[index];
} if (newScore > result.Result.Score)
return index; {
} break;
}
private int NewIndex(int i) }
{ return index;
var n = Results.Count; }
if (n > 0)
{ private int NewIndex(int i)
i = (n + i) % n; {
return i; var n = Results.Count;
} if (n > 0)
else {
{ i = (n + i) % n;
// SelectedIndex returns -1 if selection is empty. return i;
return -1; }
} else
} {
// SelectedIndex returns -1 if selection is empty.
return -1;
#endregion }
}
#region Public Methods
#endregion
public void SelectNextResult()
{ #region Public Methods
SelectedIndex = NewIndex(SelectedIndex + 1);
} public void SelectNextResult()
{
public void SelectPrevResult() SelectedIndex = NewIndex(SelectedIndex + 1);
{ }
SelectedIndex = NewIndex(SelectedIndex - 1);
} public void SelectPrevResult()
{
public void SelectNextPage() SelectedIndex = NewIndex(SelectedIndex - 1);
{ }
SelectedIndex = NewIndex(SelectedIndex + _settings.MaxResultsToShow);
} public void SelectNextPage()
{
public void SelectPrevPage() SelectedIndex = NewIndex(SelectedIndex + _settings.MaxResultsToShow);
{ }
SelectedIndex = NewIndex(SelectedIndex - _settings.MaxResultsToShow);
} public void SelectPrevPage()
{
public void SelectFirstResult() SelectedIndex = NewIndex(SelectedIndex - _settings.MaxResultsToShow);
{ }
SelectedIndex = NewIndex(0);
} public void SelectFirstResult()
{
public void Clear() SelectedIndex = NewIndex(0);
{ }
Results.Clear();
} public void Clear()
{
public void RemoveResultsExcept(PluginMetadata metadata) Results.Clear();
{ }
Results.RemoveAll(r => r.Result.PluginID != metadata.ID);
} public void RemoveResultsExcept(PluginMetadata metadata)
{
public void RemoveResultsFor(PluginMetadata metadata) Results.RemoveAll(r => r.Result.PluginID != metadata.ID);
{ }
Results.RemoveAll(r => r.Result.PluginID == metadata.ID);
} public void RemoveResultsFor(PluginMetadata metadata)
{
public void SelectNextTabItem() Results.RemoveAll(r => r.Result.PluginID == metadata.ID);
{ }
//Do nothing if there is no selected item or we've selected the next context button
if (!SelectedItem?.SelectNextContextButton() ?? true) public void SelectNextTabItem()
{ {
SelectNextResult(); // Do nothing if there is no selected item or we've selected the next context button
} if (!SelectedItem?.SelectNextContextButton() ?? true)
} {
SelectNextResult();
public void SelectPrevTabItem() }
{ }
//Do nothing if there is no selected item or we've selected the previous context button
if (!SelectedItem?.SelectPrevContextButton() ?? true) public void SelectPrevTabItem()
{ {
//Tabbing backwards should highlight the last item of the previous row // Do nothing if there is no selected item or we've selected the previous context button
SelectPrevResult(); if (!SelectedItem?.SelectPrevContextButton() ?? true)
SelectedItem.SelectLastContextButton(); {
} // Tabbing backwards should highlight the last item of the previous row
SelectPrevResult();
SelectedItem.SelectLastContextButton();
}
} }
public void SelectNextContextMenuItem() public void SelectNextContextMenuItem()
@@ -190,16 +196,16 @@ namespace PowerLauncher.ViewModel
SelectedItem.SelectLastContextButton(); SelectedItem.SelectLastContextButton();
} }
} }
} }
public void SelectPreviousContextMenuItem() public void SelectPreviousContextMenuItem()
{ {
if (SelectedItem != null) if (SelectedItem != null)
{ {
SelectedItem.SelectPrevContextButton(); SelectedItem.SelectPrevContextButton();
} }
} }
public bool IsContextMenuItemSelected() public bool IsContextMenuItemSelected()
{ {
if (SelectedItem != null && SelectedItem.ContextMenuSelectedIndex != ResultViewModel.NoSelectionIndex) if (SelectedItem != null && SelectedItem.ContextMenuSelectedIndex != ResultViewModel.NoSelectionIndex)
@@ -210,12 +216,12 @@ namespace PowerLauncher.ViewModel
{ {
return false; return false;
} }
} }
/// <summary> /// <summary>
/// Add new results to ResultCollection /// Add new results to ResultCollection
/// </summary> /// </summary>
public void AddResults(List<Result> newRawResults, string resultId, CancellationToken ct) public void AddResults(List<Result> newRawResults, string resultId, CancellationToken ct)
{ {
if (newRawResults == null) if (newRawResults == null)
{ {
@@ -230,44 +236,43 @@ namespace PowerLauncher.ViewModel
} }
Results.RemoveAll(r => r.Result.PluginID == resultId); Results.RemoveAll(r => r.Result.PluginID == resultId);
Results.AddRange(newResults); Results.AddRange(newResults);
} }
#endregion #endregion
#region FormattedText Dependency Property #region FormattedText Dependency Property
public static readonly DependencyProperty FormattedTextProperty = DependencyProperty.RegisterAttached( public static readonly DependencyProperty FormattedTextProperty = DependencyProperty.RegisterAttached(
"FormattedText", "FormattedText",
typeof(Inline), typeof(Inline),
typeof(ResultsViewModel), typeof(ResultsViewModel),
new PropertyMetadata(null, FormattedTextPropertyChanged)); new PropertyMetadata(null, FormattedTextPropertyChanged));
public static void SetFormattedText(DependencyObject textBlock, IList<int> value) public static void SetFormattedText(DependencyObject textBlock, IList<int> value)
{ {
if (textBlock != null) if (textBlock != null)
{ {
textBlock.SetValue(FormattedTextProperty, value); textBlock.SetValue(FormattedTextProperty, value);
} }
} }
public static Inline GetFormattedText(DependencyObject textBlock) public static Inline GetFormattedText(DependencyObject textBlock)
{ {
return (Inline)textBlock?.GetValue(FormattedTextProperty); return (Inline)textBlock?.GetValue(FormattedTextProperty);
} }
private static void FormattedTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void FormattedTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
var textBlock = d as TextBlock; var textBlock = d as TextBlock;
if (textBlock == null) return; if (textBlock == null) return;
var inline = (Inline)e.NewValue; var inline = (Inline)e.NewValue;
textBlock.Inlines.Clear(); textBlock.Inlines.Clear();
if (inline == null) return; if (inline == null) return;
textBlock.Inlines.Add(inline); textBlock.Inlines.Add(inline);
} }
#endregion #endregion
}
} }
}

View File

@@ -1,3 +1,7 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Globalization; using System.Globalization;
using Wox.Core.Resource; using Wox.Core.Resource;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
@@ -30,7 +34,7 @@ namespace PowerLauncher.ViewModel
_storage.Save(); _storage.Save();
} }
#region general #region general
private static Internationalization _translater => InternationalizationManager.Instance; private static Internationalization _translater => InternationalizationManager.Instance;

View File

@@ -1,4 +1,8 @@
namespace Wox.Plugin // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin
{ {
public class ActionContext public class ActionContext
{ {
@@ -8,8 +12,11 @@
public class SpecialKeyState public class SpecialKeyState
{ {
public bool CtrlPressed { get; set; } public bool CtrlPressed { get; set; }
public bool ShiftPressed { get; set; } public bool ShiftPressed { get; set; }
public bool AltPressed { get; set; } public bool AltPressed { get; set; }
public bool WinPressed { get; set; } public bool WinPressed { get; set; }
} }
} }

View File

@@ -1,4 +1,8 @@
namespace Wox.Plugin // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin
{ {
public static class AllowedLanguage public static class AllowedLanguage
{ {
@@ -18,4 +22,4 @@
|| language.ToUpper() == Executable.ToUpper(); || language.ToUpper() == Executable.ToUpper();
} }
} }
} }

View File

@@ -1,7 +1,9 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Windows;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Wox.Plugin namespace Wox.Plugin
@@ -16,4 +18,4 @@ namespace Wox.Plugin
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
} }
} }

View File

@@ -1,9 +1,12 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Windows.Input; using System.Windows.Input;
namespace Wox.Plugin namespace Wox.Plugin
{ {
public class ContextMenuResult public class ContextMenuResult
{ {
public string PluginName { get; set; } public string PluginName { get; set; }
@@ -28,4 +31,4 @@ namespace Wox.Plugin
return Title; return Title;
} }
} }
} }

View File

@@ -1,9 +1,14 @@
using System.Windows; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
namespace Wox.Plugin namespace Wox.Plugin
{ {
public delegate void WoxKeyDownEventHandler(WoxKeyDownEventArgs e); public delegate void WoxKeyDownEventHandler(WoxKeyDownEventArgs e);
public delegate void AfterWoxQueryEventHandler(WoxQueryEventArgs e); public delegate void AfterWoxQueryEventHandler(WoxQueryEventArgs e);
public delegate void ResultItemDropEventHandler(Result result, IDataObject dropObject, DragEventArgs e); public delegate void ResultItemDropEventHandler(Result result, IDataObject dropObject, DragEventArgs e);
@@ -11,6 +16,7 @@ namespace Wox.Plugin
public class WoxKeyDownEventArgs public class WoxKeyDownEventArgs
{ {
public string Query { get; set; } public string Query { get; set; }
public KeyEventArgs keyEventArgs { get; set; } public KeyEventArgs keyEventArgs { get; set; }
} }

View File

@@ -1,6 +1,9 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
namespace Wox.Plugin namespace Wox.Plugin
{ {

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Wox.Plugin.Features namespace Wox.Plugin.Features
{ {
@@ -6,4 +10,4 @@ namespace Wox.Plugin.Features
"and use Wox.Plugin.Feature.IContextMenu instead, " + "and use Wox.Plugin.Feature.IContextMenu instead, " +
"this method will be removed in v1.3.0")] "this method will be removed in v1.3.0")]
public interface IContextMenu { } public interface IContextMenu { }
} }

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Wox.Plugin.Features namespace Wox.Plugin.Features
{ {

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Wox.Plugin.Features namespace Wox.Plugin.Features
{ {
@@ -6,4 +10,4 @@ namespace Wox.Plugin.Features
"and use Wox.Plugin.Feature.IInstantQuery instead, " + "and use Wox.Plugin.Feature.IInstantQuery instead, " +
"this method will be removed in v1.3.0")] "this method will be removed in v1.3.0")]
public interface IInstantQuery { } public interface IInstantQuery { }
} }

View File

@@ -1,10 +1,15 @@
using System.Collections.Generic; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace Wox.Plugin namespace Wox.Plugin
{ {
public interface IPlugin public interface IPlugin
{ {
List<Result> Query(Query query); List<Result> Query(Query query);
void Init(PluginInitContext context); void Init(PluginInitContext context);
} }
} }

View File

@@ -1,4 +1,8 @@
using System.Collections.Generic; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace Wox.Plugin namespace Wox.Plugin
{ {
@@ -12,7 +16,7 @@ namespace Wox.Plugin
/// </summary> /// </summary>
/// <param name="query">query text</param> /// <param name="query">query text</param>
/// <param name="requery"> /// <param name="requery">
/// force requery By default, Wox will not fire query if your query is same with existing one. /// force requery By default, Wox will not fire query if your query is same with existing one.
/// Set this to true to force Wox requerying /// Set this to true to force Wox requerying
/// </param> /// </param>
void ChangeQuery(string query, bool requery = false); void ChangeQuery(string query, bool requery = false);
@@ -38,7 +42,7 @@ namespace Wox.Plugin
void SaveAppAllSettings(); void SaveAppAllSettings();
/// <summary> /// <summary>
/// Reloads any Plugins that have the /// Reloads any Plugins that have the
/// IReloadable implemented. It refreshes /// IReloadable implemented. It refreshes
/// Plugin's in memory data with new content /// Plugin's in memory data with new content
/// added by user. /// added by user.
@@ -73,7 +77,7 @@ namespace Wox.Plugin
string GetTranslation(string key); string GetTranslation(string key);
/// <summary> /// <summary>
/// Get all loaded plugins /// Get all loaded plugins
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
List<PluginPair> GetAllPlugins(); List<PluginPair> GetAllPlugins();

View File

@@ -1,11 +1,16 @@
using Microsoft.PowerToys.Settings.UI.Lib; // Copyright (c) Microsoft Corporation
using System.Windows.Controls; // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin
{ using System.Windows.Controls;
public interface ISettingProvider using Microsoft.PowerToys.Settings.UI.Lib;
{
Control CreateSettingPanel(); namespace Wox.Plugin
void UpdateSettings(PowerLauncherSettings settings); {
} public interface ISettingProvider
} {
Control CreateSettingPanel();
void UpdateSettings(PowerLauncherSettings settings);
}
}

View File

@@ -1,13 +1,17 @@
namespace Wox.Plugin // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin
{ {
/// <summary> /// <summary>
/// This interface is to indicate and allow plugins to reload their /// This interface is to indicate and allow plugins to reload their
/// in memory data cache or other mediums when user makes a new change /// in memory data cache or other mediums when user makes a new change
/// that is not immediately captured. For example, for BrowserBookmark and Program /// that is not immediately captured. For example, for BrowserBookmark and Program
/// plugin does not automatically detect when a user added a new bookmark or program, /// plugin does not automatically detect when a user added a new bookmark or program,
/// so this interface's function is exposed to allow user manually do the reloading after /// so this interface's function is exposed to allow user manually do the reloading after
/// those new additions. /// those new additions.
/// ///
/// The command that allows user to manual reload is exposed via Plugin.Sys, and /// The command that allows user to manual reload is exposed via Plugin.Sys, and
/// it will call the plugins that have implemented this interface. /// it will call the plugins that have implemented this interface.
/// </summary> /// </summary>

View File

@@ -1,4 +1,6 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin namespace Wox.Plugin
{ {

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -9,14 +13,23 @@ namespace Wox.Plugin
public class PluginMetadata : BaseModel public class PluginMetadata : BaseModel
{ {
private string _pluginDirectory; private string _pluginDirectory;
public string ID { get; set; } public string ID { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Author { get; set; } public string Author { get; set; }
public string Version { get; set; } public string Version { get; set; }
public string Language { get; set; } public string Language { get; set; }
public string Description { get; set; } public string Description { get; set; }
public string Website { get; set; } public string Website { get; set; }
public bool Disabled { get; set; } public bool Disabled { get; set; }
public string ExecuteFilePath { get; private set; } public string ExecuteFilePath { get; private set; }
public string ExecuteFileName { get; set; } public string ExecuteFileName { get; set; }
@@ -24,6 +37,7 @@ namespace Wox.Plugin
public string PluginDirectory public string PluginDirectory
{ {
get { return _pluginDirectory; } get { return _pluginDirectory; }
internal set internal set
{ {
_pluginDirectory = value; _pluginDirectory = value;
@@ -51,8 +65,10 @@ namespace Wox.Plugin
/// </summary> /// </summary>
[JsonIgnore] [JsonIgnore]
public long InitTime { get; set; } public long InitTime { get; set; }
[JsonIgnore] [JsonIgnore]
public long AvgQueryTime { get; set; } public long AvgQueryTime { get; set; }
[JsonIgnore] [JsonIgnore]
public int QueryCount { get; set; } public int QueryCount { get; set; }
} }

View File

@@ -1,8 +1,13 @@
namespace Wox.Plugin // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin
{ {
public class PluginPair public class PluginPair
{ {
public IPlugin Plugin { get; internal set; } public IPlugin Plugin { get; internal set; }
public PluginMetadata Metadata { get; internal set; } public PluginMetadata Metadata { get; internal set; }

View File

@@ -1,6 +1,10 @@
using System.Runtime.CompilerServices; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("PowerLauncher")] [assembly: InternalsVisibleTo("PowerLauncher")]
[assembly: InternalsVisibleTo("Wox")] [assembly: InternalsVisibleTo("Wox")]
[assembly: InternalsVisibleTo("Wox.Core")] [assembly: InternalsVisibleTo("Wox.Core")]
[assembly: InternalsVisibleTo("Wox.Test")] [assembly: InternalsVisibleTo("Wox.Test")]

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -28,7 +32,7 @@ namespace Wox.Plugin
/// <summary> /// <summary>
/// Search part of a query. /// Search part of a query.
/// This will not include action keyword if exclusive plugin gets it, otherwise it should be same as RawQuery. /// This will not include action keyword if exclusive plugin gets it, otherwise it should be same as RawQuery.
/// Since we allow user to switch a exclusive plugin to generic plugin, /// Since we allow user to switch a exclusive plugin to generic plugin,
/// so this property will always give you the "real" query part of the query /// so this property will always give you the "real" query part of the query
/// </summary> /// </summary>
public string Search { get; internal set; } public string Search { get; internal set; }

View File

@@ -1,161 +1,169 @@
using System; // Copyright (c) Microsoft Corporation
using System.Collections.Generic; // The Microsoft Corporation licenses this file to you under the MIT license.
using System.IO; // See the LICENSE file in the project root for more information.
using System.Windows.Media;
using System.Windows; using System;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Media;
namespace Wox.Plugin
{
public class Result
{
private string _title;
private ToolTipData _toolTipData;
private string _pluginDirectory;
private string _icoPath;
namespace Wox.Plugin
{
public class Result
{
private string _title;
private ToolTipData _toolTipData;
private string _pluginDirectory;
private string _icoPath;
public string Title public string Title
{ {
get { return _title; } get { return _title; }
set set
{ {
_title = value.Replace("\n", " "); _title = value.Replace("\n", " ");
} }
} }
public string SubTitle { get; set; }
public string SubTitle { get; set; }
public string Glyph { get; set; }
public string Glyph { get; set; }
public string FontFamily { get; set; } public string FontFamily { get; set; }
public Visibility ToolTipVisibility { get; set; } = Visibility.Collapsed; public Visibility ToolTipVisibility { get; set; } = Visibility.Collapsed;
public ToolTipData ToolTipData public ToolTipData ToolTipData
{ {
get get
{ {
return _toolTipData; return _toolTipData;
}
set
{
_toolTipData = value;
ToolTipVisibility = Visibility.Visible;
} }
}
set
{
_toolTipData = value;
ToolTipVisibility = Visibility.Visible;
}
}
/// <summary> /// <summary>
/// The text that will get displayed in the Search text box, when this item is selected in the result list. /// The text that will get displayed in the Search text box, when this item is selected in the result list.
/// </summary> /// </summary>
public string QueryTextDisplay { get; set; } public string QueryTextDisplay { get; set; }
public string IcoPath public string IcoPath
{ {
get { return _icoPath; } get { return _icoPath; }
set
{ set
if (!string.IsNullOrEmpty(PluginDirectory) && !Path.IsPathRooted(value)) {
{ if (!string.IsNullOrEmpty(PluginDirectory) && !Path.IsPathRooted(value))
_icoPath = Path.Combine(value, IcoPath); {
} _icoPath = Path.Combine(value, IcoPath);
else }
{ else
_icoPath = value; {
} _icoPath = value;
} }
} }
}
public delegate ImageSource IconDelegate();
public delegate ImageSource IconDelegate();
public IconDelegate Icon;
public IconDelegate Icon;
/// <summary>
/// return true to hide wox after select result /// <summary>
/// </summary> /// return true to hide wox after select result
public Func<ActionContext, bool> Action { get; set; } /// </summary>
public Func<ActionContext, bool> Action { get; set; }
public int Score { get; set; }
public int Score { get; set; }
/// <summary>
/// A list of indexes for the characters to be highlighted in Title /// <summary>
/// </summary> /// A list of indexes for the characters to be highlighted in Title
public IList<int> TitleHighlightData { get; set; } /// </summary>
public IList<int> TitleHighlightData { get; set; }
/// <summary>
/// A list of indexes for the characters to be highlighted in SubTitle /// <summary>
/// </summary> /// A list of indexes for the characters to be highlighted in SubTitle
public IList<int> SubTitleHighlightData { get; set; } /// </summary>
public IList<int> SubTitleHighlightData { get; set; }
/// <summary>
/// Only results that originQuery match with current query will be displayed in the panel /// <summary>
/// </summary> /// Only results that originQuery match with current query will be displayed in the panel
internal Query OriginQuery { get; set; } /// </summary>
internal Query OriginQuery { get; set; }
/// <summary>
/// Plugin directory /// <summary>
/// </summary> /// Plugin directory
public string PluginDirectory /// </summary>
{ public string PluginDirectory
get { return _pluginDirectory; } {
set get { return _pluginDirectory; }
{
_pluginDirectory = value; set
if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath)) {
{ _pluginDirectory = value;
IcoPath = Path.Combine(value, IcoPath); if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath))
} {
} IcoPath = Path.Combine(value, IcoPath);
} }
}
public override bool Equals(object obj) }
{
var r = obj as Result; public override bool Equals(object obj)
{
var equality = string.Equals(r?.Title, Title) && var r = obj as Result;
string.Equals(r?.SubTitle, SubTitle) &&
string.Equals(r?.IcoPath, IcoPath) && var equality = string.Equals(r?.Title, Title) &&
TitleHighlightData == r.TitleHighlightData && string.Equals(r?.SubTitle, SubTitle) &&
SubTitleHighlightData == r.SubTitleHighlightData; string.Equals(r?.IcoPath, IcoPath) &&
TitleHighlightData == r.TitleHighlightData &&
return equality; SubTitleHighlightData == r.SubTitleHighlightData;
}
return equality;
public override int GetHashCode() }
{
var hashcode = (Title?.GetHashCode() ?? 0) ^ public override int GetHashCode()
(SubTitle?.GetHashCode() ?? 0); {
return hashcode; var hashcode = (Title?.GetHashCode() ?? 0) ^
} (SubTitle?.GetHashCode() ?? 0);
return hashcode;
public override string ToString() }
{
return Title + SubTitle; public override string ToString()
} {
return Title + SubTitle;
[Obsolete("Use IContextMenu instead")] }
/// <summary>
/// Context menus associate with this result [Obsolete("Use IContextMenu instead")]
/// </summary> /// <summary>
public List<Result> ContextMenu { get; set; } /// Context menus associate with this result
/// </summary>
[Obsolete("Use Object initializers instead")] public List<Result> ContextMenu { get; set; }
public Result(string Title, string IcoPath, string SubTitle = null)
{ [Obsolete("Use Object initializers instead")]
this.Title = Title; public Result(string Title, string IcoPath, string SubTitle = null)
this.IcoPath = IcoPath; {
this.SubTitle = SubTitle; this.Title = Title;
} this.IcoPath = IcoPath;
this.SubTitle = SubTitle;
public Result() { } }
/// <summary> public Result() { }
/// Additional data associate with this result
/// </summary> /// <summary>
public object ContextData { get; set; } /// Additional data associate with this result
/// </summary>
/// <summary> public object ContextData { get; set; }
/// Plugin ID that generated this result
/// </summary> /// <summary>
public string PluginID { get; internal set; } /// Plugin ID that generated this result
} /// </summary>
} public string PluginID { get; internal set; }
}
}

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO; using System.IO;
using System.Windows; using System.Windows;

View File

@@ -1,3 +1,7 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@@ -7,8 +11,8 @@ namespace Wox.Plugin.SharedCommands
{ {
public static class SearchWeb public static class SearchWeb
{ {
/// <summary> /// <summary>
/// Opens search in a new browser. If no browser path is passed in then Chrome is used. /// Opens search in a new browser. If no browser path is passed in then Chrome is used.
/// Leave browser path blank to use Chrome. /// Leave browser path blank to use Chrome.
/// </summary> /// </summary>
public static void NewBrowserWindow(this string url, string browserPath) public static void NewBrowserWindow(this string url, string browserPath)
@@ -37,7 +41,7 @@ namespace Wox.Plugin.SharedCommands
} }
} }
/// <summary> /// <summary>
/// Opens search as a tab in the default browser chosen in Windows settings. /// Opens search as a tab in the default browser chosen in Windows settings.
/// </summary> /// </summary>
public static void NewTabInBrowser(this string url, string browserPath) public static void NewTabInBrowser(this string url, string browserPath)
@@ -53,6 +57,7 @@ namespace Wox.Plugin.SharedCommands
Process.Start(url); Process.Start(url);
} }
} }
// This error may be thrown for Process.Start(browserPath, url) // This error may be thrown for Process.Start(browserPath, url)
catch (System.ComponentModel.Win32Exception) catch (System.ComponentModel.Win32Exception)
{ {

View File

@@ -1,19 +1,23 @@
using System; // Copyright (c) Microsoft Corporation
using System.Collections.Generic; // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
namespace Wox.Plugin.SharedCommands namespace Wox.Plugin.SharedCommands
{ {
public static class ShellCommand public static class ShellCommand
{ {
public delegate bool EnumThreadDelegate(IntPtr hwnd, IntPtr lParam); public delegate bool EnumThreadDelegate(IntPtr hwnd, IntPtr lParam);
[DllImport("user32.dll")] static extern bool EnumThreadWindows(uint threadId, EnumThreadDelegate lpfn, IntPtr lParam); [DllImport("user32.dll")] static extern bool EnumThreadWindows(uint threadId, EnumThreadDelegate lpfn, IntPtr lParam);
[DllImport("user32.dll")] static extern int GetWindowText(IntPtr hwnd, StringBuilder lpString, int nMaxCount); [DllImport("user32.dll")] static extern int GetWindowText(IntPtr hwnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")] static extern int GetWindowTextLength(IntPtr hwnd); [DllImport("user32.dll")] static extern int GetWindowTextLength(IntPtr hwnd);
private static bool containsSecurityWindow; private static bool containsSecurityWindow;
@@ -29,6 +33,7 @@ namespace Wox.Plugin.SharedCommands
CheckSecurityWindow(); CheckSecurityWindow();
Thread.Sleep(25); Thread.Sleep(25);
} }
while (containsSecurityWindow) // while this process contains a "Windows Security" dialog, stay open while (containsSecurityWindow) // while this process contains a "Windows Security" dialog, stay open
{ {
containsSecurityWindow = false; containsSecurityWindow = false;

View File

@@ -1,10 +1,13 @@
using ControlzEx.Theming; // Copyright (c) Microsoft Corporation
using MahApps.Metro.Theming; // The Microsoft Corporation licenses this file to you under the MIT license.
using Microsoft.Win32; // See the LICENSE file in the project root for more information.
using System; using System;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using ControlzEx.Theming;
using MahApps.Metro.Theming;
using Microsoft.Win32;
namespace Wox.Plugin namespace Wox.Plugin
{ {
@@ -142,6 +145,7 @@ namespace Wox.Plugin
{ {
currentTheme = Theme.None; currentTheme = Theme.None;
} }
ThemeChanged?.Invoke(oldTheme, currentTheme); ThemeChanged?.Invoke(oldTheme, currentTheme);
} }

View File

@@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Wox.Plugin namespace Wox.Plugin
{ {
@@ -14,6 +18,7 @@ namespace Wox.Plugin
{ {
throw new ArgumentException("title cannot be null or empty", "title"); throw new ArgumentException("title cannot be null or empty", "title");
} }
Title = title; Title = title;
Text = text; Text = text;
} }

View File

@@ -68,5 +68,19 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\core\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj" /> <ProjectReference Include="..\..\..\core\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj" />
</ItemGroup> </ItemGroup>
<!--<ItemGroup>
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
<Link>StyleCop.json</Link>
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>-->
</Project> </Project>

View File

@@ -1,3 +1,7 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@@ -238,4 +242,4 @@ namespace Wox.Test
Assert.IsTrue(firstScore > secondScore); Assert.IsTrue(firstScore > secondScore);
} }
} }
} }

View File

@@ -1,4 +1,8 @@
using NUnit.Framework; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using NUnit.Framework;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;

View File

@@ -1,4 +1,8 @@
using Moq; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Moq;
using NUnit.Framework; using NUnit.Framework;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,4 +1,8 @@
using NUnit.Framework; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using NUnit.Framework;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Infrastructure.Exception; using Wox.Infrastructure.Exception;
@@ -11,7 +15,7 @@ namespace Wox.Test.Plugins
[Test] [Test]
public void PublicAPIIsNullTest() public void PublicAPIIsNullTest()
{ {
//Assert.Throws(typeof(WoxFatalException), () => PluginManager.Initialize(null)); // Assert.Throws(typeof(WoxFatalException), () => PluginManager.Initialize(null));
} }
} }
} }

View File

@@ -1,4 +1,8 @@
using NUnit.Framework; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using NUnit.Framework;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;

View File

@@ -1,4 +1,8 @@
using NUnit.Framework; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using NUnit.Framework;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;

View File

@@ -1,4 +1,8 @@
using NUnit.Framework; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using NUnit.Framework;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Search.Interop; using Microsoft.Search.Interop;

View File

@@ -1,4 +1,8 @@
using System.Collections.Generic; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Plugin; using Wox.Plugin;

View File

@@ -1,4 +1,8 @@
using NUnit.Framework; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using NUnit.Framework;
using PowerLauncher.ViewModel; using PowerLauncher.ViewModel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -41,7 +45,6 @@ namespace Wox.Test
}); });
rvm.SelectedItem = selectedItem; rvm.SelectedItem = selectedItem;
// Act // Act
rvm.SelectNextContextMenuItem(); rvm.SelectNextContextMenuItem();
@@ -62,7 +65,6 @@ namespace Wox.Test
}); });
rvm.SelectedItem = selectedItem; rvm.SelectedItem = selectedItem;
// Act // Act
rvm.SelectNextContextMenuItem(); rvm.SelectNextContextMenuItem();
@@ -91,7 +93,6 @@ namespace Wox.Test
}); });
rvm.SelectedItem = selectedItem; rvm.SelectedItem = selectedItem;
// Act // Act
rvm.SelectNextContextMenuItem(); rvm.SelectNextContextMenuItem();
rvm.SelectNextContextMenuItem(); rvm.SelectNextContextMenuItem();
@@ -115,7 +116,6 @@ namespace Wox.Test
}); });
rvm.SelectedItem = selectedItem; rvm.SelectedItem = selectedItem;
// Act // Act
rvm.SelectNextContextMenuItem(); rvm.SelectNextContextMenuItem();
rvm.SelectPreviousContextMenuItem(); rvm.SelectPreviousContextMenuItem();
@@ -137,7 +137,6 @@ namespace Wox.Test
}); });
rvm.SelectedItem = selectedItem; rvm.SelectedItem = selectedItem;
// Act // Act
rvm.SelectNextContextMenuItem(); rvm.SelectNextContextMenuItem();
bool isContextMenuItemSelected = rvm.IsContextMenuItemSelected(); bool isContextMenuItemSelected = rvm.IsContextMenuItemSelected();
@@ -159,7 +158,6 @@ namespace Wox.Test
}); });
rvm.SelectedItem = selectedItem; rvm.SelectedItem = selectedItem;
// Act // Act
rvm.SelectNextContextMenuItem(); rvm.SelectNextContextMenuItem();
rvm.SelectPreviousContextMenuItem(); rvm.SelectPreviousContextMenuItem();

View File

@@ -1,5 +1,9 @@
using NUnit.Framework; // Copyright (c) Microsoft Corporation
//using Wox.Plugin.Url; // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using NUnit.Framework;
// using Wox.Plugin.Url;
namespace Wox.Test namespace Wox.Test
{ {
@@ -9,24 +13,23 @@ namespace Wox.Test
[Test] [Test]
public void URLMatchTest() public void URLMatchTest()
{ {
//var plugin = new Main(); // var plugin = new Main();
//Assert.IsTrue(plugin.IsURL("http://www.google.com")); // Assert.IsTrue(plugin.IsURL("http://www.google.com"));
//Assert.IsTrue(plugin.IsURL("https://www.google.com")); // Assert.IsTrue(plugin.IsURL("https://www.google.com"));
//Assert.IsTrue(plugin.IsURL("http://google.com")); // Assert.IsTrue(plugin.IsURL("http://google.com"));
//Assert.IsTrue(plugin.IsURL("www.google.com")); // Assert.IsTrue(plugin.IsURL("www.google.com"));
//Assert.IsTrue(plugin.IsURL("google.com")); // Assert.IsTrue(plugin.IsURL("google.com"));
//Assert.IsTrue(plugin.IsURL("http://localhost")); // Assert.IsTrue(plugin.IsURL("http://localhost"));
//Assert.IsTrue(plugin.IsURL("https://localhost")); // Assert.IsTrue(plugin.IsURL("https://localhost"));
//Assert.IsTrue(plugin.IsURL("http://localhost:80")); // Assert.IsTrue(plugin.IsURL("http://localhost:80"));
//Assert.IsTrue(plugin.IsURL("https://localhost:80")); // Assert.IsTrue(plugin.IsURL("https://localhost:80"));
//Assert.IsTrue(plugin.IsURL("http://110.10.10.10")); // Assert.IsTrue(plugin.IsURL("http://110.10.10.10"));
//Assert.IsTrue(plugin.IsURL("110.10.10.10")); // Assert.IsTrue(plugin.IsURL("110.10.10.10"));
//Assert.IsTrue(plugin.IsURL("ftp://110.10.10.10")); // Assert.IsTrue(plugin.IsURL("ftp://110.10.10.10"));
// Assert.IsFalse(plugin.IsURL("wwww"));
//Assert.IsFalse(plugin.IsURL("wwww")); // Assert.IsFalse(plugin.IsURL("wwww.c"));
//Assert.IsFalse(plugin.IsURL("wwww.c")); // Assert.IsFalse(plugin.IsURL("wwww.c"));
//Assert.IsFalse(plugin.IsURL("wwww.c"));
} }
} }
} }

View File

@@ -57,5 +57,19 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
</ItemGroup> </ItemGroup>
<!--<ItemGroup>
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
<Link>StyleCop.json</Link>
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>-->
</Project> </Project>

View File

@@ -1,4 +1,8 @@
using System.Windows.Input; // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Windows.Input;
using NUnit.Framework; using NUnit.Framework;
using Wox.Plugin; using Wox.Plugin;
using PowerLauncher.ViewModel; using PowerLauncher.ViewModel;
@@ -39,7 +43,6 @@ namespace Wox.Test
} }
} }
[Test] [Test]
public void AnyVariable_MustCallOnPropertyChanged_WhenSet() public void AnyVariable_MustCallOnPropertyChanged_WhenSet()
{ {