Skip to content

Commit

Permalink
更新 Avalonia相关项目
Browse files Browse the repository at this point in the history
  • Loading branch information
MakesYT committed Jul 11, 2024
1 parent e680d3e commit af9695d
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 89 deletions.
10 changes: 5 additions & 5 deletions Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
</ItemGroup>-->

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.0-beta2" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-beta2" />
<PackageReference Include="Avalonia" Version="11.1.0-rc2"/>
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-rc2"/>
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-beta2" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-rc2"/>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2"/>
<PackageReference Include="Desktop.Robot" Version="1.5.0"/>
<PackageReference Include="FluentAvaloniaUI" Version="2.0.5" />
<PackageReference Include="log4net" Version="2.0.17"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1"/>
<PackageReference Include="SharpHook" Version="5.3.6"/>
<PackageReference Include="SharpHook.Reactive" Version="5.3.6"/>
<PackageReference Include="SharpHook" Version="5.3.7"/>
<PackageReference Include="SharpHook.Reactive" Version="5.3.7"/>
<PackageReference Include="Silk.NET.Direct3D11" Version="2.21.0"/>
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4"/>
<PackageReference Include="System.Drawing.Common" Version="8.0.6"/>
Expand Down
10 changes: 5 additions & 5 deletions KitopiaAvalonia/KitopiaAvalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@

<ItemGroup>
<PackageReference Condition="$(DefineConstants.Contains(ENABLE_XAML_HOT_RELOAD))" Include="Avalonia.Markup.Xaml.Loader" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.0-beta2"/>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.0-rc2"/>
<PackageReference Condition="$(DefineConstants.Contains(ENABLE_XAML_HOT_RELOAD))" Include="HotAvalonia" Version="1.1.1"/>
<PackageReference Include="HotAvalonia.Extensions" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.10.9"/>
<PackageReference Include="Avalonia" Version="11.1.0-rc2"/>
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-rc2"/>
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-rc2"/>
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0-rc2"/>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2"/>
<PackageReference Include="log4net" Version="2.0.17"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0"/>
Expand Down
2 changes: 1 addition & 1 deletion KitopiaEx/KitopiaEx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
<OutputPath>D:\WPF.net\Kitopia\KitopiaAvalonia\bin\Debug\net8.0-windows10.0.17763.0\plugins\KitopiaEx</OutputPath>
<OutputPath>F:\Coding\Kitopia\KitopiaAvalonia\bin\Debug\net8.0-windows10.0.17763.0\plugins\KitopiaEx\</OutputPath>

</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
120 changes: 57 additions & 63 deletions KitopiaTest/NameSolver.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System.Runtime.InteropServices;
using Silk.NET.Direct3D9;
using Silk.NET.DXGI;
using Format = Silk.NET.DXGI.Format;
using PresentParameters = Silk.NET.DXGI.PresentParameters;

namespace KitopiaTest;
namespace KitopiaTest;

