AppleSeeker's Tech Blog
Welcome to AppleSeeker's space

这篇文章主要讲述:Microsoft.WindowsMobile.Forms命名空间下的三个类:
1.CameraCaptureDialog
2.SelectPictureDialog
3.ChooseContactDialog
该命名空间在WM5.0中就已经存在,且都是调用系统中提供的对象,可能很多人都已掌握,这里就当复习下。

程序运行如下:


1.CameraCaptureDialog:
打开照相机-支持录像和拍照功能。
InitialDirectory属性:指定初始目录,就是拍摄后保存的路径。
Title属性:对话框的Title。
Mode属性:Still为拍照,VideoOnly为录图像不带声音,VideoWithAudio录像带声音。
Resolution属性:照片或录像的尺寸,具体哪些可以参考系统所提供的。
VideoTimeLimit属性:录像时的时间最大限制。
VideoTypes属性:主要分为Messaging和Standard
Messaging为3gp格式的彩信消息,Standard为wmv格式。
注:如果未指定DefaultFileName,不论VideoTypes设置为Messaging或Standard,保存的文件依旧是wmv格式的。
未指定DefaultFileName,则,系统会以001开始,自动递增文件,拍照为img***,录像为***。
在注册表的HKEY_LOCAL_MACHINE\Software\Microsoft\Pictures\Camera\OEM\VideoProfile\下会指定保存文件的默认情况。通常为Standard。所以都会以wmv格式保存。

代码如下:

 1        private void menuItem4_Click(object sender, EventArgs e)
 2        {
 3            CameraCaptureDialog camDialog = new CameraCaptureDialog();
 4            camDialog.InitialDirectory = @"\My Documents";
 5            camDialog.Mode = CameraCaptureMode.Still;
 6            camDialog.Title = "Camera Picture";
 7            //camDialog.DefaultFileName = "test.jpg";
 8            camDialog.Resolution = new Size(600480);
 9            camDialog.StillQuality = CameraCaptureStillQuality.High;
10            camDialog.ShowDialog();
11        }

12
13        private void menuItem5_Click(object sender, EventArgs e)
14        {
15            CameraCaptureDialog camDialog = new CameraCaptureDialog();
16            camDialog.Owner = null;
17            camDialog.InitialDirectory = @"\My Documents";
18            camDialog.Title = "Camera Video";
19            //camDialog.DefaultFileName = "test1.3gp";
20            //camDialog.Resolution = new Size(320, 240);
21            camDialog.VideoTypes = CameraCaptureVideoTypes.Standard;
22            camDialog.Resolution = new Size(176144);
23            camDialog.VideoTimeLimit = new TimeSpan(0015);
24            //camDialog.VideoTypes = CameraCaptureVideoTypes.All;
25            camDialog.Mode = CameraCaptureMode.VideoWithAudio;
26            camDialog.ShowDialog();
27        }

拍照运行效果:


录像运行效果:


注:一旦指定了Mode后,其Menu菜单中不提供拍照和录像这2种模式的切换的。
对比下系统照相机效果:


当我的录像以3gp格式保存后,在Picure & Video选择框内是找不到的,但是用资源管理器就发现,其实是保存了的。

最后一个test1就是3gp格式的文件。

2.SelectPictureDialog
图片选择
InitialDirectory属性:指定初始目录,图片选择对话框的初始路径。
LockDirectory属性:是否可以路径。
SortOrder属性:排序方式。
CameraAccess属性:当浏览My Doucement\My Picture目录下时,该属性决定是否现实照相机。

代码如下:

 1        private void menuItem6_Click(object sender, EventArgs e)
 2        {
 3            SelectPictureDialog selDialog = new SelectPictureDialog();
 4            selDialog.InitialDirectory = @"\My Documents";
 5            selDialog.LockDirectory = false;
 6            selDialog.SortOrder = SortOrder.DateDescending;
 7            selDialog.Title = "Select Picture";
 8            selDialog.ShowDrmContent = true;
 9            selDialog.ShowForwardLockedContent = true;
10            selDialog.MessagingFileCreate = true;
11            selDialog.CameraAccess = false;
12            if (selDialog.ShowDialog() == DialogResult.OK)
13            {
14                this.pictureBox1.Image = new Bitmap(selDialog.FileName);
15            }

16        }

图片选择效果:


CameraAccess属性为False时,不显示照相机


3.ChooseContactDialog
联系人选择
没有列举详细属性。大家可以自己试下。
运行效果:


程序运行完效果:


代码下载:SmartDeviceDemo.rar

总结:
本文介绍的非常简单,但相信看完的朋友一定会对此完全掌握了.最近会准备一些关于SQL CE操作方面的文章,到时候希望大家能够喜欢。

Author:AppleSeeker
Date:2008-03-23

posted on 2008-03-23 18:26  AppleSeeker(冯峰)  阅读(4403)  评论(10编辑  收藏  举报