Windows Phone开发(33):路径之其它Geometry
原文:Windows Phone开发(33):路径之其它Geometry
上一节中,我们把最复杂的PathGeometry给干了,生剩下几个家伙就好办事了。一起来见见他们的真面目吧。
一、LineGeometry
这个几何图形就很简单了,一条线段,两个点——StartPoint And EndPoint。
一起来看看下面的例子。
<Path Grid.Column="0" Grid.Row="0">
<Path.Data>
<LineGeometry StartPoint="20,5" EndPoint="200,320"/>
</Path.Data>
</Path>
运行之后你会看到以下情景:

二、RectangleGeometry
它呈现一人矩形的几何图形,Rect指示其中矩形的位置大小,在XAML中可以用4个数值表示,即X、Y、Width、Height;别外,RadiusX和RadiusY表示圆角在X轴和Y轴上的半径。看下面的例子。
<Path Grid.Column="1" Grid.Row="0">
<Path.Data>
<RectangleGeometry Rect="12,6,125,90" RadiusX="24" RadiusY="30"/>
</Path.Data>
</Path>
运行效果如下图所示。

三、EllipseGeometry
表示一个椭圆的几何图形,Center属性为椭圆的中心点的坐标,RadiusX和RadiusY分别为X轴方向上和Y轴方向上的半径长度。看例子。
<Path Grid.Column="0" Grid.Row="1">
<Path.Data>
<EllipseGeometry Center="100,180" RadiusX="55" RadiusY="120"/>
</Path.Data>
</Path>
运行效果如下:

四、GeometryGroup
严格上说,它不属性一种几何图形,但它很有用,因为它可以同时包含N个几何图形,如下面例子所示。
<Path Grid.Column="1" Grid.Row="1">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="32,185" EndPoint="180,230"/>
<RectangleGeometry Rect="35,85,136,96" RadiusX="25" RadiusY="5"/>
<EllipseGeometry Center="112,130" RadiusX="45" RadiusY="36"/>
</GeometryGroup>
</Path.Data>
</Path>
运行效是如下所示:

