Wp7 Camera Button Event

淺唱寂寞╮ 提交于 2020-01-05 07:43:28

问题


Within a Windows Phone 7 app, is it possible to capture the hardware camera button pressed event in code? Right now when I press the camera button nothing happens and I can't figure out how to hook up to the event.


回答1:


Yes you can. Check this link. This is an example of the events:

// The event is fired when the shutter button receives a half press.
CameraButtons.ShutterKeyHalfPressed += OnButtonHalfPress;

// The event is fired when the shutter button receives a full press.
CameraButtons.ShutterKeyPressed += OnButtonFullPress;

// The event is fired when the shutter button is released.
CameraButtons.ShutterKeyReleased += OnButtonRelease;

// Provide auto-focus with a half button press using the hardware shutter button.
private void OnButtonHalfPress(object sender, EventArgs e)
{
        if (cam != null)
        {
            // Focus when a capture is not in progress.
            try
            {
                this.Dispatcher.BeginInvoke(delegate()
                {
                    txtDebug.Text = "Half Button Press: Auto Focus";
                });

                cam.Focus();
            }
            catch (Exception focusError)
            {
                // Cannot focus when a capture is in progress.
                this.Dispatcher.BeginInvoke(delegate()
                {
                    txtDebug.Text = focusError.Message;
                });
            }
        }
    }


来源:https://stackoverflow.com/questions/11973740/wp7-camera-button-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!