public class NameSolver
{
Expand All @@ -16,61 +10,61 @@ public void Setup()
[Test]
public void Test1()
{
var d3d9 = D3D9.GetApi();
var d3d = d3d9.Direct3DCreate9(SDK);

var pp = new PresentParameters
{
Wi = true,
SwapEffect = SwapEffect.Discard,
BackBufferFormat = Format.A8R8G8B8,
BackBufferWidth = 1920,
BackBufferHeight = 1080
};

nint devicePtr;
d3d.CreateDevice(0, DeviceType.HAL, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, ref pp, &devicePtr);
var device = new IDirect3DDevice9(devicePtr);

// Create surface for the screenshot
nint surfacePtr;
device.CreateOffscreenPlainSurface(1920, 1080, Format.A8R8G8B8, Pool.SystemMem, &surfacePtr, IntPtr.Zero);
var surface = new IDirect3DSurface9(surfacePtr);

// Capture the screen
device.GetFrontBufferData(0, surface.NativePointer);

// Lock the surface
var lockedRect = new D3DLockedRect();
surface.LockRect(&lockedRect, IntPtr.Zero, 0);

// Copy the data
var data = new byte[1920 * 1080 * 4];
Marshal.Copy(lockedRect.PBits, data, 0, data.Length);

// Unlock the surface
surface.UnlockRect();

// Save the data as a bitmap file
using (var fs = new FileStream("screenshot.bmp", FileMode.Create))
{
var bmpFileHeader = new byte[]
{
0x42, 0x4D, 0x36, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x38, 0x04, 0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

fs.Write(bmpFileHeader, 0, bmpFileHeader.Length);
fs.Write(data, 0, data.Length);
}

Console.WriteLine("Screenshot saved as screenshot.bmp");

// Clean up
surface.Dispose();
device.Dispose();
d3d.Dispose();
// var d3d9 = D3D9.GetApi();
// var d3d = d3d9.Direct3DCreate9(SDK);
//
// var pp = new PresentParameters
// {
// Wi = true,
// SwapEffect = SwapEffect.Discard,
// BackBufferFormat = Format.A8R8G8B8,
// BackBufferWidth = 1920,
// BackBufferHeight = 1080
// };
//
// nint devicePtr;
// d3d.CreateDevice(0, DeviceType.HAL, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, ref pp, &devicePtr);
// var device = new IDirect3DDevice9(devicePtr);
//
// // Create surface for the screenshot
// nint surfacePtr;
// device.CreateOffscreenPlainSurface(1920, 1080, Format.A8R8G8B8, Pool.SystemMem, &surfacePtr, IntPtr.Zero);
// var surface = new IDirect3DSurface9(surfacePtr);
//
// // Capture the screen
// device.GetFrontBufferData(0, surface.NativePointer);
//
// // Lock the surface
// var lockedRect = new D3DLockedRect();
// surface.LockRect(&lockedRect, IntPtr.Zero, 0);
//
// // Copy the data
// var data = new byte[1920 * 1080 * 4];
// Marshal.Copy(lockedRect.PBits, data, 0, data.Length);
//
// // Unlock the surface
// surface.UnlockRect();
//
// // Save the data as a bitmap file
// using (var fs = new FileStream("screenshot.bmp", FileMode.Create))
// {
// var bmpFileHeader = new byte[]
// {
// 0x42, 0x4D, 0x36, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
// 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x38, 0x04, 0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
// };
//
// fs.Write(bmpFileHeader, 0, bmpFileHeader.Length);
// fs.Write(data, 0, data.Length);
// }
//
// Console.WriteLine("Screenshot saved as screenshot.bmp");
//
// // Clean up
// surface.Dispose();
// device.Dispose();
// d3d.Dispose();
}
}
26 changes: 12 additions & 14 deletions KitopiaTest/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Management;
using SharpHook;
using SharpHook.Native;

namespace KitopiaTest;

Expand All @@ -12,20 +13,17 @@ public void Setup()
[Test]
public void Test1()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem");
var eventSimulator = new EventSimulator();
eventSimulator.SimulateKeyPress(KeyCode.VcLeftControl);

eventSimulator.SimulateKeyPress(KeyCode.VcLeftAlt);
eventSimulator.SimulateKeyPress(KeyCode.VcA);
Task.Delay(100).GetAwaiter().GetResult();

eventSimulator.SimulateKeyRelease(KeyCode.VcA);
eventSimulator.SimulateKeyRelease(KeyCode.VcLeftAlt);
eventSimulator.SimulateKeyRelease(KeyCode.VcLeftControl);

foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("Caption: {0}", queryObj["Caption"]);
}
}
catch (ManagementException e)
{
Console.WriteLine("An error occurred while querying for WMI data: " + e.Message);
}

Assert.Pass();
}
Expand Down
2 changes: 1 addition & 1 deletion PluginCore
Submodule PluginCore updated 1 files
+1 −1 PluginCore.csproj

0 comments on commit af9695d

Please sign in to comment.