下面是本节示例的完整XAML代码。
<phone:PhoneApplicationPage
x:Class="Sample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True"> <phone:PhoneApplicationPage.Resources>
<Style TargetType="Path">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Margin" Value="20"/>
<Setter Property="Stroke" Value="Blue"/>
<Setter Property="StrokeThickness" Value="8"/>
</Style>
</phone:PhoneApplicationPage.Resources> <Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Path Grid.Column="0" Grid.Row="0">
<Path.Data>
<LineGeometry StartPoint="20,5" EndPoint="200,320"/>
</Path.Data>
</Path>
<Path Grid.Column="1" Grid.Row="0">
<Path.Data>
<RectangleGeometry Rect="12,6,125,90" RadiusX="24" RadiusY="30"/>
</Path.Data>
</Path>
<Path Grid.Column="0" Grid.Row="1">
<Path.Data>
<EllipseGeometry Center="100,180" RadiusX="55" RadiusY="120"/>
</Path.Data>
</Path>
<Path Grid.Column="1" Grid.Row="1">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="32,185" EndPoint="180,230"/>
<RectangleGeometry Rect="35,85,136,96" RadiusX="25" RadiusY="5"/>
<EllipseGeometry Center="112,130" RadiusX="45" RadiusY="36"/>
</GeometryGroup>
</Path.Data>
</Path>
</Grid>
</phone:PhoneApplicationPage>
Windows Phone开发(33):路径之其它Geometry的更多相关文章
- Windows Phone开发(32):路径之PathGeometry
原文:Windows Phone开发(32):路径之PathGeometry 说起路径这玩意儿,其实说的就是Path类,它藏在命名空间System.Windows.Shapes下,应该好找,它有一个很 ...
- Windows Phone开发(34):路径标记语法
原文:Windows Phone开发(34):路径标记语法 如果你觉得前面所讨论的绘制各种几何图形的方法过于复杂,那么,今天我们也来一次"减负"吧.当然,我们是很轻松的,本教程是不 ...
- Kinect for Windows SDK开发入门(15):进阶指引 下
Kinect for Windows SDK开发入门(十五):进阶指引 下 上一篇文章介绍了Kinect for Windows SDK进阶开发需要了解的一些内容,包括影像处理Coding4Fun K ...
- Windows驱动开发(中间层)
Windows驱动开发 一.前言 依据<Windows内核安全与驱动开发>及MSDN等网络质料进行学习开发. 二.初步环境 1.下载安装WDK7.1.0(WinDDK\7600.16385 ...
- Windows 10开发基础——文件、文件夹和库(一)
原文:Windows 10开发基础--文件.文件夹和库(一) 主要内容: 1.枚举查询文件和文件夹 2.文本文件读写的三种方法——创建写入和读取文件 3.获得文件的属性 枚举查询文件和文件夹 先了解一 ...
- Windows Phone开发(48):不可或缺的本地数据库
原文:Windows Phone开发(48):不可或缺的本地数据库 也许WP7的时候,是想着让云服务露两手,故似乎并不支持本地数据库,所有数据都上传上"云"数据库中.不过呢,在SD ...
- Windows Phone开发(29):隔离存储C
原文:Windows Phone开发(29):隔离存储C 本文是隔离存储的第三节,大家先喝杯咖啡放松,今天的内容也是非常简单,我们就聊一件东东--用户设置. 当然了,可能翻译为应用程序设置合适一些,不 ...
- Windows Phone开发(30):图形
原文:Windows Phone开发(30):图形 图形如矩形.椭圆.路径等都从Shape类派生,它们一般表示规则或不规则图形,这些图形都是简单的二维图形,我相信大家都能理解的. 例一:矩形. 请看下 ...
- Windows Phone开发(27):隔离存储A
原文:Windows Phone开发(27):隔离存储A 在很多资料或书籍上都翻译为"独立存储",不过,我想了一下,决定将IsolatedStorage翻译为"隔离存储& ...
随机推荐
- 【ASP.NET Web API教程】5.1 HTTP消息处理器
原文:[ASP.NET Web API教程]5.1 HTTP消息处理器 注:本文是[ASP.NET Web API系列教程]的一部分,如果您是第一次看本系列教程,请先看前面的内容. 5.1 HTTP ...
- 微微信.NET:开源的ASP.NET微信公众号应用平台
题记: 平时喜欢使用 C# 编程.近半年玩微信公众平台,看到一些微信的应用系统大多是PHP.Python的,于是就有想法做一套开放的 C# ASP.NET的微信应用系统. 微微信.NET 基于ASP ...
- H-index因素
Problem Description Paper quality and quantity have long been used to measure a research's scientifi ...
- UVa 11233 - Deli Deli
题目:求所给单词的负数形式. 分析:模拟. 直接按章题意分情况求解就可以. 说明:按语法也能够(⊙_⊙). #include <iostream> #include <cstdlib ...
- HDU4911-Inversion(树状数组)
Inversion Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
- 调整Tomcat的并发线程到5000+
调整Tomcat的并发线程数到5000+ 1. 调整server.xml的配置 先调整maxThreads的数值,在未调整任何参数之前,默认的并发线程可以达到40. 调整此项后可以达到1800左右. ...
- Java抓取网页数据(原来的页面+Javascript返回数据)
转载请注明出处! 原文链接:http://blog.csdn.net/zgyulongfei/article/details/7909006 有时候因为种种原因,我们须要採集某个站点的数据,但因为不同 ...
- StringBuilder、StringBuffer和String三者的联系和区别(转)
StringBuilder.StringBuffer和String三者的联系和区别 1. String 类 String的值是不可变的,这就导致每次对String的操作都会生成新的String对 ...
- CString的部分实现剖析
一.CString初探: 在CString的实现中,其最基础的类结构如下: CString其实只有一个数据成员m_pszData,这个成员指向了字符串的首地址.但在MFC的具体实现中, m_pszDa ...
- CMake Intro - CMakeLists.txt
Notes: directory structure: cmake, cmake/Tutorial, cmake/Tutorial/MathLibs 1. File lists in cmake/ ...