PolyBezierSegment 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示一條或多條三次方貝茲曲線。
public ref class PolyBezierSegment sealed : System::Windows::Media::PathSegment
public sealed class PolyBezierSegment : System.Windows.Media.PathSegment
type PolyBezierSegment = class
inherit PathSegment
Public NotInheritable Class PolyBezierSegment
Inherits PathSegment
- 繼承
範例
下列範例示範如何使用 PolyBezierSegment 來繪製兩個立方 Bezier 曲線。
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<Canvas>
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<!-- The StartPoint specifies the starting point of the first curve. -->
<PathFigure StartPoint="10,100">
<PathFigure.Segments>
<PathSegmentCollection>
<!-- The PolyBezierSegment specifies two cubic Bezier curves.
The first curve is from 10,100 (start point specified above)
to 300,100 with a control point of 0,0 and another control
point of 200,0. The second curve is from 300,100
(end of the last curve) to 600,100 with a control point of 300,0
and another control point of 400,0. -->
<PolyBezierSegment Points="0,0 200,0 300,100 300,0 400,0 600,100" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>
</StackPanel>
</Page>
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace SDKSample
{
public partial class PolyBezierSegmentExample : Page
{
public PolyBezierSegmentExample()
{
// Create a PathFigure to be used for the PathGeometry of myPath.
PathFigure myPathFigure = new PathFigure();
// Set the starting point for the PathFigure specifying that the
// geometry starts at point 10,100.
myPathFigure.StartPoint = new Point(10, 100);
// Create a PointCollection that holds the Points used to specify
// the points of the PolyBezierSegment below.
PointCollection myPointCollection = new PointCollection(6);
myPointCollection.Add(new Point(0, 0));
myPointCollection.Add(new Point(200, 0));
myPointCollection.Add(new Point(300, 100));
myPointCollection.Add(new Point(300, 0));
myPointCollection.Add(new Point(400, 0));
myPointCollection.Add(new Point(600, 100));
// The PolyBezierSegment specifies two cubic Bezier curves.
// The first curve is from 10,100 (start point specified by the PathFigure)
// to 300,100 with a control point of 0,0 and another control point
// of 200,0. The second curve is from 300,100 (end of the last curve) to
// 600,100 with a control point of 300,0 and another control point of 400,0.
PolyBezierSegment myBezierSegment = new PolyBezierSegment();
myBezierSegment.Points = myPointCollection;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myBezierSegment);
myPathFigure.Segments = myPathSegmentCollection;
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
myPathFigureCollection.Add(myPathFigure);
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = myPathFigureCollection;
// Create a path to draw a geometry with.
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
// specify the shape (quadratic Bezier curve) of the path using the StreamGeometry.
myPath.Data = myPathGeometry;
// Add path shape to the UI.
StackPanel mainPanel = new StackPanel();
mainPanel.Children.Add(myPath);
this.Content = mainPanel;
}
}
}
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Media
Imports System.Windows.Shapes
Namespace SDKSample
Partial Public Class PolyBezierSegmentExample
Inherits Page
Public Sub New()
' Create a PathFigure to be used for the PathGeometry of myPath.
Dim myPathFigure As New PathFigure()
' Set the starting point for the PathFigure specifying that the
' geometry starts at point 10,100.
myPathFigure.StartPoint = New Point(10, 100)
' Create a PointCollection that holds the Points used to specify
' the points of the PolyBezierSegment below.
Dim myPointCollection As New PointCollection(6)
myPointCollection.Add(New Point(0, 0))
myPointCollection.Add(New Point(200, 0))
myPointCollection.Add(New Point(300, 100))
myPointCollection.Add(New Point(300, 0))
myPointCollection.Add(New Point(400, 0))
myPointCollection.Add(New Point(600, 100))
' The PolyBezierSegment specifies two cubic Bezier curves.
' The first curve is from 10,100 (start point specified by the PathFigure)
' to 300,100 with a control point of 0,0 and another control point
' of 200,0. The second curve is from 300,100 (end of the last curve) to
' 600,100 with a control point of 300,0 and another control point of 400,0.
Dim myBezierSegment As New PolyBezierSegment()
myBezierSegment.Points = myPointCollection
Dim myPathSegmentCollection As New PathSegmentCollection()
myPathSegmentCollection.Add(myBezierSegment)
myPathFigure.Segments = myPathSegmentCollection
Dim myPathFigureCollection As New PathFigureCollection()
myPathFigureCollection.Add(myPathFigure)
Dim myPathGeometry As New PathGeometry()
myPathGeometry.Figures = myPathFigureCollection
' Create a path to draw a geometry with.
Dim myPath As New Path()
myPath.Stroke = Brushes.Black
myPath.StrokeThickness = 1
' specify the shape (quadratic Bezier curve) of the path using the StreamGeometry.
myPath.Data = myPathGeometry
' Add path shape to the UI.
Dim mainPanel As New StackPanel()
mainPanel.Children.Add(myPath)
Me.Content = mainPanel
End Sub
End Class
End Namespace
備註
PathFigure使用 物件來儲存 PolyBezierSegment 物件和其他區段。
三次方 Bezier 曲線是由四點所定義:一個起點、一個終點和兩個控制點。 指定 PolyBezierSegment 一或多個立方 Bezier 曲線,方法是將 Points 屬性設定為點集合。 針對集合中的每三個點,第一個和第二個點會指定曲線的兩個控制點,而第三個點則指定結束點。 請注意,沒有指定曲線的起點,因為起點與最後一個線段的終點相同。
三次方 Bezier 曲線的兩個控制點的行為就像磁力一樣,另一部分則為直線向自己,並產生曲線。 第一個控制點會影響曲線的開頭部分;第二個控制點會影響曲線的結束部分。 請注意,曲線不一定通過任一控制點;每個控制點都會將其行的部分向本身移動,但不會透過本身移動。
建構函式
PolyBezierSegment() |
初始化 PolyBezierSegment 類別的新執行個體。 |
PolyBezierSegment(IEnumerable<Point>, Boolean) |
初始化 PolyBezierSegment 類別的新執行個體,這個執行個體具有指定之 Point 物件的集合,以及指定是否將片段描邊的值。 |
欄位
PointsProperty |
識別 Points 相依性屬性。 |
屬性
CanFreeze |
取得值,指出是否可以將物件設為不可修改。 (繼承來源 Freezable) |
DependencyObjectType |
取得包裝 DependencyObjectType 這個實例 CLR 型別的 。 (繼承來源 DependencyObject) |
Dispatcher |
取得與這個 Dispatcher 關聯的 DispatcherObject。 (繼承來源 DispatcherObject) |
HasAnimatedProperties |
取得值,這個值表示是否有一個或多個 AnimationClock 物件與這個物件的任何一個相依性屬性相關聯。 (繼承來源 Animatable) |
IsFrozen |
取得值,該值表示物件目前是否可修改。 (繼承來源 Freezable) |
IsSealed |
取得值,這個值表示此執行個體目前是否已密封 (唯讀)。 (繼承來源 DependencyObject) |
IsSmoothJoin |
取得或設定值,這個值表示使用 PathSegment 加上描邊時,是否將這個 PathSegment 與前一個 Pen 之間的聯結視為邊角。 (繼承來源 PathSegment) |
IsStroked |
取得或設定值,這個值表示是否將片段描邊。 (繼承來源 PathSegment) |
Points |
取得或設定 PointCollection,它會定義這個 PolyBezierSegment 物件。 |
方法
事件
Changed |
發生於 Freezable 或所含的物件遭到修改時。 (繼承來源 Freezable) |