zoukankan      html  css  js  c++  java
  • <metro>摄取相片

    首先,我们打开Vs2012,选择好Blank App模板。在MainPage.xaml中拉进Button和image两个空间。在Button控件中选择Click事件。经命名等后,代码如下:

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <Button x:Name="Start" Content="Start" HorizontalAlignment="Left" Height="39" Margin="81,40,0,0" VerticalAlignment="Top" Width="88" Click="Start_Click"/>
            <Image x:Name="image" HorizontalAlignment="Left" Height="320" Margin="81,110,0,0" VerticalAlignment="Top" Width="434"/>
    
        </Grid>

    接着,在MainPage.xaml.cs中的Click事件里,填入一下代码就可以了:

    private async void Start_Click(object sender, RoutedEventArgs e)
            {
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.ViewMode = PickerViewMode.Thumbnail;
                openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
                openPicker.FileTypeFilter.Add(".jpg");
                openPicker.FileTypeFilter.Add(".gif");
                openPicker.FileTypeFilter.Add(".png");
    
                StorageFile file = await openPicker.PickSingleFileAsync();
    
                string fileToken;
                IStorageItemAccessList futureAccess = StorageApplicationPermissions.FutureAccessList;
                fileToken = futureAccess.Add(file);
    
                BitmapImage src = new BitmapImage();
                src.SetSource(await file.OpenAsync(FileAccessMode.Read));
                image.Source = src;
                AutomationProperties.SetName(image, file.Name);
                
            }

    然后,按F5,演示。

  • 相关阅读:
    误操作 rpm -e --nodeps zlib
    Raid阵列之简单介绍
    GpG使用指南
    hadoop系统的端口
    网站日志流量复杂分析
    Flume在企业大数据仓库架构中位置及功能
    Hue的安装与部署
    Hive中的数据倾斜
    Hive的三种Join方式
    如何每日增量加载数据到Hive分区表
  • 原文地址:https://www.cnblogs.com/virgil/p/2765968.html
Copyright © 2011-2022 走看看