如何使用C#拍照后自动关闭CameraCaptureDialog对话框

发布于 2024-11-05 04:11:17 字数 1105 浏览 0 评论 0原文

我正在做一项工作,在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文