"Essential WPF - Chapter 5 Visuals" 阅读笔记

(WPF 设计师讲述 WPF 框架设计思路的书, 非常不错. 之前看了一半, 一直想要看完, 刚好最近有项目界面决定采用 WPF, 捡起这本书, 继续学习)

 

Chapter 5 Visuals

 

WPF 是个界面框架, 而界面, 是通过图形描绘出来的.

因此, 这一章讲的是 WPF 图形绘制机制, 同时也是上层界面搭建的基础.

 

5.1 2D Graphics

 

WPF 的 2D 图形绘制分为 3 层: shapes, drawings, and drawing instructions.

 

所有的图形绘制可以归结为: a geometry, a brush, and a pen. Geometries define the shape, brushes define the fill (contents), and pens define the stroke (edge) of the shape.

 

5.1.6 Drawings

 

Drawing 直接架构在 geometry-brush-pen 上, 是对 drawing instructions 的浅包装, 以驱动底层的引擎绘制图形.

 

在 drawing 这层, 所有 drawing 都会属于一个 graph structure, 而 graph structure 提供了 drawing 组合及复用的机制, 使用恰当的话, 可以极大地提高绘制效率: This graph structure allows a single drawing to appear in multiple places in the graph, providing a significant performance benefit.

 

The sharing here is much deeper than just the managed object model exposure; because drawings are a thin wrapper on the composition engine, this sharing is occurring inside of the engine.

 

5.1.7 Shapes

 

Shapes bring drawings into the control world.

 

Shapes introduce an interesting problem.

主要在于 Shapes 架构在 Drawings 之上, 但是用于构建控件时, Drawing 的一些属性, 比如 layout determines position and size, 对控件并不合适, 因为 Controls typically don’t scale by default, so shapes are designed to stretch the associated geometry instead of simply scaling.

 

5.1.8 Images

略过

 

5.1.9 Opacity

 

在 WPF 中, 为透明提供的支持有 4 种: alpha channel in the image, all colors in WPF have an alpha value, and every visual has Opacity and OpacityMask properties

 

不过透明效果比较消耗资源, 容易成为瓶颈, 使用时需要注意

Before we continue, here’s a word of warning: Anytime we add another layer of transparency, a lot of work must be done somewhere in the system.

That’s not fatal, but it’s worth noting that transparency effects should be used judiciously, and always remember to profile the performance impact.

 

OpacityMask 提供对整颗 Visual 子树的透明定制, 可以用来实现一些比较炫的效果.

 

5.1.10 BitmapEffects

 

简单来讲, 这个功能就是通过设置 UIElement.BitmapEffect 对 Visual 产生的位图进行以像素为单位的修饰, 不过因为全是软件实时计算, 所以性能消耗很大, 使用时要注意

 

5.2 3D Graphics

略过

 

5.3 Documents and Text

 

5.3.1 Hello World, Text Style

 

The WPF development team decided not to create special tags for every combination of formatting attributes.

Instead we favored using attributes to control font rendering.

 

One of the big improvements in WPF is that it was built from the ground up with support for Unicode.

 

A pervasive design philosophy in the development of WPF was “pay for play”; we applied this concept to performance, complexity, and anything else we could.

 

5.3.2 Fonts

 

 

5.3.3 Text Layout

 

5.3.3.1 Paragraphs

 

解说了几个概念, Margin 对外部的间隔, Padding 内部的间隔, BorderThickness 边界的宽度

 

5.3.3.2 List

略过

 

5.3.3.3 Table

略过

 

5.3.3.4 Figures and Floaters

略过

 

5.3.3.5 Columns and Page-Level Formatting

略过

 

5.3.4 Advanced Typography

略过

 

5.4 Animation

略过

 

5.5 Media

略过

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值