migrate Pilz.Win32 & optimize Pilz & Pilz.IO

This commit is contained in:
2024-09-01 08:54:57 +02:00
parent f370642354
commit 7a94fcf360
55 changed files with 700 additions and 1427 deletions

View File

@@ -0,0 +1,17 @@
namespace Pilz.Win32.Mapped;
public static class FileTypeIcons
{
public static Icon ExtractIconFromFilePath(string filePath, SystemIconSize size)
{
return Internals.IconExtractor.ExtractIcon(filePath, size);
}
public static Icon ExtractIconFromFileExtension(string fileExtension, SystemIconSize size)
{
return Internals.IconFactory.IconFromExtensionShell(fileExtension, size);
}
}

View File

@@ -1,17 +0,0 @@
Imports System.Drawing
Namespace Mapped
Public Module FileTypeIcons
Public Function ExtractIconFromFilePath(filePath As String, size As SystemIconSize) As Icon
Return Internals.IconExtractor.ExtractIcon(filePath, size)
End Function
Public Function ExtractIconFromFileExtension(fileExtension As String, size As SystemIconSize) As Icon
Return Internals.IconFactory.IconFromExtensionShell(fileExtension, size)
End Function
End Module
End Namespace

View File

@@ -0,0 +1,22 @@
using Microsoft.VisualBasic.CompilerServices;
using Pilz.Win32.Native;
using Keys = System.Windows.Forms.Keys;
namespace Pilz.Win32.Mapped;
public class Keyboard
{
public static bool IsKeyDown(int keyCode)
{
return Conversions.ToDouble(User32.GetKeyState(keyCode).ToString() + 0x8000) < 0d;
}
public static bool IsKeyDown(Keys keyCode)
{
return IsKeyDown((int)keyCode);
}
}

View File

@@ -1,19 +0,0 @@
Imports Pilz.Win32.Native
Imports Keys = System.Windows.Forms.Keys
Namespace Mapped
Public Class Keyboard
Public Shared Function IsKeyDown(keyCode As Integer) As Boolean
Return (User32.GetKeyState(keyCode) & &H8000) < 0
End Function
Public Shared Function IsKeyDown(keyCode As Keys) As Boolean
Return IsKeyDown(CInt(keyCode))
End Function
End Class
End Namespace

View File

@@ -0,0 +1,22 @@
using Pilz.Win32.Native;
namespace Pilz.Win32.Mapped;
public class NativeFileInfo
{
public Icon Icon { get; private set; }
public int SystemIconIndex { get; private set; }
public string Displayname { get; private set; }
public string Typename { get; private set; }
public NativeFileInfo(SHFILEINFO info)
{
Icon = Icon.FromHandle(info.hIcon);
SystemIconIndex = (int)info.iIcon;
Displayname = info.szDisplayName;
Typename = info.szTypeName;
}
}

View File

@@ -1,23 +0,0 @@
Imports System.Drawing
Imports Pilz.Win32.Native
Namespace Mapped
Public Class NativeFileInfo
Public ReadOnly Property Icon As Icon
Public ReadOnly Property SystemIconIndex As Integer
Public ReadOnly Property Displayname As String
Public ReadOnly Property Typename As String
Public Sub New(info As SHFILEINFO)
Icon = Icon.FromHandle(info.hIcon)
SystemIconIndex = info.iIcon
Displayname = info.szDisplayName
Typename = info.szTypeName
End Sub
End Class
End Namespace

View File

@@ -0,0 +1,13 @@
namespace Pilz.Win32.Mapped;
/// <summary>
/// Two constants extracted from the FileInfoFlags, the only that are
/// meaningfull for the user of this class.
/// </summary>
public enum SystemIconSize : int
{
Large,
Small
}

View File

@@ -1,12 +0,0 @@
Namespace Mapped
''' <summary>
''' Two constants extracted from the FileInfoFlags, the only that are
''' meaningfull for the user of this class.
''' </summary>
Public Enum SystemIconSize As Integer
Large
Small
End Enum
End Namespace