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.Windows.Media.Imaging;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Hi.Geom;
|
using Hi.Geom;
|
||||||
|
using Microsoft.Win32; // Add this for SystemEvents
|
||||||
|
|
||||||
namespace Hi.Wpf.Disp
|
namespace Hi.Wpf.Disp
|
||||||
{
|
{
|
||||||
@ -46,6 +47,32 @@ namespace Hi.Wpf.Disp
|
|||||||
private Dictionary<int, Point> PreviousTouchingPointsMap { get; } = new Dictionary<int, Point>();
|
private Dictionary<int, Point> PreviousTouchingPointsMap { get; } = new Dictionary<int, Point>();
|
||||||
#endregion
|
#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
|
#region Initialization
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the RenderingCanvas
|
/// Initializes a new instance of the RenderingCanvas
|
||||||
@ -89,6 +116,9 @@ namespace Hi.Wpf.Disp
|
|||||||
// Enable touch support
|
// Enable touch support
|
||||||
this.IsManipulationEnabled = true;
|
this.IsManipulationEnabled = true;
|
||||||
|
|
||||||
|
// Initialize power management
|
||||||
|
InitializePowerManagement();
|
||||||
|
|
||||||
// Add the display pane to this control's content
|
// Add the display pane to this control's content
|
||||||
Content = DisplayerPane;
|
Content = DisplayerPane;
|
||||||
}
|
}
|
||||||
@ -221,8 +251,9 @@ namespace Hi.Wpf.Disp
|
|||||||
CurrentWindow = null;
|
CurrentWindow = null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region DispEngine_Rendering
|
#region DispEngine_Rendering
|
||||||
|
private byte[] PreImageBgra { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the buffer swapped event from DispEngine
|
/// Handles the buffer swapped event from DispEngine
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -230,7 +261,14 @@ namespace Hi.Wpf.Disp
|
|||||||
{
|
{
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return;
|
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
|
// Copy pixel data from DispEngine
|
||||||
int n = w * h * 4;
|
int n = w * h * 4;
|
||||||
byte[] arr = new byte[n];
|
byte[] arr = new byte[n];
|
||||||
@ -381,6 +419,9 @@ namespace Hi.Wpf.Disp
|
|||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
|
// Unsubscribe from power events
|
||||||
|
SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
|
||||||
|
|
||||||
// Dispose the DispEngine to free resources
|
// Dispose the DispEngine to free resources
|
||||||
DispEngine.Dispose();
|
DispEngine.Dispose();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user