在Windows Phone 7应用程序中,是否可以在代码中捕获硬件相机按钮事件? 现在当我按下相机按钮时没有任何反应,我无法弄清楚如何连接到事件。
答案 0 :(得分:1)
是的,你可以。检查此link。这是事件的一个例子:
// 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;
});
}
}
}