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,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.Net;
@@ -40,6 +44,7 @@ namespace PowerLauncher.Helper
public override string ContentType
{
get { return m_contentType; }
set
{
throw new NotSupportedException();
@@ -49,6 +54,7 @@ namespace PowerLauncher.Helper
public override long ContentLength
{
get { return m_data.Length; }
set
{
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 NLog;
using Wox.Infrastructure;
@@ -22,15 +26,15 @@ namespace PowerLauncher.Helper
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
{
//handle non-ui thread exceptions
// handle non-ui thread exceptions
Report((Exception)e?.ExceptionObject);
}
public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
//handle ui thread exceptions
// handle ui thread exceptions
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;
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
// 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 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.Specialized;
using PowerLauncher.ViewModel;
namespace PowerLauncher.Helper
{
@@ -42,4 +46,4 @@ namespace PowerLauncher.Helper
}
}
}
}

View File

@@ -1,17 +1,18 @@
using System;
using System.Collections;
// 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.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using System.IO.Pipes;
using System.Runtime.Serialization.Formatters;
using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using static PowerLauncher.Helper.WindowsInteropHelper;
// http://blogs.microsoft.co.il/arik/2010/05/28/wpf-single-instance-application/
@@ -99,7 +100,6 @@ namespace PowerLauncher.Helper
XBUTTONDBLCLK = 0x020D,
MOUSEHWHEEL = 0x020E,
CAPTURECHANGED = 0x0215,
ENTERSIZEMOVE = 0x0231,
@@ -131,7 +131,7 @@ namespace PowerLauncher.Helper
// This is the hard-coded message value used by WinForms for Shell_NotifyIcon.
// It's relatively safe to reuse.
TRAYMOUSEMESSAGE = 0x800, //WM_USER + 1024
TRAYMOUSEMESSAGE = 0x800, // WM_USER + 1024
APP = 0x8000
}
@@ -146,7 +146,6 @@ namespace PowerLauncher.Helper
[DllImport("shell32.dll", EntryPoint = "CommandLineToArgvW", CharSet = CharSet.Unicode)]
private static extern IntPtr _CommandLineToArgvW([MarshalAs(UnmanagedType.LPWStr)] string cmdLine, out int numArgs);
[DllImport("kernel32.dll", EntryPoint = "LocalFree", SetLastError = true)]
internal static extern IntPtr _LocalFree(IntPtr hMem);
@@ -201,7 +200,6 @@ namespace PowerLauncher.Helper
}
finally
{
IntPtr p = _LocalFree(argv);
// Otherwise LocalFree failed.
// Assert.AreEqual(IntPtr.Zero, p);
@@ -216,7 +214,7 @@ namespace PowerLauncher.Helper
}
/// <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.
/// </summary>
/// <remarks>
@@ -256,7 +254,7 @@ namespace PowerLauncher.Helper
#region Public Methods
/// <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.
/// </summary>
/// <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);
// 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;
singleInstanceMutex = new Mutex(true, applicationIdentifier, out firstInstance);
if (firstInstance)
@@ -309,12 +307,11 @@ namespace PowerLauncher.Helper
}
catch (NotSupportedException)
{
// The application was clickonce deployed
// Clickonce deployed apps cannot receive traditional commandline arguments
// 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
// shared location
// 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
// shared location
string appFolderPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), uniqueApplicationName);
@@ -345,7 +342,7 @@ namespace PowerLauncher.Helper
}
/// <summary>
/// Creates a remote server pipe for communication.
/// Creates a remote server pipe for communication.
/// Once receives signal from client, will activate first instance.
/// </summary>
/// <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.Runtime.InteropServices;
using System.Text;
@@ -12,13 +16,13 @@ namespace PowerLauncher.Helper
{
public static class WindowsInteropHelper
{
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 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 static IntPtr _hwnd_shell;
private static IntPtr _hwnd_desktop;
//Accessors for shell and desktop handlers
//Will set the variables once and then will return them
// Accessors for shell and desktop handlers
// Will set the variables once and then will return them
private static IntPtr HWND_SHELL
{
get
@@ -101,19 +105,19 @@ namespace PowerLauncher.Helper
public static bool IsWindowFullscreen()
{
//get current active window
// get current active window
IntPtr hWnd = NativeMethods.GetForegroundWindow();
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)))
{
StringBuilder sb = new StringBuilder(256);
_ = NativeMethods.GetClassName(hWnd, sb, sb.Capacity);
string windowClass = sb.ToString();
//for Win+Tab (Flip3D)
// for Win+Tab (Flip3D)
if (windowClass == WINDOW_CLASS_WINTAB)
{
return false;
@@ -122,13 +126,13 @@ namespace PowerLauncher.Helper
RECT 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)
{
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)
{
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));
}
[StructLayout(LayoutKind.Sequential)]
internal struct RECT
{
@@ -195,4 +198,4 @@ namespace PowerLauncher.Helper
public int Bottom;
}
}
}
}