Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 鼠标指向横向模式_Windows Phone 7_Windows Phone 7.1 - Fatal编程技术网

Windows phone 7 鼠标指向横向模式

Windows phone 7 鼠标指向横向模式,windows-phone-7,windows-phone-7.1,Windows Phone 7,Windows Phone 7.1,我需要一个图像,可以跟随我的手指(鼠标)在屏幕上。。。下面的代码在纵向模式下工作得很好,但在横向模式下却完全搞砸了,有人听过吗 <Image Height="68" HorizontalAlignment="Left" Margin="872,388,0,0" Name="imgStarPoint" Stretch="Fill" VerticalAlignment="Top" Width="54" Source="/GetMousePoint;component/St

我需要一个图像,可以跟随我的手指(鼠标)在屏幕上。。。下面的代码在纵向模式下工作得很好,但在横向模式下却完全搞砸了,有人听过吗

           <Image Height="68" HorizontalAlignment="Left" Margin="872,388,0,0" Name="imgStarPoint" Stretch="Fill" VerticalAlignment="Top" Width="54" Source="/GetMousePoint;component/StarT.png" ManipulationCompleted="imgStarPoint_ManipulationCompleted">  
                <i:Interaction.Behaviors>
                <el:MouseDragElementBehavior x:Name="imgStar"/>
                </i:Interaction.Behaviors>
            </Image>
}

有人有办法在横向模式下设置我指尖上的图像吗?

编辑:

好的,出于某种原因,我认为您使用的是WP Toolkit的手势监听器,它将在每个方向模式中报告正确的X和Y。在您的情况下,您需要检测您处于哪个方向模式,并进行必要的调整

当方向处于横向时,轴似乎被切换。在横向左侧模式下,X轴反转,在横向右侧模式下,Y轴反转。以下代码应该可以解决您的问题:

bool\u开关轴;
bool_invertX;
bool_invertY;
私有void PhoneApplicationPage\u方向已更改(对象发送方,方向更改Deventargs e){
_开关轴=(e.Orientation | PageOrientation.LandscapeLeft | PageOrientation.LandscapeRight)==(PageOrientation.LandscapeLeft | PageOrientation.LandscapeRight);
_反转X=e.方向==PageOrientation.LandscapeLeft;
_反转Y=e.方向==PageOrientation.LandscapeRight;
}
私有void Touch_FrameReported(对象发送方,System.Windows.Input.TouchFrameEventArgs e){
var width=Application.Current.Host.Content.ActualWidth;
var height=Application.Current.Host.Content.ActualHeight;
var primaryPoint=e.GetPrimaryTouchPoint(null);
如果(_开关轴){
如果(_invertY)imgStar.X=高度-primaryPoint.Position.Y;否则imgStar.X=primaryPoint.Position.Y;
如果(_invertX)imgStar.Y=width-primaryPoint.Position.X;否则imgStar.Y=primaryPoint.Position.X;
}否则{
imgStar.X=主点.Position.X;
imgStar.Y=主点.Position.Y;
}
}
您需要将
OrientationChanged
事件添加到页面xaml:


OrientationChanged=“PhoneApplicationPage\u OrientationChanged”
/

在横向模式下,一个可见的应用程序栏和系统托盘将为您搞乱X

如果有应用程序栏,请将其模式设置为最小化

ApplicationBar.Mode=ApplicationBarMode.Minimized
您还需要隐藏系统托盘,以避免在X上进行手动调整。请在页面加载事件中执行此操作

Xaml:


