Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("2026.11.11.0")]
[assembly: AssemblyFileVersion("2026.11.11.0")]
[assembly: AssemblyVersion("2026.11.14.0")]
[assembly: AssemblyFileVersion("2026.11.14.0")]
16 changes: 16 additions & 0 deletions Source/NETworkManager.Settings/CommandLineInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ public class CommandLineInfo
/// </summary>
public ApplicationName Application { get; set; } = ApplicationName.None;

/// <summary>
/// Indicates if the application should start in screenshot mode (fixed window size, centered, not resizable,
/// window position not loaded or saved) to take consistent screenshots for the documentation
/// </summary>
public bool Screenshot { get; set; }

/// <summary>
/// Width of the window in screenshot mode (device-independent pixels, scaled with the Windows display scaling)
/// </summary>
public int ScreenshotWidth { get; set; } = CommandLineManager.ScreenshotDefaultWidth;

/// <summary>
/// Height of the window in screenshot mode (device-independent pixels, scaled with the Windows display scaling)
/// </summary>
public int ScreenshotHeight { get; set; } = CommandLineManager.ScreenshotDefaultHeight;

/// <summary>
/// Wrong parameter(s) detected in the command line to display in the help dialog
/// </summary>
Expand Down
65 changes: 65 additions & 0 deletions Source/NETworkManager.Settings/CommandLineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ static CommandLineManager()
WrongParameterDetected(parameters);
return;
}
} // Screenshot mode (optional size, e.g. --screenshot:1280x800)
else if (param[0].Equals(ParameterScreenshot, StringComparison.InvariantCultureIgnoreCase))
{
Current.Screenshot = true;

if (param.Length > 1)
{
if (TryParseScreenshotSize(param[1], out var width, out var height))
{
Current.ScreenshotWidth = width;
Current.ScreenshotHeight = height;
}
else
{
WrongParameterDetected(parameters);
return;
}
}
}
else
{
Expand Down Expand Up @@ -84,13 +102,60 @@ static CommandLineManager()
public static string ParameterAutostart => $"{ParameterIdentifier}autostart";
public static string ParameterRestartPid => $"{ParameterIdentifier}restart-pid";

// Documentation (screenshots)
public static string ParameterScreenshot => $"{ParameterIdentifier}screenshot";

/// <summary>
/// Default window width in screenshot mode (16:10, readable when scaled to the width of the documentation).
/// </summary>
public const int ScreenshotDefaultWidth = 1280;

/// <summary>
/// Default window height in screenshot mode.
/// </summary>
public const int ScreenshotDefaultHeight = 800;

// Minimum size of the main window (MinWidth / MinHeight in MainWindow.xaml)
private const int ScreenshotMinWidth = 800;
private const int ScreenshotMinHeight = 600;
private const int ScreenshotMaxSize = 7680;

public static CommandLineInfo Current { get; set; }

public static string GetParameterWithSplitIdentifier(string parameter)
{
return $"{parameter}{ValueSplitIdentifier}";
}

/// <summary>
/// Parses the window size of the screenshot mode (<c>WIDTHxHEIGHT</c>, e.g. <c>1280x800</c>).
/// </summary>
/// <param name="value">Size to parse.</param>
/// <param name="width">Parsed width.</param>
/// <param name="height">Parsed height.</param>
/// <returns><c>true</c> if the size is valid and not smaller than the minimum size of the main window.</returns>
public static bool TryParseScreenshotSize(string value, out int width, out int height)
{
width = 0;
height = 0;

var size = value.Split('x', 'X');

if (size.Length != 2 ||
!int.TryParse(size[0], out var parsedWidth) ||
!int.TryParse(size[1], out var parsedHeight))
return false;

if (parsedWidth is < ScreenshotMinWidth or > ScreenshotMaxSize ||
parsedHeight is < ScreenshotMinHeight or > ScreenshotMaxSize)
return false;

width = parsedWidth;
height = parsedHeight;

return true;
}

private static void WrongParameterDetected(string[] parameters)
{
Current.WrongParameter = string.Join(" ", parameters);
Expand Down
34 changes: 34 additions & 0 deletions Source/NETworkManager.Tests/Settings/CommandLineManagerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using NETworkManager.Settings;
using Xunit;

namespace NETworkManager.Tests.Settings;

public class CommandLineManagerTests
{
[Theory]
[InlineData("1280x800", 1280, 800)]
[InlineData("1200X800", 1200, 800)]
[InlineData("800x600", 800, 600)]
public void ParsesTheScreenshotSize(string value, int expectedWidth, int expectedHeight)
{
Assert.True(CommandLineManager.TryParseScreenshotSize(value, out var width, out var height));
Assert.Equal(expectedWidth, width);
Assert.Equal(expectedHeight, height);
}

[Theory]
[InlineData("")]
[InlineData("1280")]
[InlineData("1280x")]
[InlineData("x800")]
[InlineData("1280x800x600")]
[InlineData("abcxdef")]
[InlineData("799x600")]
[InlineData("800x599")]
[InlineData("-1280x800")]
[InlineData("7681x800")]
public void RejectsAnInvalidScreenshotSize(string value)
{
Assert.False(CommandLineManager.TryParseScreenshotSize(value, out _, out _));
}
}
45 changes: 44 additions & 1 deletion Source/NETworkManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ public MainWindow()
InitializeComponent();
DataContext = this;

if (CommandLineManager.Current.Screenshot)
ConfigureScreenshotMode();

// Language metadata
LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
new FrameworkPropertyMetadata(
Expand Down Expand Up @@ -433,6 +436,27 @@ public MainWindow()
_isLoading = false;
}

/// <summary>
/// Screenshot mode (<c>--screenshot</c>): fixed window size (device-independent pixels, e.g. 1280 x 800 is
/// 1920 x 1200 pixels with 150 % display scaling), centered on the screen, not resizable and not maximizable.
/// The saved window position is neither loaded nor overwritten. The window always shows the glow of an active
/// window, so a screenshot tool that takes the focus doesn't change the look.
/// </summary>
private void ConfigureScreenshotMode()
{
SaveWindowPosition = false;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
WindowState = WindowState.Normal;

Width = MinWidth = MaxWidth = CommandLineManager.Current.ScreenshotWidth;
Height = MinHeight = MaxHeight = CommandLineManager.Current.ScreenshotHeight;

SetResourceReference(BackgroundProperty, AppearanceManager.SurfaceWindowBrushKey);
SetResourceReference(NonActiveWindowTitleBrushProperty, AppearanceManager.SurfaceWindowBrushKey);

Log.Info($"Screenshot mode: {Width} x {Height}");
}

private void MetroMainWindow_ContentRendered(object sender, EventArgs e)
{
WelcomeThenLoadAsync();
Expand Down Expand Up @@ -1548,6 +1572,13 @@ private void NotifyIcon_Click(object sender, EventArgs e)

private void MetroWindowMain_StateChanged(object sender, EventArgs e)
{
// Keep the fixed size in screenshot mode (e.g. double-click on the title bar)
if (CommandLineManager.Current.Screenshot && WindowState == WindowState.Maximized)
{
WindowState = WindowState.Normal;
return;
}

if (WindowState != WindowState.Minimized)
return;

Expand Down Expand Up @@ -1659,12 +1690,24 @@ private void CloseApplication()
public void RestartApplication(bool asAdmin = false)
{
ExternalProcessStarter.RunProcess(ConfigurationManager.Current.ApplicationFullName,
$"{CommandLineManager.GetParameterWithSplitIdentifier(CommandLineManager.ParameterRestartPid)}{Environment.ProcessId} {CommandLineManager.GetParameterWithSplitIdentifier(CommandLineManager.ParameterApplication)}{SelectedApplication.Name}",
$"{CommandLineManager.GetParameterWithSplitIdentifier(CommandLineManager.ParameterRestartPid)}{Environment.ProcessId} {CommandLineManager.GetParameterWithSplitIdentifier(CommandLineManager.ParameterApplication)}{SelectedApplication.Name}{GetScreenshotParameter()}",
asAdmin);

CloseApplication();
}

/// <summary>
/// Keeps the screenshot mode after a restart (e.g. language changed, restart as administrator).
/// </summary>
private static string GetScreenshotParameter()
{
if (!CommandLineManager.Current.Screenshot)
return string.Empty;

return
$" {CommandLineManager.GetParameterWithSplitIdentifier(CommandLineManager.ParameterScreenshot)}{CommandLineManager.Current.ScreenshotWidth}x{CommandLineManager.Current.ScreenshotHeight}";
}

public ICommand ApplicationListMouseEnterCommand => new RelayCommand(_ => ApplicationListMouseEnterAction());

private void ApplicationListMouseEnterAction()
Expand Down
1 change: 1 addition & 0 deletions Website/docs/changelog/next-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Release date: **xx.xx.2026**
- A dragged-out tab (e.g. **Remote Desktop**, **PuTTY**) can be dropped anywhere on the tab bar of another window of the same tool, not only over the existing tabs. While dragging, a highlighted slot shows where it can be dropped. [#3702](https://github.com/BornToBeRoot/NETworkManager/pull/3702)
- New setting **Accent glow** in [Settings > Appearance](../settings/appearance.md#accent-glow): a subtle glow of the accent color in the top left corner of the windows (`Off`, `Subtle`, `Medium` (default), `Strong`). [#3702](https://github.com/BornToBeRoot/NETworkManager/pull/3702)
- New themes **Black**, **Midnight**, **Steel**, **Indigo**, **Mist**, **Soft** and **Paper** and new accent colors **Sky**, **Ocean**, **Mint**, **Rose**, **Coral**, **Gold**, **Lavender**, **Slate** and **Graphite** in [Settings > Appearance](../settings/appearance.md#theme). All accents work with every theme. [#3702](https://github.com/BornToBeRoot/NETworkManager/pull/3702)
- New [command line argument](../commandline-arguments.md#--screenshot) `--screenshot` to start the application with a fixed window size (default `1280x800`, centered, not resizable) for consistent screenshots, e.g. `NETworkManager.exe --screenshot:1200x800`.
- ARM64 builds are now available. [#3538](https://github.com/BornToBeRoot/NETworkManager/issues/3538)

**Run command**
Expand Down
25 changes: 25 additions & 0 deletions Website/docs/commandline-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@ Start a specific application on startup.
NETworkManager.exe --application:PingMonitor
```

### `--screenshot`

Starts the application in screenshot mode to take consistent screenshots, e.g. for the documentation:

- The window has a fixed size (default `1280x800`) and is centered on the primary screen. It can't be resized or maximized.
- The size is in device-independent pixels and is scaled with the Windows display scaling. For example, `1280x800` is `1920x1200` pixels with `150 %` scaling, which looks sharp on high-resolution screens.
- The saved window position and size are not loaded and not overwritten.
- The window always looks like an active window (accent glow), even if the screenshot tool takes the focus.

Optionally, the size can be set with `--screenshot:WIDTHxHEIGHT` (minimum `800x600`).

**Example:**

```powershell
NETworkManager.exe --screenshot
NETworkManager.exe --screenshot:1200x800
NETworkManager.exe --screenshot --application:IPScanner
```

:::note

If NETworkManager is already running (and multiple instances are not allowed), the running instance is shown instead. Close it first.

:::

## Internal

Internally used command line arguments.
Expand Down
Loading