add stroke check.
This commit is contained in:
parent
e4daa418ca
commit
bd23930c5f
@ -9,6 +9,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Collections.Generic;
|
||||
using Hi.Geom;
|
||||
using Microsoft.Win32; // Add this for SystemEvents
|
||||
|
||||
namespace Hi.Wpf.Disp
|
||||
{
|
||||
@ -46,6 +47,32 @@ namespace Hi.Wpf.Disp
|
||||
private Dictionary<int, Point> PreviousTouchingPointsMap { get; } = new Dictionary<int, Point>();
|
||||
#endregion
|
||||
|
||||
#region Power_Management
|
||||
/// <summary>
|
||||
/// Handles system power mode changes
|
||||
/// </summary>
|
||||
private void InitializePowerManagement()
|
||||
{
|
||||
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles power mode change events
|
||||
/// </summary>
|
||||
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||
{
|
||||
switch (e.Mode)
|
||||
{
|
||||
case PowerModes.Suspend:
|
||||
DispEngine.IsVisible = false;
|
||||
break;
|
||||
case PowerModes.Resume:
|
||||
DispEngine.IsVisible = IsVisible;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Initialization
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the RenderingCanvas
|
||||
@ -89,6 +116,9 @@ namespace Hi.Wpf.Disp
|
||||
// Enable touch support
|
||||
this.IsManipulationEnabled = true;
|
||||
|
||||
// Initialize power management
|
||||
InitializePowerManagement();
|
||||
|
||||
// Add the display pane to this control's content
|
||||
Content = DisplayerPane;
|
||||
}
|
||||
@ -221,8 +251,9 @@ namespace Hi.Wpf.Disp
|
||||
CurrentWindow = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region DispEngine_Rendering
|
||||
private byte[] PreImageBgra { get; set; }
|
||||
/// <summary>
|
||||
/// Handles the buffer swapped event from DispEngine
|
||||
/// </summary>
|
||||
@ -230,7 +261,14 @@ namespace Hi.Wpf.Disp
|
||||
{
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
|
||||
//since the treatment is different from Razor version,
|
||||
//the image checking mechanism cannot be set in DispEngine.
|
||||
Span<byte> bgra = new Span<byte>(data, w * h * 4);
|
||||
if (PreImageBgra != null && bgra.SequenceEqual(PreImageBgra))
|
||||
return;
|
||||
PreImageBgra = bgra.ToArray();
|
||||
|
||||
// Copy pixel data from DispEngine
|
||||
int n = w * h * 4;
|
||||
byte[] arr = new byte[n];
|
||||
@ -381,6 +419,9 @@ namespace Hi.Wpf.Disp
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Unsubscribe from power events
|
||||
SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
|
||||
|
||||
// Dispose the DispEngine to free resources
|
||||
DispEngine.Dispose();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user