StylusPointCollection.Clone 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
public:
System::Windows::Input::StylusPointCollection ^ Clone();
public System.Windows.Input.StylusPointCollection Clone ();
member this.Clone : unit -> System.Windows.Input.StylusPointCollection
Public Function Clone () As StylusPointCollection
傳回
新的 StylusPointCollection,包含目前 StylusPoint 中 StylusPointCollection 物件的複本。
範例
下列範例示範如何複製 StylusPointCollection。 此範例會建立由 成員組成的筆劃, StylusPointCollection 並將其新增至 InkCanvas。 這個範例假設有名為 InkCanvasinkcanvs1
的 。
Point[] rawPoints = new Point[]
{
new Point(100, 100),
new Point(100, 200),
new Point(200, 250),
new Point(300, 300)
};
StylusPointCollection points1 = new StylusPointCollection(rawPoints);
// Create a copy of points1 and change the second StylusPoint.
StylusPointCollection points2 = points1.Clone();
points2[1] = new StylusPoint(200, 100);
// Create a stroke from each StylusPointCollection and add them to
// inkCanvas1. Note that changing a StylusPoint in point2 did not
// affect points1.
Stroke stroke1 = new Stroke(points1);
inkCanvas1.Strokes.Add(stroke1);
Stroke stroke2 = new Stroke(points2);
stroke2.DrawingAttributes.Color = Colors.Red;
inkCanvas1.Strokes.Add(stroke2);
Dim rawPoints() As Point = {New Point(100, 100), _
New Point(100, 200), _
New Point(200, 250), _
New Point(300, 300)}
Dim points1 As New StylusPointCollection(rawPoints)
' Create a copy of points1 and change the second StylusPoint.
Dim points2 As StylusPointCollection = points1.Clone()
points2(1) = New StylusPoint(200, 100)
' Create a stroke from each StylusPointCollection and add them to
' inkCanvas1. Note that changing a StylusPoint in point2 did not
' affect points1.
Dim stroke1 As New Stroke(points1)
inkCanvas1.Strokes.Add(stroke1)
Dim stroke2 As New Stroke(points2)
stroke2.DrawingAttributes.Color = Colors.Red
inkCanvas1.Strokes.Add(stroke2)