C# 使用操纵增量事件UWP旋转边界
我想用惯性旋转边界。我应该在哪里遗漏什么 MainPage.xaml:C# 使用操纵增量事件UWP旋转边界,c#,uwp,manipulationdelta,C#,Uwp,Manipulationdelta,我想用惯性旋转边界。我应该在哪里遗漏什么 MainPage.xaml: <Grid> <Border x:Name="ManipulationBorder" Width="200" Height="200" HorizontalAlignment="Center" VerticalAlignment="Center" Background="Red"/> </Grid> 当我在操纵DeltaRouteDeventargs中实际应用增量旋转时,它不起作
<Grid>
<Border x:Name="ManipulationBorder" Width="200" Height="200" HorizontalAlignment="Center" VerticalAlignment="Center" Background="Red"/>
</Grid>
当我在操纵DeltaRouteDeventargs中实际应用增量旋转时,它不起作用。我错在哪里
提前谢谢
当我在操纵DeltaRouteDeventargs中实际应用增量旋转时,它不起作用。我错在哪里
标准的基于触摸的旋转需要两个或两个以上的触摸点:
对于单触式旋转,首先需要固定三角变换的中心。
您需要重新计算单触更改的角度
您将知道角度=a1-a2的值
private TransformGroup transforms;
private MatrixTransform previousTransform;
private CompositeTransform deltaTransform;
public MainPage()
{
this.InitializeComponent();
InitManipulationTransforms();
ManipulationBorder.ManipulationDelta += new ManipulationDeltaEventHandler(ManipulateMe_ManipulationDelta);
ManipulationBorder.ManipulationMode =
ManipulationModes.TranslateX |
ManipulationModes.TranslateY |
ManipulationModes.Rotate |
ManipulationModes.TranslateInertia |
ManipulationModes.RotateInertia;
}
private void InitManipulationTransforms()
{
transforms = new TransformGroup();
previousTransform = new MatrixTransform() { Matrix = Matrix.Identity };
deltaTransform = new CompositeTransform();
transforms.Children.Add(previousTransform);
transforms.Children.Add(deltaTransform);
ManipulationBorder.RenderTransform = transforms;
}
private void ManipulateMe_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
previousTransform.Matrix = transforms.Value;
// Center point for rotation
Point center = previousTransform.TransformPoint(new Point(e.Position.X, e.Position.Y));
deltaTransform.CenterX = center.X;
deltaTransform.CenterY = center.Y;
// Rotation
deltaTransform.Rotation = e.Delta.Rotation;
}
private void Right_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
var x = this.RightRotateTransform.CenterX - e.Position.X;
var y = this.RightRotateTransform.CenterY - e.Position.Y;
double a1 = Math.Atan(y / x);
double a2 = Math.Atan((e.Delta.Translation.Y - y) / (x - e.Delta.Translation.X));
this.RightRotateTransform.Angle += a1 - a2;
}