Question

I have a function to have a Record button

    protected void StartRecord(object sender, RoutedEventArgs e)
    {
        MessageBox.Show("Start Recording");
        //string generatedName = Guid.NewGuid().ToString();
        string generatedName = @"c:\Desktop\Stream.recorded";
        //recordStreamPathAndName = @"C:" + generatedName + ".recorded";
        //this.recordStream = File.Create(recordStreamPathAndName);
        this.recordStream = File.Create(generatedName);
        this.Recorder = new KinectRecorder(KinectRecordOptions.Color | KinectRecordOptions.Skeletons, recordStream);
    }

Will this code allow me to create the record button? If it does how do I create it to show on the main window and to actually start the recording? Answer here: Here is the .xaml code

  <Button Click ="StartRecord" DataContext="{Binding}" Name="StartRecording" Width="50" Height="50" Canvas.Left="709" Canvas.Top="0" />

Update: Button created and file created. But nothing is saved to file.

    void sensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
    {
          // some stuff

        using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
        {
          if (skeletonFrame == null)
          {
              return;
          }


           // Start recorder
            this.StartRecord(sender, e);  
         // parameter asks for (object, Routedeventargs)
         // but I have only (object, AllFramesReadyargs) declared in this function.


         // some stuff here

        }
   }
Was it helpful?

Solution

You need to create the button in your XAML and hook it up to a callback. Something like:

<Button Click="StartRecord">

In your code-behind your function declaration would look like:

private void StartRecord(object sender, RoutedEventArgs e)
{
    // code here
}

Tell your program what you want to do when the button is clicked in there.

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