ManipulationInertiaStartingEventHandler 委托
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示将处理 ManipulationInertiaStarting 事件的方法。
public delegate void ManipulationInertiaStartingEventHandler(Platform::Object ^ sender, ManipulationInertiaStartingRoutedEventArgs ^ e);
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.Guid(1575130813, 28444, 24416, 145, 128, 16, 112, 82, 130, 87, 108)]
public delegate void ManipulationInertiaStartingEventHandler(object sender, ManipulationInertiaStartingRoutedEventArgs e);
Public Delegate Sub ManipulationInertiaStartingEventHandler(sender As Object, e As ManipulationInertiaStartingRoutedEventArgs)
参数
- sender
-
Object
Platform::Object
附加处理程序的对象。
事件的事件数据。
- 属性
示例
下面的代码示例演示 输入示例中的方案 4。 此代码显示了一些使用 ManipulationStarting、ManipulationStarted、ManipulationDelta、ManipulationInertiaStarting 和 ManipulationCompleted 事件的直接操作的使用模式。
private TransformGroup _transformGroup;
private MatrixTransform _previousTransform;
private CompositeTransform _compositeTransform;
private bool forceManipulationsToEnd;
public Scenario4()
{
this.InitializeComponent();
forceManipulationsToEnd = false;
ManipulateMe.ManipulationStarting +=
new ManipulationStartingEventHandler(
ManipulateMe_ManipulationStarting);
ManipulateMe.ManipulationStarted +=
new ManipulationStartedEventHandler(
ManipulateMe_ManipulationStarted);
ManipulateMe.ManipulationDelta +=
new ManipulationDeltaEventHandler(
ManipulateMe_ManipulationDelta);
ManipulateMe.ManipulationCompleted +=
new ManipulationCompletedEventHandler(
ManipulateMe_ManipulationCompleted);
ManipulateMe.ManipulationInertiaStarting +=
new ManipulationInertiaStartingEventHandler(
ManipulateMe_ManipulationInertiaStarting);
InitManipulationTransforms();
}
private void InitManipulationTransforms()
{
_transformGroup = new TransformGroup();
_compositeTransform = new CompositeTransform();
_previousTransform = new MatrixTransform() {
Matrix = Matrix.Identity };
_transformGroup.Children.Add(_previousTransform);
_transformGroup.Children.Add(_compositeTransform);
ManipulateMe.RenderTransform = _transformGroup;
}
private void ManipulateMe_ManipulationStarting(object sender,
ManipulationStartingRoutedEventArgs e)
{
forceManipulationsToEnd = false;
e.Handled = true;
}
private void ManipulateMe_ManipulationStarted(
object sender, ManipulationStartedRoutedEventArgs e)
{
e.Handled = true;
}
private void ManipulateMe_ManipulationInertiaStarting(
object sender, ManipulationInertiaStartingRoutedEventArgs e)
{
e.Handled = true;
}
private void ManipulateMe_ManipulationDelta(
object sender, ManipulationDeltaRoutedEventArgs e)
{
if (forceManipulationsToEnd)
{
e.Complete();
return;
}
_previousTransform.Matrix = _transformGroup.Value;
Point center = _previousTransform.TransformPoint(
new Point(e.Position.X, e.Position.Y));
_compositeTransform.CenterX = center.X;
_compositeTransform.CenterY = center.Y;
_compositeTransform.Rotation = (e.Delta.Rotation * 180) / Math.PI;
_compositeTransform.ScaleX =
_compositeTransform.ScaleY = e.Delta.Scale;
_compositeTransform.TranslateX = e.Delta.Translation.X;
_compositeTransform.TranslateY = e.Delta.Translation.Y;
e.Handled = true;
}
private void ManipulateMe_ManipulationCompleted(object sender,
ManipulationCompletedRoutedEventArgs e)
{
e.Handled = true;
}
private void Scenario4Reset(object sender, RoutedEventArgs e)
{
Scenario4Reset();
}
void Scenario4Reset()
{
forceManipulationsToEnd = true;
ManipulateMe.RenderTransform = null;
InitManipulationTransforms();
}