diff --git a/Sources/DesktopManager.Example/Helpers.cs b/Sources/DesktopManager.Example/Helpers.cs
index eb7b99f..c018f82 100644
--- a/Sources/DesktopManager.Example/Helpers.cs
+++ b/Sources/DesktopManager.Example/Helpers.cs
@@ -2,7 +2,15 @@
using Spectre.Console;
namespace DesktopManager.Example;
+///
+/// Provides helper methods for displaying properties and adding lines to the console.
+///
internal class Helpers {
+ ///
+ /// Displays the properties of an object in the console.
+ ///
+ /// The description of the object being analyzed.
+ /// The object whose properties are to be displayed.
public static void ShowProperties(string analysisOf, object obj) {
Console.WriteLine("----");
Console.WriteLine($"Analysis of {analysisOf}:");
@@ -20,18 +28,39 @@ public static void ShowProperties(string analysisOf, object obj) {
}
}
+ ///
+ /// Adds a line to the console with a specified text and string value.
+ ///
+ /// The text to display.
+ /// The string value to display.
public static void AddLine(string text, string value) {
AnsiConsole.Write(new Rule($"[blue]{text}[/]: [yellow]{value}[/]"));
}
+ ///
+ /// Adds a line to the console with a specified text and integer value.
+ ///
+ /// The text to display.
+ /// The integer value to display.
public static void AddLine(string text, int value) {
AnsiConsole.Write(new Rule($"[blue]{text}[/]: [yellow]{value}[/]"));
}
+ ///
+ /// Adds a line to the console with a specified text and unsigned integer value.
+ ///
+ /// The text to display.
+ /// The unsigned integer value to display.
public static void AddLine(string text, uint value) {
AnsiConsole.Write(new Rule($"[blue]{text}[/]: [yellow]{value}[/]"));
}
+ ///
+ /// Displays the properties of an object or a collection of objects in a table format.
+ ///
+ /// The description of the object being analyzed.
+ /// The object or collection of objects whose properties are to be displayed.
+ /// Indicates whether to display properties per property.
public static void ShowPropertiesTable(string analysisOf, object objs, bool perProperty = false) {
var table = new Table();
table.Border(TableBorder.Rounded);
@@ -59,6 +88,12 @@ public static void ShowPropertiesTable(string analysisOf, object objs, bool perP
AnsiConsole.Write(panel);
}
+ ///
+ /// Adds the properties of an object to a table.
+ ///
+ /// The table to which properties are added.
+ /// The prefix for the property names.
+ /// The object whose properties are to be added.
private static void AddPropertiesToTable(Table table, string prefix, object obj) {
if (obj == null) {
return;
diff --git a/Sources/DesktopManager.Example/Program.cs b/Sources/DesktopManager.Example/Program.cs
index a46af9e..b251030 100644
--- a/Sources/DesktopManager.Example/Program.cs
+++ b/Sources/DesktopManager.Example/Program.cs
@@ -1,33 +1,43 @@
-using DesktopManager;
-
-namespace DesktopManagerSample {
+namespace DesktopManager.Example {
+ ///
+ /// The main class for the DesktopManager example application.
+ ///
class Program {
+ ///
+ /// The main entry point for the application.
+ ///
+ /// The command-line arguments.
static void Main(string[] args) {
-
Monitors monitor = new Monitors();
- var getMonitors = monitor.GetMonitors();
+ // Get all monitors
+ var getMonitors = monitor.GetMonitors();
Helpers.AddLine("Number of monitors", getMonitors.Count);
Helpers.ShowPropertiesTable("GetMonitors() ", getMonitors);
+ // Get connected monitors
var getMonitorsConnected = monitor.GetMonitorsConnected();
Helpers.AddLine("Number of monitors (connected):", getMonitorsConnected.Count);
Helpers.ShowPropertiesTable("GetMonitorsConnected() ", getMonitorsConnected);
+ // Get all display devices
var listDisplayDevices = monitor.DisplayDevicesAll();
Console.WriteLine("Count DisplayDevicesAll: " + listDisplayDevices.Count);
Helpers.ShowPropertiesTable("DisplayDevicesAll()", listDisplayDevices);
Console.WriteLine("======");
+ // Get connected display devices
var getDisplayDevices = monitor.DisplayDevicesConnected();
Console.WriteLine("Count DisplayDevicesConnected: " + getDisplayDevices.Count);
Helpers.ShowPropertiesTable("DisplayDevicesConnected()", getDisplayDevices);
Console.WriteLine("======");
+ // Get wallpaper position for the first monitor
Console.WriteLine("Wallpaper Position (only first monitor): " + monitor.GetWallpaperPosition());
+ // Iterate through connected monitors
foreach (var device in monitor.GetMonitorsConnected()) {
Console.WriteLine("3==================================");
Console.WriteLine("MonitorID: " + device.DeviceId);
@@ -41,7 +51,6 @@ static void Main(string[] args) {
var position1 = device.GetMonitorPosition();
Helpers.ShowPropertiesTable($"Position before move {device.DeviceId}", position1);
-
}
// Set monitor position
@@ -60,8 +69,8 @@ static void Main(string[] args) {
testPosition = monitor.GetMonitorPosition(@"\\?\DISPLAY#GSM5BBF#5&22b00b5d&0&UID4352#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}");
Helpers.ShowPropertiesTable("Position after move", testPosition);
+ // Set wallpaper for the first monitor
monitor.SetWallpaper(1, @"C:\Users\przemyslaw.klys\Downloads\CleanupMonster2.jpg");
-
}
}
}
\ No newline at end of file