Wp7相机按钮事件 [英] Wp7 Camera Button Event

查看:162
本文介绍了Wp7相机按钮事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows Phone 7应用程式中,可以在程式码中撷取硬体相机按钮按下的事件吗?
现在当我按下相机按钮没有发生任何事情,我不知道如何挂钩事件。

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.

推荐答案

是的,可以。请检查此链接。这是事件的示例:

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;
                });
            }
        }
    }

这篇关于Wp7相机按钮事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