1、Win8 Metro下的MessageBox
复制代码
2、消除AppBar阻挡
复制代码
后台代码:
复制代码
3、Image加载图片
复制代码
4、获取摄像头图片
复制代码
5、获取摄像头视频
复制代码
6、获取摄像头视频到程序中
复制代码
7、获取系统文件
复制代码
- private async void No_But_Click(object sender, RoutedEventArgs e)
- {
- MessageDialog msg = new MessageDialog("确定退出应用吗?", "提示");
- msg.Commands.Add(new UICommand("是", new UICommandInvokedHandler(this.CommandInvokedHandler)));
- msg.Commands.Add(new UICommand("否", 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);
- }
- <AppBar Name="pb" VerticalAlignment="Bottom" HorizontalContentAlignment="Stretch" Height="88" VerticalContentAlignment="Stretch" Background="#E5058AE6" Visibility="Collapsed">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition/>
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
- <StackPanel Grid.Column="1" Orientation="Horizontal"/>
- <StackPanel Orientation="Horizontal"/>
- </Grid>
- </AppBar>
- protected override void OnRightTapped(RightTappedRoutedEventArgs e)
- {
- if (!pb.IsOpen)
- {
- pb.Visibility = Visibility.Visible;
- }
- else
- {
- pb.Visibility = Visibility.Collapsed;
- }
- base.OnRightTapped(e);
- }
- img.Source = new BitmapImage(new Uri( "ms-appx:/Images/a.png", UriKind.RelativeOrAbsolute));
- private async void Button_Click(object sender, RoutedEventArgs e)
- {
- CameraCaptureUI camera = new CameraCaptureUI();
- camera.PhotoSettings.CroppedAspectRatio = new Size(1, 1);//比例
- camera.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Png;//图片格式
- // dialog.PhotoSettings.CroppedSizeInPixels = new Size(100, 150);//固定大小
- 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;
- }
- }
- private async void Button_Click(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");
- }
- }
- MediaCapture mediaCaptureMgr;
- private async void Button_Click(object sender, RoutedEventArgs e)
- {
- mediaCaptureMgr = new MediaCapture();
- await mediaCaptureMgr.InitializeAsync();
- Scenario1Video.Source = mediaCaptureMgr;
- await mediaCaptureMgr.StartPreviewAsync();
- }
- FileOpenPicker openPicker = new FileOpenPicker();
- openPicker.ViewMode = PickerViewMode.List;//显示文件样式
- openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;//图片库为查找目标路径
- openPicker.FileTypeFilter.Add(".iso"); //查找文件类型
- IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync();//获取文件
- //显示文件
- foreach (StorageFile v in files)
- {
- lv.Items.Add(v.Path);
- }