我正在創建一個小型測試相機應用程序,並且我希望能夠實現一個功能,使硬件相機按鈕處於屏幕上時可以在屏幕上顯示焦點文本條按下一半。我創建了一個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();
}
}
目前,如果用戶決定是完全按下之前釋放相機按鈕,對焦框堅持在屏幕上。我該如何解決這個問題?
我找不到任何發佈事件,你會告訴我這是如何推動的嗎? – Matthew
那麼你是如何註冊ButtonFullPress和ButtonHalfPress事件的?我正在考慮這樣的事情:'CameraButtons.ShutterKeyHalfPressed + = this.CameraButtons_ShutterKeyHalfPressed;' –
我剛剛找到解決方案,CameraButtons類包含ShutterKeyReleased。感謝您的洞察力,我在下面添加了我的解決方案。 – Matthew