8,735
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace line
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private StreamGeometry BuildRegularPolygon(Point[] values, bool isClosed, bool isfilled)
{
StreamGeometry geometry = new StreamGeometry();
using (StreamGeometryContext ctx = geometry.Open())
{
ctx.BeginFigure(values[0], isfilled /* is filled */, isClosed /* is closed */);
for (int i = 1; i < values.Length; i++)
{
ctx.LineTo(values[i], true /* is stroked */, false /* is smooth join */);
}
}
return geometry;
}
private void myButtonClicked(object sender, EventArgs e) {
Point p6 = Point.Parse("234,789");
Point p1 = new Point(0, 0);
Point p2 = new Point(100,100);
Point p3 = new Point(235,344);
Point p4 = new Point(454,67);
Point p5 = new Point(36,455);
Point[] values = new Point[] { p1, p3, p5, p2, p4,p6 };
StreamGeometry theGeometry = BuildRegularPolygon(values, true, false);
// Create a StreamGeometry to use to specify myPath.
theGeometry.FillRule = FillRule.EvenOdd;
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = theGeometry;
grid1.Children.Add(myPath);
}
}
}