0

我正在创建一个小型测试相机应用程序,我希望能够实现一个功能,当硬件相机按钮被按下一半时,允许焦点文本栏出现在屏幕上。我创建了一个 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();
        }
    }

目前,如果用户决定在完全按下相机按钮之前释放它,则焦点括号会保留在屏幕上。我该如何解决这个问题?

4

2 回答 2

0

只需订阅CameraButtons.ShutterKeyHalfPressed相机的事件,并将文本栏隐藏在里面。

于 2012-09-01T21:35:04.077 回答
0

如果在 OnNavigatedTo 事件中添加 CameraButtons.ShutterKeyReleased,那么问题就解决了!

protected override void OnNavigatedTo(NavigationEventArgs e)  
{  
    base.OnNavigatedTo(e);  

     ...  

     CameraButtons.ShutterKeyReleased -= camera_ButtonReleased;  //add corresponding event handler elsewhere

     ...                

 }  
于 2012-09-02T02:04:10.887 回答