Loaded=“PhoneApplicationPage\u Loaded”
/
代码隐藏:

   void Touch_FrameReported(object sender, TouchFrameEventArgs e)
    {
        var PrimaryPoint = e.GetPrimaryTouchPoint(null);

        imgStar.X = PrimaryPoint.Position.X;
        imgStar.Y = PrimaryPoint.Position.Y;
        txt1.Text = PrimaryPoint.Position.X + "." + PrimaryPoint.Position.Y;
private void phoneapplication页面\u已加载(对象发送方、路由目标方){
SystemTray.IsVisible=false;
}
此外,您还需要从X中减去image.Width/2,从Y中减去image.Height/2,使其正好位于指尖的中心

imgStar.X=PrimaryPoint.Position.X-(img.Width/2);
imgStar.Y=主点位置Y-(img.Height/2);
这应该可以解决问题。

编辑:

好的,出于某种原因,我认为您使用的是WP Toolkit的手势监听器,它将在每个方向模式中报告正确的X和Y。在您的情况下,您需要检测您处于哪个方向模式,并进行必要的调整

当方向处于横向时,轴似乎被切换。在横向左侧模式下,X轴反转,在横向右侧模式下,Y轴反转。以下代码应该可以解决您的问题:

bool\u开关轴;
bool_invertX;
bool_invertY;
私有void PhoneApplicationPage\u方向已更改(对象发送方,方向更改Deventargs e){
_开关轴=(e.Orientation | PageOrientation.LandscapeLeft | PageOrientation.LandscapeRight)==(PageOrientation.LandscapeLeft | PageOrientation.LandscapeRight);
_反转X=e.方向==PageOrientation.LandscapeLeft;
_反转Y=e.方向==PageOrientation.LandscapeRight;
}
私有void Touch_FrameReported(对象发送方,System.Windows.Input.TouchFrameEventArgs e){
var width=Application.Current.Host.Content.ActualWidth;
var height=Application.Current.Host.Content.ActualHeight;
var primaryPoint=e.GetPrimaryTouchPoint(null);
如果(_开关轴){
如果(_invertY)imgStar.X=高度-primaryPoint.Position.Y;否则imgStar.X=primaryPoint.Position.Y;
如果(_invertX)imgStar.Y=width-primaryPoint.Position.X;否则imgStar.Y=primaryPoint.Position.X;
}否则{
imgStar.X=主点.Position.X;
imgStar.Y=主点.Position.Y;
}
}
您需要将
OrientationChanged
事件添加到页面xaml:


OrientationChanged=“PhoneApplicationPage\u OrientationChanged”
/

在横向模式下,一个可见的应用程序栏和系统托盘将为您搞乱X

如果有应用程序栏,请将其模式设置为最小化

ApplicationBar.Mode=ApplicationBarMode.Minimized
您还需要隐藏系统托盘,以避免在X上进行手动调整。请在页面加载事件中执行此操作

Xaml:


Loaded=“PhoneApplicationPage\u Loaded”
/
代码隐藏:

   void Touch_FrameReported(object sender, TouchFrameEventArgs e)
    {
        var PrimaryPoint = e.GetPrimaryTouchPoint(null);

        imgStar.X = PrimaryPoint.Position.X;
        imgStar.Y = PrimaryPoint.Position.Y;
        txt1.Text = PrimaryPoint.Position.X + "." + PrimaryPoint.Position.Y;
private void phoneapplication页面\u已加载(对象发送方、路由目标方){
SystemTray.IsVisible=false;
}
此外,您还需要从X中减去image.Width/2,从Y中减去image.Height/2,使其正好位于指尖的中心

imgStar.X=PrimaryPoint.Position.X-(img.Width/2);
imgStar.Y=主点位置Y-(img.Height/2);

这应该可以解决问题。

上面的建议不起作用,而且我也没有使用SystemTray。。。发生的情况是//var PrimaryPoint=e.GetPrimaryTouchPoint(null);//例如,如果单击左下角,返回0,0点,就像在正常纵向模式下一样,但图像位于左上角的对面(480,0)。有什么想法吗?#就这样!它现在运行得非常好。非常感谢你指出这一点。上面的建议不起作用,我也不使用SystemTray。。。发生的事情是//var PrimaryPoint=e.GetPrimaryT