diff --git a/PeyrSharp.Core/PeyrSharp.Core.csproj b/PeyrSharp.Core/PeyrSharp.Core.csproj
index 5950f56..4a27ea5 100644
--- a/PeyrSharp.Core/PeyrSharp.Core.csproj
+++ b/PeyrSharp.Core/PeyrSharp.Core.csproj
@@ -4,7 +4,7 @@
net5.0;net6.0;net7.0
True
PeyrSharp.Core
- 1.8.0.2308
+ 1.9.0.2309
Devyus
Core methods and features of PeyrSharp.
© 2023
@@ -16,10 +16,7 @@
NUGET_README.md
MIT
True
- - Added Save() method in XmlHelper (#126)
-- Added Load() method in XmlHelper (#127)
-- Added Save() method in JsonHelper (#128)
-- Added Load() method in JsonHelper (#129)
+
@@ -34,8 +31,8 @@
-
-
+
+
\ No newline at end of file
diff --git a/PeyrSharp.Enums/PeyrSharp.Enums.csproj b/PeyrSharp.Enums/PeyrSharp.Enums.csproj
index f338582..1952941 100644
--- a/PeyrSharp.Enums/PeyrSharp.Enums.csproj
+++ b/PeyrSharp.Enums/PeyrSharp.Enums.csproj
@@ -11,7 +11,7 @@
https://peyrsharp.leocorporation.dev/
https://github.com/DevyusCode/PeyrSharp
enums;c-sharp;dotnet;vb;peyrsharp;leo corp
- 1.8.0.2308
+ 1.9.0.2309
True
logo.png
NUGET_README.md
diff --git a/PeyrSharp.Env/PeyrSharp.Env.csproj b/PeyrSharp.Env/PeyrSharp.Env.csproj
index 5d05c66..34f3dfd 100644
--- a/PeyrSharp.Env/PeyrSharp.Env.csproj
+++ b/PeyrSharp.Env/PeyrSharp.Env.csproj
@@ -4,7 +4,7 @@
net5.0;net6.0;net7.0
True
PeyrSharp.Env
- 1.8.0.2308
+ 1.9.0.2309
Devyus
Environment-related methods of PeyrSharp.
© 2023
@@ -16,7 +16,8 @@
NUGET_README.md
MIT
True
-
+ - Added Supported OS attribute (#137)
+- Added CurrentTheme property (#138)
@@ -31,6 +32,7 @@
-
+
+
\ No newline at end of file
diff --git a/PeyrSharp.Env/Sys.cs b/PeyrSharp.Env/Sys.cs
index dc49080..18ea05b 100644
--- a/PeyrSharp.Env/Sys.cs
+++ b/PeyrSharp.Env/Sys.cs
@@ -21,6 +21,7 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
+using Microsoft.Win32;
using PeyrSharp.Enums;
using System;
using System.Collections.Generic;
@@ -32,7 +33,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System.Runtime.Versioning;
using System.Text.Json;
using System.Threading.Tasks;
-using static System.Net.Mime.MediaTypeNames;
namespace PeyrSharp.Env
{
@@ -150,11 +150,23 @@ public static bool IsProcessRunning(string processName)
///
/// The PackageFamilyName property.
/// The Application Id property in the UWP AppxManifest.xml file.
+ [SupportedOSPlatform("windows")]
public static void LaunchUWPApp(string packageFamilyName, string applicationID)
{
Process.Start("explorer.exe", $@"shell:appsFolder\{packageFamilyName}!{applicationID}"); // Synthax to launch UWP apps
}
+ ///
+ /// Launches an UWP application using information from a object.
+ ///
+ /// The UWP application to launch.
+ [SupportedOSPlatform("windows")]
+ public static void LaunchUWPApp(UwpApp uwpApp)
+ {
+ string[] info = uwpApp.AppID.Split("!");
+ LaunchUWPApp(info[0], info[1]);
+ }
+
///
/// Executes a program in administrator mode.
///
@@ -229,6 +241,28 @@ public static void ExecuteAsAdmin(string filename)
/// The name of the current computer.
public static string ComputerName => Environment.MachineName;
+ ///
+ /// Gets the current theme. Only works on Windows 10/11.
+ ///
+ [SupportedOSPlatform("windows")]
+ public static SystemThemes CurrentTheme
+ {
+ get
+ {
+ if (CurrentWindowsVersion != WindowsVersion.Windows10 && CurrentWindowsVersion != WindowsVersion.Windows11)
+ {
+ return SystemThemes.Unknown; // Avoid errors on older OSs
+ }
+ var t = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "SystemUsesLightTheme", "1");
+ return t switch
+ {
+ 0 => SystemThemes.Dark,
+ 1 => SystemThemes.Light,
+ _ => SystemThemes.Unknown
+ }; // Return
+ }
+ }
+
///
/// Terminates a process with the specified process ID.
///
diff --git a/PeyrSharp.Exceptions/PeyrSharp.Exceptions.csproj b/PeyrSharp.Exceptions/PeyrSharp.Exceptions.csproj
index 5885b1e..13a2915 100644
--- a/PeyrSharp.Exceptions/PeyrSharp.Exceptions.csproj
+++ b/PeyrSharp.Exceptions/PeyrSharp.Exceptions.csproj
@@ -6,7 +6,7 @@
enable
True
PeyrSharp.Exceptions
- 1.8.0.2308
+ 1.9.0.2309
Devyus
Exceptions of PeyrSharp.
© 2023
diff --git a/PeyrSharp.Extensions/PeyrSharp.Extensions.csproj b/PeyrSharp.Extensions/PeyrSharp.Extensions.csproj
index e432aee..8e80622 100644
--- a/PeyrSharp.Extensions/PeyrSharp.Extensions.csproj
+++ b/PeyrSharp.Extensions/PeyrSharp.Extensions.csproj
@@ -4,7 +4,7 @@
net5.0;net6.0;net7.0
True
PeyrSharp.Extensions
- 1.8.0.2308
+ 1.9.0.2309
Devyus
Extensions methods of PeyrSharp.
© 2023
@@ -16,7 +16,8 @@
NUGET_README.md
MIT
True
-
+ - Added ToLowerAt(s) (#136)
+- Added ToLowerAt(str, r) (#136)
@@ -31,7 +32,7 @@
-
+
\ No newline at end of file
diff --git a/PeyrSharp.Extensions/StringExtensions.cs b/PeyrSharp.Extensions/StringExtensions.cs
index ddf5013..586500e 100644
--- a/PeyrSharp.Extensions/StringExtensions.cs
+++ b/PeyrSharp.Extensions/StringExtensions.cs
@@ -184,6 +184,21 @@ public static string DecryptAes(this string encrypted, string key)
/// The input string with the first letter uppercased.
public static string ToUpperAt(this string s) => string.IsNullOrEmpty(s) ? s : char.ToUpper(s[0]) + s[1..];
+ ///
+ /// Returns a new in which the characters in a specified range of the current are converted to lowercase.
+ ///
+ /// The to modify.
+ /// The range of characters to convert to lowercase.
+ /// A that is equivalent to the current , but with the characters in the specified range converted to lowercase.
+ public static string ToLowerAt(this string str, Range r) => str[..r.Start.Value] + str.Substring(r.Start.Value, r.End.Value - r.Start.Value + 1).ToLower() + str[(r.End.Value + 1)..];
+
+ ///
+ /// Uppercases the first letter of a string.
+ ///
+ /// The string to capitalize.
+ /// The input string with the first letter lowercased.
+ public static string ToLowerAt(this string s) => string.IsNullOrEmpty(s) ? s : char.ToLower(s[0]) + s[1..];
+
///
/// Reverses a .
///
diff --git a/PeyrSharp.UiHelpers/PeyrSharp.UiHelpers.csproj b/PeyrSharp.UiHelpers/PeyrSharp.UiHelpers.csproj
index 51a5d48..95c91b7 100644
--- a/PeyrSharp.UiHelpers/PeyrSharp.UiHelpers.csproj
+++ b/PeyrSharp.UiHelpers/PeyrSharp.UiHelpers.csproj
@@ -8,7 +8,7 @@
true
True
PeyrSharp.UiHelpers
- 1.8.0.2308
+ 1.9.0.2309
Devyus
Useful helpers for Windows Forms and Windows Presentation Framework.
© 2023
@@ -20,7 +20,8 @@
NUGET_README.md
MIT
True
-
+ - Added WindowInfo class (#139)
+- Added the possibility to get a list of opened windows (#139)
@@ -35,7 +36,7 @@
-
+
\ No newline at end of file
diff --git a/PeyrSharp.UiHelpers/WindowHelpers.cs b/PeyrSharp.UiHelpers/WindowHelpers.cs
new file mode 100644
index 0000000..d5adc2b
--- /dev/null
+++ b/PeyrSharp.UiHelpers/WindowHelpers.cs
@@ -0,0 +1,94 @@
+/*
+MIT License
+
+Copyright (c) Devyus
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace PeyrSharp.UiHelpers
+{
+ ///
+ /// Provides utility methods for working with windows.
+ ///
+ public static class WindowHelpers
+ {
+ ///
+ /// Retrieves a list of currently visible windows.
+ ///
+ /// A list of objects representing the visible windows.
+ public static List GetWindows()
+ {
+ List windowList = new();
+ EnumWindows((hWnd, lParam) =>
+ {
+ if (IsWindowVisible(hWnd))
+ {
+ StringBuilder titleBuilder = new(256);
+ StringBuilder classNameBuilder = new(256);
+
+ GetWindowText(hWnd, titleBuilder, titleBuilder.Capacity);
+ GetClassName(hWnd, classNameBuilder, classNameBuilder.Capacity);
+
+ string title = titleBuilder.ToString();
+ string className = classNameBuilder.ToString();
+
+ windowList.Add(new WindowInfo
+ {
+ Handle = hWnd,
+ Name = title,
+ ClassName = className
+ });
+ }
+
+ return true;
+ }, IntPtr.Zero);
+
+ return windowList;
+ }
+
+ private static bool IsWindowVisible(IntPtr hWnd)
+ {
+ return IsWindowVisibleCore(hWnd) && !IsIconic(hWnd);
+ }
+
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool IsWindowVisibleCore(IntPtr hWnd);
+
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool IsIconic(IntPtr hWnd);
+
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
+ private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
+
+ [DllImport("user32.dll")]
+ private static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
+
+ [DllImport("user32.dll")]
+ private static extern int GetClassName(IntPtr hWnd, StringBuilder className, int count);
+ }
+}
diff --git a/PeyrSharp.UiHelpers/WindowInfo.cs b/PeyrSharp.UiHelpers/WindowInfo.cs
new file mode 100644
index 0000000..fc50c66
--- /dev/null
+++ b/PeyrSharp.UiHelpers/WindowInfo.cs
@@ -0,0 +1,49 @@
+/*
+MIT License
+
+Copyright (c) Devyus
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+using System;
+
+namespace PeyrSharp.UiHelpers
+{
+ ///
+ /// Represents information about a window.
+ ///
+ public class WindowInfo
+ {
+ ///
+ /// Gets or sets the handle of the window.
+ ///
+ public IntPtr Handle { get; set; }
+
+ ///
+ /// Gets or sets the name of the window.
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// Gets or sets the class name of the window.
+ ///
+ public string ClassName { get; set; }
+ }
+
+}
diff --git a/PeyrSharp/PeyrSharp.cs b/PeyrSharp/PeyrSharp.cs
index 77fef70..12b81d1 100644
--- a/PeyrSharp/PeyrSharp.cs
+++ b/PeyrSharp/PeyrSharp.cs
@@ -32,6 +32,6 @@ public static class PeyrSharp
///
/// The current version of PeyrSharp.
///
- public static string Version => "1.8.0.2308";
+ public static string Version => "1.9.0.2309";
}
}
diff --git a/PeyrSharp/PeyrSharp.csproj b/PeyrSharp/PeyrSharp.csproj
index 2f65e1f..8737dc7 100644
--- a/PeyrSharp/PeyrSharp.csproj
+++ b/PeyrSharp/PeyrSharp.csproj
@@ -4,7 +4,7 @@
net5.0;net6.0;net5.0-windows;net6.0-windows;net7.0;net7.0-windows
True
PeyrSharp
- 1.8.0.2308
+ 1.9.0.2309
Devyus
© 2023
A C# library designed to make developers' job easier.
@@ -17,10 +17,12 @@
NUGET_README.md
MIT
True
- - Added Save() method in XmlHelper (#126)
-- Added Load() method in XmlHelper (#127)
-- Added Save() method in JsonHelper (#128)
-- Added Load() method in JsonHelper (#129)
+ - Added ToLowerAt(s) (#136)
+- Added ToLowerAt(str, r) (#136)
+- Added LaunchUWPApp(UwpApp) (#137)
+- Added CurrentTheme property (#138)
+- Added WindowInfo class (#139)
+- Added the possibility to get a list of opened windows (#139)
@@ -35,12 +37,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file