Win8开发技术点积累(一)

VS11下载地址:

专注于为中小企业提供成都网站建设、网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业湘潭免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千多家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

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

1       Win8 Metro下的MessageBox

 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);
        }
2       消除AppBar阻挡
           
               
                   
                   
               
               
               
           
       
后台代码:
protected override void OnRightTapped(RightTappedRoutedEventArgs e)
        {     
            if (!pb.IsOpen)
            {
                pb.Visibility = Visibility.Visible;
            }
            else
            {
                pb.Visibility = Visibility.Collapsed; 
            }
            base.OnRightTapped(e);              
        }
 
3       Image加载图片
   img.Source = new BitmapImage(new Uri( "ms-appx:/Images/a.png", UriKind.RelativeOrAbsolute));
4       获取摄像头图片
 private async void Button_Click_1(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;
            }
}
5       获取摄像头视频
private 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       获取摄像头视频到程序中
  MediaCapture mediaCaptureMgr;    
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            mediaCaptureMgr = new MediaCapture();
            await mediaCaptureMgr.InitializeAsync();
            Scenario1Video.Source = mediaCaptureMgr;
            await mediaCaptureMgr.StartPreviewAsync();    
        }
7       获取系统文件

FileOpenPicker openPicker = new FileOpenPicker();

 

            openPicker.ViewMode = PickerViewMode.List;//显示文件样式

 

            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;//图片库为查找目标路径

 

            openPicker.FileTypeFilter.Add(".iso");         //查找文件类型

 

            IReadOnlyList files = await openPicker.PickMultipleFilesAsync();//获取文件

 

            //显示文件

 

            foreach (StorageFile v in files)

 

            {

 

                lv.Items.Add(v.Path);

 

            }

 

 

 

网页题目:Win8开发技术点积累(一)
当前网址:http://bzwzjz.com/article/ieeips.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 专业网站设计 成都网站建设 古蔺网站建设 成都网站设计 成都网站设计公司 成都网站建设公司 宜宾网站设计 网站建设改版 成都营销网站制作 成都网站建设 成都网站建设推广 成都网站制作 成都网站制作 网站建设公司 达州网站设计 手机网站设计 成都响应式网站建设 成都网站建设公司 成都网站制作公司 成都网站设计 成都做网站建设公司 定制网站设计