如何使用C#拍照后自动关闭CameraCaptureDialog对话框
我正在做一项工作,在 Windows Mobile 6.5 和 .net Compact Framework 2.0 下扫描条形码并获取其背后的信息,使用 CameraCaptureDialog 类从手机摄像头捕获图片,这是我的代码:
CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog();
cameraCaptureDialog.Owner = this;
cameraCaptureDialog.Title = "";
cameraCaptureDialog.Mode = CameraCaptureMode.Still;
cameraCaptureDialog.InitialDirectory = dir;
cameraCaptureDialog.Resolution = new System.Drawing.Size(640, 480);
cameraCaptureDialog.DefaultFileName = "CodeBar.jpg";
if (cameraCaptureDialog.ShowDialog() == DialogResult.OK && cameraCaptureDialog.FileName.Length > 0)
{
curFileName = cameraCaptureDialog.FileName;
cameraCaptureDialog.Dispose();
}
//deal with CodeBar.jpg
问题是,在我的代码期间运行时,我必须按cameraCaptureDialog上的捕获按钮,然后按后退按钮返回到我的程序来处理捕获的文件,此操作需要按2个按钮,为了用户方便,我希望cameraCaptureDialog在之后自动关闭用户按下了捕获按钮,该怎么办?据我所知,当调用 ShowDialog() 方法时,cameraCaptureDialog 不会返回,直到对话框上显示后退按钮,因此在手动关闭cameraCaptureDialog 和 ShowDialog() 方法返回 DialogResult.OK 之前我什么也做不了
I am doing a work that scans the barcode and gets the information behind it under windows mobile 6.5 and .net compact framework 2.0, using CameraCaptureDialog class to capture a picture from the phone camera, this is my code:
CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog();
cameraCaptureDialog.Owner = this;
cameraCaptureDialog.Title = "";
cameraCaptureDialog.Mode = CameraCaptureMode.Still;
cameraCaptureDialog.InitialDirectory = dir;
cameraCaptureDialog.Resolution = new System.Drawing.Size(640, 480);
cameraCaptureDialog.DefaultFileName = "CodeBar.jpg";
if (cameraCaptureDialog.ShowDialog() == DialogResult.OK && cameraCaptureDialog.FileName.Length > 0)
{
curFileName = cameraCaptureDialog.FileName;
cameraCaptureDialog.Dispose();
}
//deal with CodeBar.jpg
the question is, during my code running, I have to press the capture button on the cameraCaptureDialog, then press the back button to return to my program to deal with the captured file, this operation needs to press 2 buttons, for user convenience, I want the cameraCaptureDialog to close automatically after the user pressed the capture button, how can this be done? as I know, when ShowDialog() method is called, cameraCaptureDialog won't return until the back button shown on the dialog, so I could do nothing before manually close the cameraCaptureDialog and the ShowDialog() method returned DialogResult.OK
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论