capture Tag visualizer contact event

2019-08-17 18:17发布

I'm developing Microsoft Surface(pixelsense) App using TagVisualizer object I'm looking for a method to capture tagEnter, tagLeave event on other UI elements such as a button. For example in following XAML code I want to capture an event when TagVisualizer enters the boundary of "Button1".

  <Grid>
    <s:TagVisualizer 
        Name="MaintagVisualizer" VisualizationAdded="MaintagVisualizer_VisualizationAdded" 
        VerticalAlignment="Stretch" 
        HorizontalAlignment="Stretch" 
        HorizontalContentAlignment="Center" 
        Height="Auto" Width="Auto"
        VerticalContentAlignment="Center" >

        <s:TagVisualizer.Definitions>
            <s:TagVisualizationDefinition LostTagTimeout="2000" MaxCount="1" Value="0x1" Source="TagVisualizationEllipse.xaml" />
        </s:TagVisualizer.Definitions>

        <s:SurfaceButton Name="Button1" HorizontalAlignment="Left" VerticalAlignment="Top" Content="test" Width="120" Height="40" Margin="20" ></s:SurfaceButton>

    </s:TagVisualizer>
</Grid>

标签: pixelsense
1条回答
迷人小祖宗
2楼-- · 2019-08-17 18:43

I know this is an old post, but I thought I would put something on the record to help others.

I'm working on something similar...trying to capture the touch events (down, up, etc) for when a tag is placed over the control called myMap.

Here is the solution I developed: first, a touch listener for the window:

public SurfaceWindow1()
    {
         Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);
    }

Then the handler:

void Touch_FrameReported(object sender, TouchFrameEventArgs e)
    {

        if (this.myMap != null)
        {
            string active_capture = "";

            foreach (TouchPoint _touchPoint in e.GetTouchPoints(this.myMap))
            {

                if (_touchPoint.TouchDevice.Captured != null)
                {
                    active_capture = _touchPoint.TouchDevice.Captured.ToString();
                }

                if (active_capture.Contains("TagVisualizer"))
                {
                    //This touch was captured by the tag visualizer, therefore it must be a tag
                   if (_touchPoint.Action == TouchAction.Down)
                    {
                        TagTouchId = _touchPoint.TouchDevice.Id;
                        //now you can do whatever you like with the TouchDevice ID
                    }
                }
            }
        }
    }

You could probably do the same thing with a button control. At the least this can get you started.

查看更多
登录 后发表回答