• Windows 8.1 新控件和功能:


    http://msdn.microsoft.com/zh-cn/library/windows/apps/bg182878.aspx#five

    将 XAML 树呈现为位图:

    适用于 Windows 8.1 的 Windows 运行时为 Windows.UI.Xaml.Media.Imaging 命名空间添加了一种新类型:RenderTargetBitmap

    此类型提供了两个关键方法:

    • RenderTargetBitmap.RenderAsync,用于提取 XAML 可视化树 并为其创建位图表示。

      注意  此操作采用异步方式,将给定的 XAML 元素树呈现为位图。 此方法与屏幕刷新不同步,不能保证精确的帧计时,因此该位图可能在假定捕获时刻前后的一瞬间进行呈现。

    • RenderTargetBitmap.GetPixelsAsync,用于以特定格式返回像素的字节数组。

    下例显示如何呈现 XAML 元素树。

    var renderTargetBitmap = new RenderTargetBitmap();
    await renderTargetBitmap.RenderAsync(myElementTree);
    
    myImage.Source = renderTargetBitmap;

    RenderTargetBitmap 继承自 ImageSource,因此可以直接将其设置为 Image 对象的源,而无需调用 GetPixelsAsync 以获取及显示位图数据。

    下例显示如何将呈现的位图写入文件。

                var bitmap = new RenderTargetBitmap();
                await bitmap.RenderAsync(this.C1);
                IBuffer buffer = await bitmap.GetPixelsAsync();
                var pixelStream = buffer.AsStream();
    
    
                FileSavePicker savePicker = new FileSavePicker();
                savePicker.SuggestedStartLocation = PickerLocationId.Desktop;
                savePicker.FileTypeChoices.Add("Bitmap", new List<string>() { ".png" });
                savePicker.SuggestedFileName = "New Bitmap";
    
                StorageFile savedItem = await savePicker.PickSaveFileAsync();
    
    
                Guid encoderId = BitmapEncoder.PngEncoderId;
                IRandomAccessStream fileStream = await savedItem.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);
                BitmapEncoder encoder = await BitmapEncoder.CreateAsync(encoderId, fileStream);
                byte[] pixels = new byte[pixelStream.Length];
                pixelStream.Read(pixels, 0, pixels.Length);
    
                //pixal format shouldconvert to rgba8
                for (int i = 0; i < pixels.Length; i += 4)
                {
                    byte temp = pixels[i];
                    pixels[i] = pixels[i + 2];
                    pixels[i + 2] = temp;
                }
    
                encoder.SetPixelData(
                 BitmapPixelFormat.Rgba8,
                 BitmapAlphaMode.Straight,
                 (uint)bitmap.PixelWidth,
                 (uint)bitmap.PixelHeight,
                 96, // Horizontal DPI
                 96, // Vertical DPI
                 pixels);
    
                await encoder.FlushAsync();

    MetroApp保存UIEment为图片 http://www.cnblogs.com/manupstairs/p/3556642.html 的代码 也差不多。其//pixal format shouldconvert to rgba8 下面的一段交换代码不用会变色。

    A new control for XAML that lets you easily create the hub design pattern that reflects the proper design guidelines and behaviors: the Hub control.

    Hub pages are the user's entry point to your app.

    (Hub页是用户进入应用的入口点。)

    Hub可以分区显示,通过将不同的内容放入不同的HubSection来实现。HubSection也可以设置标题,做法与Hub一致。如果HubSection的IsHeaderInteractive属性为true,那么标题默认包含 '>' 字型,以及悬停和按下状态。

     void Hub_SectionHeaderClick(object sender, HubSectionHeaderClickEventArgs e)
            {
                HubSection section = e.Section;
                var group = section.DataContext;
                this.Frame.Navigate(typeof(SectionPage), ((SampleDataGroup)group).UniqueId);
            }

     临时显示与用户当前操作相关的 UI:Flyout 控件。

     临时显示与用户当前操作相关的命令或选项列表:MenuFlyout 控件。

     轻松地创建应用设置浮出控件,恰如其分地反映设计思想和行为:SettingsFlyout 控件。

    Windows 8.1 将 PlaceholderText 属性添加到多个包含文本的控件中。某些控件(如 ComboBoxPasswordBox)可能需要用户输入。如果不想使用默认值或显示空控件,你可以添加占位符文本以便为用户提供上下文。

    XAML 数据绑定改进:

    Windows 8.1 中添加了以下 API 元素:

  • 相关阅读:
    85--spring cloud (Ribbon-Eureka注册中心)
    85--spring cloud 入门(springcloud简介)
    84--spring cloud 入门(微服务注册中心介绍)
    83--spring cloud 入门(Eureka注册中心)
    82--JT项目20(订单模块实现/ThreadLocal本地线程变量/Quartz框架)
    81--JT项目19(商品购物车/详情/用户退出)
    80--JT项目18(Dubbo负载均衡/单点登录/注册业务)
    Ajax中post与get的区别
    Process
    Java实现CURL,与把字符串结果写到json文件
  • 原文地址:https://www.cnblogs.com/qianblue/p/3809470.html
Copyright © 2020-2023  润新知