我正在创建一个小型测试相机应用程序,我希望能够实现一个功能,允许焦点文本栏出现在屏幕上,而硬件相机按钮被按下一半。我创建了一个camera_ButtonHalfPress事件来执行焦点操作,但我不确定如何切换我想在屏幕上显示的文本栏。基本上,我的目标是在按下相机按钮的同时显示文本条,然后在完全按下按钮时将其移除,或者在完全按下按钮之前释放按钮。正在释放的按钮是我遇到问题的部分。我所拥有的如下:
MainPage.xaml.cs中
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
...
//Event is fired when the button is half pressed
CameraButtons.ShutterKeyHalfPressed += camera_ButtonHalfPress;
//Event is fired when the button is fully pressed
CameraButtons.ShutterKeyPressed += camera_ButtonFullPress;
}
private void camera_ButtonHalfPress(object sender, EventArgs e)
{
//camera.Focus();
// Show the focus brackets.
focusBrackets.Visibility = Visibility.Visible;
}
}
private void camera_ButtonFullPress(object sender, EventArgs e)
{
// Hide the focus brackets.
focusBrackets.Visibility = Visibility.Collapsed;
camera.CaptureImage();
}
}
目前,如果用户在完全按下之前决定释放相机按钮,则焦点括在屏幕上。我该如何解决这个问题?
答案 0 :(得分:0)
只需订阅相机的CameraButtons.ShutterKeyHalfPressed
事件,并隐藏文本栏。
答案 1 :(得分:0)
如果将CameraButtons.ShutterKeyReleased添加到OnNavigatedTo事件,则问题就解决了!
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
...
CameraButtons.ShutterKeyReleased -= camera_ButtonReleased; //add corresponding event handler elsewhere
...
}