Win8 development technical points accumulation (1)

Source: Internet
Author: User

VS11:

Http://www.microsoft.com/click/services/Redirect2.ashx? CR_CC = 200098114

1Win8 MetroUnderMessageBox

Private async void No_But_Click (object sender, RoutedEventArgs e) {MessageDialog msg = new MessageDialog ("are you sure you want to exit your application? "," Gui suwei prompt "); msg. commands. add (new UICommand ("yes", new UICommandInvokedHandler (this. commandInvokedHandler); msg. commands. add (new UICommand ("no", new UICommandInvokedHandler (this. commandInvokedHandler); await msg. showAsync ();} private void CommandInvokedHandler (IUICommand command) {this. dispatcher. invoke (Windows. UI. core. coreDispatcherPriority. normal, (s, a) =>{ UserName_TB.Text = command. label;}, this, null );} 2 Eliminate AppBarBlock<AppBar Name = "pb" verticalignment = "Bottom" placement = "Stretch" Height = "88" VerticalContentAlignment = "Stretch" Background = "# E5058AE6" Visibility = "Collapsed"> <grid> <Grid. columnDefinitions> <ColumnDefinition/> </Grid. columnDefinitions> <StackPanel Grid. column = "1" Orientation = "Horizontal"/> <StackPanel Orientation = "Horizontal"/> </Grid> </AppBar> background code: protected o Verride void OnRightTapped (RightTappedRoutedEventArgs e) {if (! Pb. IsOpen) {pb. Visibility = Visibility. Visible;} else {pb. Visibility = Visibility. Collapsed;} base. OnRightTapped (e );} 3 Image Attach ImagesImg. Source = new BitmapImage (new Uri ("ms-appx:/Images/a.png", UriKind. RelativeOrAbsolute )); 4 Get camera imagePrivate async void Button_Click_1 (object sender, RoutedEventArgs e)
{CameraCaptureUI camera = new CameraCaptureUI ();
Camera. PhotoSettings. CroppedAspectRatio = new Size (1, 1); // Ratio
Camera. PhotoSettings. Format = CameraCaptureUIPhotoFormat. Png; // image Format
// Dialog. PhotoSettings. CroppedSizeInPixels = new Size (100,150); // fixed Size
StorageFile file = await camera. CaptureFileAsync (CameraCaptureUIMode. Photo );
If (file! = Null)
{
BitmapImage bitmapImage = new BitmapImage ();
Using (IRandomAccessStream fileStream = await file. OpenAsync (Windows. Storage. FileAccessMode. Read ))
{
BitmapImage. SetSource (fileStream );
}
Img. Source = bitmapImage;
Aaa. Content = file. Path;
}} 5 Get camera videoPrivate async void Button_Click_1 (object sender, RoutedEventArgs e) {CameraCaptureUI dialog = new CameraCaptureUI (); dialog. videoSettings. format = CameraCaptureUIVideoFormat. mp4; StorageFile file = await dialog. captureFileAsync (CameraCaptureUIMode. video); if (file! = Null) {IRandomAccessStream fileStream = await file. OpenAsync (Windows. Storage. FileAccessMode. Read); mediaelement. SetSource (fileStream, "video/mp4 ");}} 6 Get the camera video to the programMediaCapture mediaCaptureMgr;
Private async void Button_Click_1 (object sender, RoutedEventArgs e)
{
MediaCaptureMgr = new MediaCapture ();
Await mediaCaptureMgr. InitializeAsync ();
Scenario1Video. Source = mediaCaptureMgr;
Await mediaCaptureMgr. StartPreviewAsync ();
} 7 Obtain system files

FileOpenPicker openPicker = new FileOpenPicker ();

 

OpenPicker. ViewMode = PickerViewMode. List; // display the file Style

 

OpenPicker. SuggestedStartLocation = PickerLocationId. PicturesLibrary; // The Image Library is the target path.

 

OpenPicker. FileTypeFilter. Add (". iso"); // you can specify a file type.

 

IReadOnlyList <StorageFile> files = await openPicker. PickMultipleFilesAsync (); // get the file

 

// Display the file

 

Foreach (StorageFile v in files)

 

{

 

Lv. Items. Add (v. Path );

 

}

 

 

 

This article is from "Gui Su Wei" blog, please be sure to keep this source http://axzxs.blog.51cto.com/730810/810451

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.