-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
226 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Mortise.Browser.Platform.Linux | ||
{ | ||
public class Class1 | ||
{ | ||
|
||
} | ||
} |
4 changes: 1 addition & 3 deletions
4
...tform.Linux/Mortise.Platform.Linux.csproj → ...nux/Mortise.Browser.Platform.Linux.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/Browser/Mortise.Browser.Platform.Windows/WindowsSystemInteraction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Diagnostics; | ||
using System.Drawing; | ||
using Mortise.Browser.Platform; | ||
using Mortise.BrowserAccessibility.Models; | ||
using Tenon.Infra.Windows.Win32; | ||
using Process = System.Diagnostics.Process; | ||
|
||
namespace Mortise.Platform.Windows; | ||
|
||
public class WindowsSystemInteraction : ISystemInteraction | ||
{ | ||
public IntPtr GetWindowHandle(Point point = default) | ||
{ | ||
return Window.GetTop(point); | ||
} | ||
|
||
public Process? GetProcess(Point point = default) | ||
{ | ||
var handle = Window.GetTop(point); | ||
if (handle == IntPtr.Zero) | ||
return null; | ||
var processId = Window.GetProcessId(handle); | ||
return Process.GetProcessById((int)processId); | ||
} | ||
|
||
public Point ScreenPointToWebPoint(Point screenPoint) | ||
{ | ||
Debug.WriteLine($"ScreenPointToWebPoint:{screenPoint.ToString()}"); | ||
var displayDevice = DisplayMonitor.FromPoint(screenPoint); | ||
Debug.WriteLine($"point:{screenPoint.ToString()}=>{displayDevice.ScaleX}"); | ||
//displayDevice.ScaleX = 2; | ||
//displayDevice.ScaleY = 2; | ||
if (displayDevice == null) return screenPoint; | ||
var locationY = screenPoint.Y / displayDevice.ScaleY; | ||
float locationX = screenPoint.X; | ||
if (locationX < 0) | ||
locationX = (locationX + displayDevice.VirtualResolution.Width) / displayDevice.ScaleX; | ||
else if (locationX > displayDevice.VirtualResolution.Width) | ||
locationX = (locationX - displayDevice.VirtualResolution.Width) / displayDevice.ScaleX; | ||
return new Point((int)locationX, (int)locationY); | ||
} | ||
|
||
public Rectangle WebPointToScreenRectangle(Point screenPoint, DomRect domRect) | ||
{ | ||
var domRectangle = new Rectangle(domRect.X, domRect.Y, domRect.Width, domRect.Height); | ||
|
||
var displayDevice = DisplayMonitor.FromPoint(domRect.Location); | ||
if (displayDevice == null) return domRectangle; | ||
if (screenPoint is { X: >= 0, Y: >= 0 } && screenPoint.X < displayDevice.VirtualResolution.Width && screenPoint.Y < displayDevice.VirtualResolution.Height) | ||
return domRectangle; | ||
Debug.WriteLine($"displayDevice:{displayDevice.VirtualResolution.Width}"); | ||
if (screenPoint.X < 0) | ||
domRectangle.X = | ||
Convert.ToInt32(domRectangle.X * displayDevice.ScaleX - displayDevice.VirtualResolution.Width); | ||
if (screenPoint.X > displayDevice.VirtualResolution.Width) | ||
domRectangle.X = | ||
Convert.ToInt32(domRectangle.X * displayDevice.ScaleX + displayDevice.VirtualResolution.Width); | ||
domRectangle.Y = Convert.ToInt32(domRectangle.Y * displayDevice.ScaleY); | ||
return domRectangle with { Width = domRect.Width, Height = domRect.Height }; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Browser/Mortise.Browser.Platform/ISystemInteraction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Mortise.BrowserAccessibility.Models; | ||
using System.Diagnostics; | ||
using System.Drawing; | ||
|
||
namespace Mortise.Browser.Platform; | ||
|
||
public interface ISystemInteraction | ||
{ | ||
/// <summary> | ||
/// 根据坐标获取窗口句柄 | ||
/// </summary> | ||
/// <param name="point">Point</param> | ||
/// <returns>窗口句柄</returns> | ||
public IntPtr GetWindowHandle(Point point = default); | ||
|
||
/// <summary> | ||
/// 根据坐标获取对应进程 | ||
/// </summary> | ||
/// <param name="point">Point</param> | ||
/// <returns>Process</returns> | ||
public Process? GetProcess(Point point = default); | ||
|
||
public Point ScreenPointToWebPoint(Point screenPoint); | ||
|
||
public Rectangle WebPointToScreenRectangle(Point screenPoint, DomRect domRect); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Browser/Mortise.Browser.Platform/Mortise.Browser.Platform.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="..\..\..\nuget.props"></Import> | ||
<Import Project="..\..\..\common.props"></Import> | ||
<Import Project="..\..\..\version.props"></Import> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Mortise.BrowserAccessibility\Mortise.BrowserAccessibility.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
22 changes: 22 additions & 0 deletions
22
src/Browser/Mortise.BrowserAccessibility/CoordinateTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Mortise.BrowserAccessibility; | ||
|
||
public class CoordinateTransformer | ||
{ | ||
public static CssPoint ScreenPointToCssPoint(CssPoint screenPoint, RenderOption renderOption) | ||
{ | ||
var finalPoint = screenPoint; | ||
finalPoint = finalPoint.Offset( | ||
-(renderOption.WindowLeft + renderOption.PageRenderX), | ||
-(renderOption.WindowTop + renderOption.PageRenderY) | ||
); | ||
|
||
finalPoint = finalPoint.ScaleInv(1); | ||
|
||
return finalPoint; | ||
} | ||
|
||
private object GetPageRenderOffsetInfo(RenderOption renderOption) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Mortise.BrowserAccessibility; | ||
|
||
public sealed class CssPoint | ||
{ | ||
public CssPoint(int x, int y) | ||
{ | ||
X = x; | ||
Y = y; | ||
} | ||
public int X { get; private init; } | ||
public int Y { get; private init; } | ||
|
||
public CssPoint Offset(int offsetX, int offsetY) | ||
{ | ||
return new CssPoint(X + offsetX, Y + offsetY); | ||
// { X = X + offsetX, Y = Y + offsetY }; | ||
} | ||
|
||
public CssPoint ScaleInv(int scale) | ||
{ | ||
return new CssPoint(X / scale, Y / scale); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Mortise.BrowserAccessibility | ||
{ | ||
public sealed class RenderOption | ||
{ | ||
public int WindowLeft { get; set; } | ||
|
||
public int WindowTop { get; set; } | ||
|
||
public int WindowWidth { get; set; } | ||
|
||
public int WindowHeight { get; set; } | ||
|
||
public int Dpi { get; set; } | ||
|
||
public int PageRenderWidth { get; set; } | ||
|
||
public int PageRenderHeight { get; set; } | ||
|
||
public int PageRenderX { get; set; } | ||
|
||
public int PageRenderY { get; set; } | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/Browser/Mortise.ChromiumAccessibility/ChromiumAccessible.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Browser/Mortise.ChromiumAccessibility/ChromiumAccessibleDetector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/Browser/Mortise.ChromiumAccessibility/Configurations/ChromiumAccessibleOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.