This commit is contained in:
GG Z
2025-07-31 20:12:24 +08:00
parent 4f6cd2137c
commit f209e7d3ad
426 changed files with 15854 additions and 6612 deletions

View File

@@ -0,0 +1,58 @@
using AntDesignWPF.Contracts;
namespace AntDesignWPF.Controls
{
using System.Windows.Input;
using AntDesignWPF.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;
}
}
}
}