首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wp7相机按钮事件

Wp7相机按钮事件
EN

Stack Overflow用户
提问于 2012-08-16 01:04:09
回答 1查看 687关注 0票数 1

在Windows Phone 7应用程序中,是否可以在代码中捕获硬件摄像头按钮按下事件?现在,当我按下相机按钮时,什么也没有发生,我不知道如何连接到事件。

EN

回答 1

Stack Overflow用户

发布于 2012-08-16 01:23:15

是的你可以。检查此link。以下是事件的一个示例:

代码语言:javascript
复制
// 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;
                });
            }
        }
    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11973740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档