月更
This commit is contained in:
58
AntDesignWPF/Controls/Tumb/Thumb.cs
Normal file
58
AntDesignWPF/Controls/Tumb/Thumb.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user