Question

I want to use kinect region only on popup. So, when it's closed I don't wanna see any kinect cursor or smth like that. The problem is that I can't see the cursor, when popup is opened.

this is my xaml code, I have popup inside the region.

 <k:KinectRegion Name="kurs" Margin="0,0,0,0" >
            <Popup  Placement="Left" PlacementTarget="{Binding ElementName=OptionOfDrawing}" PopupAnimation="Fade" x:Name="Popup" 
                   IsOpen="False">
                <StackPanel Height="325" Width="492" Background="White">
                    <TextBlock Margin="0 0 0 0">FontSize</TextBlock>

                    <k:KinectScrollViewer VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto" 
                                      VerticalAlignment="Bottom">
                        <StackPanel Orientation="Horizontal" Name="MyScroll" />
                    </k:KinectScrollViewer>

                    </Grid>
                </StackPanel>
            </Popup>
        </k:KinectRegion>

and I added this namespace

 xmlns:k="http://schemas.microsoft.com/kinect/2013".

This is my code behind.

      void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {

      if (sen != null && this.Popup.IsOpen == true) 

            kurs.KinectSensor = KinectSensor.KinectSensors[0];


        sen = KinectSensor.KinectSensors.FirstOrDefault();

        if (sensor == null)
        {
            MessageBox.Show("I need kinect");
            this.Close();
        }



        sen.ColorStream.Enable();
        sen.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(sensor_ColorFrameReady);

        sen.DepthStream.Enable(); 
        sen.SkeletonStream.Enable();


        sen.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>( sensor_SkeletonFrameReady);
        sen.DepthFrameReady += new EventHandler<DepthImageFrameReadyEventArgs>( sensor_DepthFrameReady);
        interactionstream = new InteractionStream(sen, new NewInteractionClient());
        interactionstream.InteractionFrameReady += new EventHandler<InteractionFrameReadyEventArgs>( interactionstream_InteractionFrameReady);


        sen.Start();
        sen.ElevationAngle = 0;

}

I nearly sure, that one kinect device can't be attached to two diferent KinectSensor object. So, when the popup is opened, the kinect device is attached to the region and this line shouldnt be done ?

sen = KinectSensor.KinectSensors[0];

Any advice will be priceless for me.

Was it helpful?

Solution

You could try a different binding method:

//.. Bind the sensor to your KinectRegion - kurs
var regionSensorBinding = new Binding("Kinect") { Source = kurs };
BindingOperations.SetBinding(kurs, KinectRegion.KinectSensorProperty, regionSensorBinding);

This would be done in your code behind section.

Should you want to clear this binding:

//.. Clear your region binding
BindingOperations.ClearBinding(kurs, KinectRegion.KinectSensorProperty);

Just some advice, bind to your region after you have determined that the current sensor is not null.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top