Guidance:
. NET Compact framework BASICS (1)
. NET Compact framework BASICS (2)
This articleArticleThis article mainly describes three classes in the Microsoft. windowsmobile. Forms namespace:
1. cameracapturedialog
2. selectpicturedialog
3. choosecontactdialog
This namespace already exists in wm5.0 and is provided by the calling system. Many people may have mastered it. here we will review it.
ProgramRun the following command:
1. cameracapturedialog:
Enable camera-supports video recording and photo taking.
Initialdirectory attribute: Specifies the initial Directory, which is the path saved after shooting.
Title attribute: the title of the dialog box.
Mode attribute: still indicates taking a photo, videoonly indicates recording an image without sound, and videowithaudio indicates the video audio.
Resolution attribute: the size of a photo or video. For details, refer to what the system provides.
Videotimelimit attribute: Maximum video recording time limit.
Videotypes attributes: mainly divided into messaging and standard
Messaging is a MMS Message in 3GP format. The standard format is WMV.
NOTE: If defaultfilename is not specified, whether videotypes is set to messaging or standard, the stored files are still in WMV format.
If defaultfilename is not specified, the system automatically increments the file starting with 001. The image is taken as IMG *** and the video is ***.
In the Registry's HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ pictures \ camera \ OEM \ videoprofile \, the default file storage conditions are specified. It is usually standard. Therefore, all files are saved in WMV format.
CodeAs follows:
1 Private Void Menuitem4_click ( Object Sender, eventargs E)
2 {
3 Cameracapturedialog camdialog = New Cameracapturedialog ();
4 Camdialog. initialdirectory = @" \ My Documents ents " ;
5 Camdialog. Mode = Cameracapturemode. Still;
6 Camdialog. Title = " Camera picture " ;
7 // Camdialog. defaultfilename = "test.jpg ";
8 Camdialog. Resolution = New Size ( 600 , 480 );
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 ents " ;
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 ( 176 , 144 );
23 Camdialog. videotimelimit = New Timespan ( 0 , 0 , 15 );
24 // Camdialog. videotypes = cameracapturevideotypes. All;
25 Camdialog. Mode = Cameracapturemode. videowithaudio;
26 Camdialog. showdialog ();
27 }
Photo running effect:
Video running effect:
Note: Once mode is specified, the menu does not provide switching between the two modes: Photo Taking and video recording.
Compare the System camera effect:
After my video is saved in 3GP format, it cannot be found in the picure & video selection box, but it is saved in the resource manager.
The last test1 is a file in 3GP format.
2. selectpicturedialog
Image Selection
Initialdirectory attribute: Specify the initial directory and the initial path of the Image Selection dialog box.
Lockdirectory attribute: whether the path is available.
Sortorder attribute: sorting method.
Cameraaccess attribute: When you browse the my Doucement \ my picture directory, this attribute determines whether the camera is realistic.
The Code is as follows:
1 Private Void Menuitem6_click ( Object Sender, eventargs E)
2 {
3 Selectpicturedialog seldialog = New Selectpicturedialog ();
4 Seldialog. initialdirectory = @" \ My Documents ents " ;
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 {
14This. Picturebox1.image= NewBitmap (seldialog. filename );
15}
16 }
Image Selection Effect:
When the cameraaccess attribute is false, the camera is not displayed.
3. choosecontactdialog
Contact Selection
No detailed attributes are listed. You can try it yourself.
Running effect:
Effect of running the program:
Download Code: smartdevicedemo_2008_03_23.rar (124.60 KB)
Summary:
This article is very simple to introduce, But I believe my friends will have a full grasp of it. I will prepare some articles about SQL ce operations recently. I hope you will like it later.