This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

56
AntdWpf/Controls/Thumb.cs Normal file
View File

@@ -0,0 +1,56 @@
namespace AntdWpf.Controls
{
using System.Windows.Input;
using AntdWpf.Contracts;
using ThumbBase = System.Windows.Controls.Primitives.Thumb;
public class Thumb : ThumbBase, IThumb
{
private TouchDevice currentDevice = null;
protected override void OnPreviewTouchDown(TouchEventArgs e)
{
// Release any previous capture
this.ReleaseCurrentDevice();
// Capture the new touch
this.CaptureCurrentDevice(e);
}
protected override void OnPreviewTouchUp(TouchEventArgs e)
{
this.ReleaseCurrentDevice();
}
protected override void OnLostTouchCapture(TouchEventArgs e)
{
// Only re-capture if the reference is not null
// This way we avoid re-capturing after calling ReleaseCurrentDevice()
if (this.currentDevice != null)
{
this.CaptureCurrentDevice(e);
}
}
private void ReleaseCurrentDevice()
{
if (this.currentDevice != null)
{
// Set the reference to null so that we don't re-capture in the OnLostTouchCapture() method
var temp = this.currentDevice;
this.currentDevice = null;
this.ReleaseTouchCapture(temp);
}
}
private void CaptureCurrentDevice(TouchEventArgs e)
{
bool gotTouch = this.CaptureTouch(e.TouchDevice);
if (gotTouch)
{
this.currentDevice = e.TouchDevice;
}
}
}
}