-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
287 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,54 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
# This file is the top-most EditorConfig file | ||
root = true | ||
|
||
# Windows-style newlines with a newline ending every file | ||
# All Files | ||
[*] | ||
charset = utf-8 | ||
end_of_line = crlf | ||
indent_style = space | ||
indent_size = 4 | ||
insert_final_newline = false | ||
trim_trailing_whitespace = true | ||
|
||
# .NET Code files | ||
[*.{cs,csx,cake,vb}] | ||
indent_style = tab | ||
tab_width = 4 | ||
insert_final_newline = true | ||
|
||
# Visual Studio Solution Files | ||
[*.sln] | ||
indent_style = tab | ||
tab_width = 4 | ||
|
||
# Visual Studio XML Project Files | ||
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] | ||
indent_size = 2 | ||
|
||
# Various XML Configuration Files | ||
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}] | ||
indent_size = 2 | ||
|
||
# JSON Files | ||
[*.{json,json5}] | ||
indent_size = 2 | ||
|
||
# YAML Files | ||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
|
||
# Markdown Files | ||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
# Web Files | ||
[*.{htm,html,js,ts,tsx,css,sass,scss,less,svg,vue}] | ||
indent_size = 2 | ||
insert_final_newline = true | ||
|
||
# Batch Files | ||
[*.{cmd,bat}] | ||
|
||
# Bash Files | ||
[*.sh] | ||
end_of_line = lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
|
||
namespace Picton.Messaging.IntegrationTests | ||
{ | ||
public static class ConsoleUtils | ||
{ | ||
public static void CenterConsole() | ||
{ | ||
var hWin = NativeMethods.GetConsoleWindow(); | ||
if (hWin == IntPtr.Zero) return; | ||
|
||
var monitor = NativeMethods.MonitorFromWindow(hWin, NativeMethods.MONITOR_DEFAULT_TO_NEAREST); | ||
if (monitor == IntPtr.Zero) return; | ||
|
||
var monitorInfo = new NativeMethods.NativeMonitorInfo(); | ||
NativeMethods.GetMonitorInfo(monitor, monitorInfo); | ||
|
||
NativeMethods.GetWindowRect(hWin, out NativeMethods.NativeRectangle consoleInfo); | ||
|
||
var monitorWidth = monitorInfo.Monitor.Right - monitorInfo.Monitor.Left; | ||
var monitorHeight = monitorInfo.Monitor.Bottom - monitorInfo.Monitor.Top; | ||
|
||
var consoleWidth = consoleInfo.Right - consoleInfo.Left; | ||
var consoleHeight = consoleInfo.Bottom - consoleInfo.Top; | ||
|
||
var left = monitorInfo.Monitor.Left + (monitorWidth - consoleWidth) / 2; | ||
var top = monitorInfo.Monitor.Top + (monitorHeight - consoleHeight) / 2; | ||
|
||
NativeMethods.MoveWindow(hWin, left, top, consoleWidth, consoleHeight, false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Picton.Messaging.IntegrationTests | ||
{ | ||
public static class NativeMethods | ||
{ | ||
public const Int32 MONITOR_DEFAULT_TO_PRIMARY = 0x00000001; | ||
public const Int32 MONITOR_DEFAULT_TO_NEAREST = 0x00000002; | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
public static extern IntPtr GetConsoleWindow(); | ||
|
||
[DllImport("user32.dll", SetLastError = true)] | ||
public static extern bool GetWindowRect(IntPtr hWnd, out NativeRectangle rc); | ||
|
||
[DllImport("user32.dll", SetLastError = true)] | ||
public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int w, int h, bool repaint); | ||
|
||
[DllImport("user32.dll")] | ||
public static extern IntPtr MonitorFromWindow(IntPtr handle, Int32 flags); | ||
|
||
[DllImport("user32.dll")] | ||
public static extern Boolean GetMonitorInfo(IntPtr hMonitor, NativeMonitorInfo lpmi); | ||
|
||
[Serializable, StructLayout(LayoutKind.Sequential)] | ||
public struct NativeRectangle | ||
{ | ||
public Int32 Left; | ||
public Int32 Top; | ||
public Int32 Right; | ||
public Int32 Bottom; | ||
|
||
public NativeRectangle(Int32 left, Int32 top, Int32 right, Int32 bottom) | ||
{ | ||
this.Left = left; | ||
this.Top = top; | ||
this.Right = right; | ||
this.Bottom = bottom; | ||
} | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] | ||
public sealed class NativeMonitorInfo | ||
{ | ||
public Int32 Size = Marshal.SizeOf(typeof(NativeMonitorInfo)); | ||
public NativeRectangle Monitor; | ||
public NativeRectangle Work; | ||
public Int32 Flags; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.