本文整理汇总了C#中System.Windows.Media.LineSegment类的典型用法代码示例。如果您正苦于以下问题:C# LineSegment类的具体用法?C# LineSegment怎么用?C# LineSegment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineSegment类属于System.Windows.Media命名空间,在下文中一共展示了LineSegment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Draw
public static void Draw(Canvas canvas, List<LinePoint> points, Brush stroke, bool clear = true)
{
if (clear)
{
canvas.Children.Clear();
}
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
PathGeometry myPathGeometry = new PathGeometry();
foreach (LinePoint p in points)
{
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = p.StartPoint;
LineSegment myLineSegment = new LineSegment();
myLineSegment.Point = p.EndPoint;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myLineSegment);
myPathFigure.Segments = myPathSegmentCollection;
myPathFigureCollection.Add(myPathFigure);
}
myPathGeometry.Figures = myPathFigureCollection;
Path myPath = new Path();
myPath.Stroke = stroke == null ? Brushes.Black : stroke;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
canvas.Children.Add(myPath);
}
开发者ID:Eddie104,项目名称:Libra-CSharp,代码行数:34,代码来源:GraphicsHelper.cs
示例2: Setup
public void Setup()
{
m_StartSegment = Substitute.For <ITurnCircleArcSegment>();
m_MiddleSegment = Substitute.For <ITurnCircleArcSegment>();
m_EndSegment = Substitute.For <ITurnCircleArcSegment>();
m_Path = Substitute.For <IPath>();
var segments = new List <IPolylineSegment>
{
m_StartSegment,
m_MiddleSegment,
m_EndSegment
};
m_Path.Segments.Returns(segments);
m_ArcSegmentOne = new ArcSegment(new Point(10.0,
10.0),
new Size(10.0,
10.0),
45.0,
false,
SweepDirection.Clockwise,
false);
m_LineSegment = new LineSegment(new Point(20.0,
20.0),
false);
m_ArcSegmentTwo = new ArcSegment(new Point(30.0,
30.0),
new Size(30.0,
30.0),
90.0,
false,
SweepDirection.Counterclockwise,
false);
m_ArcSegmentThree = new ArcSegment(new Point(40.0,
40.0),
new Size(40.0,
40.0),
135.0,
false,
SweepDirection.Counterclockwise,
false);
m_Point = new Point(10.0,
10.0);
m_Helper = Substitute.For <IPathSegmentHelper>();
m_Helper.SegmentToLineSegment(Line.Unknown).ReturnsForAnyArgs(m_LineSegment);
m_Helper.SegmentToArcSegment(TurnCircleArcSegment.Unknown).ReturnsForAnyArgs(m_ArcSegmentOne,
m_ArcSegmentTwo,
m_ArcSegmentThree);
m_Helper.PointRelativeToOrigin(null).ReturnsForAnyArgs(m_Point);
m_Converter = new RacetrackPathUTurnToFiguresConverter(m_Helper);
}
开发者ID:tschroedter,项目名称:Selkie.WPF,代码行数:60,代码来源:RacetrackPathUTurnToFiguresConverterTests.cs
示例3: InsertionAdorner
// Create the pen and triangle in a static constructor and freeze them to improve performance.
static InsertionAdorner()
{
pen = new Pen
{
Brush = Brushes.Gray,
Thickness = 2
};
pen.Freeze();
LineSegment firstLine = new LineSegment(new Point(0, -5), false);
firstLine.Freeze();
LineSegment secondLine = new LineSegment(new Point(0, 5), false);
secondLine.Freeze();
PathFigure figure = new PathFigure
{
StartPoint = new Point(5, 0)
};
figure.Segments.Add(firstLine);
figure.Segments.Add(secondLine);
figure.Freeze();
triangle = new PathGeometry();
triangle.Figures.Add(figure);
triangle.Freeze();
}
开发者ID:Boddlnagg,项目名称:WordsLive,代码行数:27,代码来源:InsertionAdorner.cs
示例4: Superposition
public Superposition()
{
InitializeComponent();
PathGeometry pathGeometry = new PathGeometry();
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = new Point(0,0);
PathSegmentCollection pathSegmentCollection = new PathSegmentCollection();
int maxHeight = (int)this.Height;
int maxWidth = (int)this.Width;
Random rand = new Random();
for (int i = 0; i < 500; i++)
{
LineSegment newSegment = new LineSegment();
newSegment.Point = new Point(rand.Next(0, maxWidth), rand.Next(0, maxHeight));
pathSegmentCollection.Add(newSegment);
}
pathFigure.Segments = pathSegmentCollection;
pathGeometry.Figures.Add(pathFigure);
pathBackground.Data = pathGeometry;
}
开发者ID:Corantin,项目名称:Cegep,代码行数:28,代码来源:Superposition.xaml.cs
示例5: Draw
public void Draw(EasingFunctionBase easingFunction)
{
canvas1.Children.Clear();
PathSegmentCollection pathSegments = new PathSegmentCollection();
for (double i = 0; i < 1; i += _samplingInterval)
{
double x = i * canvas1.Width;
double y = easingFunction.Ease(i) * canvas1.Height;
var segment = new LineSegment();
segment.Point = new Point(x, y);
pathSegments.Add(segment);
}
var p = new Path();
p.Stroke = new SolidColorBrush(Colors.Black);
p.StrokeThickness = 3;
PathFigureCollection figures = new PathFigureCollection();
figures.Add(new PathFigure() { Segments = pathSegments });
p.Data = new PathGeometry() { Figures = figures };
canvas1.Children.Add(p);
}
开发者ID:CNinnovation,项目名称:WPFWorkshopFeb2016,代码行数:26,代码来源:EasingChartControl.xaml.cs
示例6: Triangle
public Triangle()
{
InitializeComponent();
l1 = new LineSegment();
l2 = new LineSegment();
f = new PathFigure();
f.Segments.Add(l1);
f.Segments.Add(l2);
f.IsClosed = true;
PathGeometry g = new PathGeometry();
g.Figures.Add(f);
Path p = new Path();
this.SetBinding(FillProperty, new Binding("Fill") { Source = p, Mode = BindingMode.TwoWay });
this.SetBinding(StrokeProperty, new Binding("Stroke") { Source = p, Mode = BindingMode.TwoWay });
this.SetBinding(StrokeThicknessProperty, new Binding("StrokeThickness") { Source = p, Mode = BindingMode.TwoWay });
p.Data = g;
this.Fill = new SolidColorBrush(Colors.White);
this.Stroke = new SolidColorBrush(Colors.Black);
this.LayoutRoot.Children.Add(p);
}
开发者ID:satomacoto,项目名称:Silverlight-Graph,代码行数:26,代码来源:Triangle.xaml.cs
示例7: AddPoint
/// <summary>
/// Add new point (line segment)
/// </summary>
public void AddPoint(Point point)
{
LineSegment segment = new LineSegment(point, true);
segment.IsSmoothJoin = true;
pathGeometry.Figures[0].Segments.Add(segment);
MakePoints(); // keep points array up to date
}
开发者ID:VictorHelios,项目名称:OpenCVBestPractice,代码行数:12,代码来源:GraphicsPolyLine.cs
示例8: DefineGeometry
private void DefineGeometry()
{
PointCollection points = Points;
if (points == null)
{
_geometry = Geometry.Empty;
return;
}
PathFigure figure = new PathFigure();
if (points.Count > 0)
{
// start point
figure.StartPoint = points[0];
if (points.Count > 1)
{
// points between
double desiredRadius = Radius;
for (int i = 1; i < (points.Count - 1); i++)
{
// adjust radius if points are too close
Vector v1 = points[i] - points[i - 1];
Vector v2 = points[i + 1] - points[i];
double radius = Math.Min(Math.Min(v1.Length, v2.Length) / 2, desiredRadius);
// draw the line, and stop before the next point
double len = v1.Length;
v1.Normalize();
v1 *= (len - radius);
LineSegment line = new LineSegment(points[i - 1] + v1, true);
figure.Segments.Add(line);
// draw the arc to the next point
v2.Normalize();
v2 *= radius;
SweepDirection direction = (Vector.AngleBetween(v1, v2) > 0) ? SweepDirection.Clockwise : SweepDirection.Counterclockwise;
ArcSegment arc = new ArcSegment(points[i] + v2, new Size(radius, radius), 0, false, direction, true);
figure.Segments.Add(arc);
}
// last point
figure.Segments.Add(new LineSegment(points[points.Count - 1], true));
}
}
PathGeometry geometry = new PathGeometry();
geometry.Figures.Add(figure);
geometry.FillRule = FillRule;
if (geometry.Bounds == Rect.Empty)
{
_geometry = Geometry.Empty;
}
else
{
_geometry = geometry;
}
}
开发者ID:arpinerap,项目名称:digiCamControl.Plugins,代码行数:57,代码来源:RoundPolyline.cs
示例9: Arc
public Arc(Path path, LineSegment lineSegment, ArcSegment arcSegment, Point zeroPos, Color color)
{
Path = path;
LineSegment = lineSegment;
ArcSegment = arcSegment;
ZeroPos = zeroPos;
Path.Stroke = ToBrush(color);
Path.Fill = ToBrush(color);
}
开发者ID:draptik,项目名称:worktimer,代码行数:9,代码来源:Arc.cs
示例10: SegmentToLineSegment
public LineSegment SegmentToLineSegment(ILine segment)
{
m_Converter.GeometryPoint = segment.EndPoint;
m_Converter.Convert();
var line = new LineSegment(m_Converter.Point,
true);
return line;
}
开发者ID:tschroedter,项目名称:Selkie.WPF,代码行数:10,代码来源:PathSegmentHelper.cs
示例11: AddLine
/// <summary>
/// Adds a line to a <see cref="PathGeometry"/>.
/// </summary>
/// <param name="pathGeometry">The <see cref="PathGeometry"/>.</param>
/// <param name="start">The start point of the line.</param>
/// <param name="end">The end point of the line.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="pathGeometry"/> is <see langword="null"/>.
/// </exception>
public static void AddLine(this PathGeometry pathGeometry, Point start, Point end)
{
if (pathGeometry == null)
throw new ArgumentNullException(nameof(pathGeometry));
var pathFigure = new PathFigure { StartPoint = start };
var lineSegment = new LineSegment { Point = end };
pathFigure.Segments.Add(lineSegment);
pathGeometry.Figures.Add(pathFigure);
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:19,代码来源:PathHelper.cs
示例12: LineAndAreaShape
public LineAndAreaShape(PathFigure figure)
{
Figure = figure;
Right = new LineSegment(new Point(), false);
Bottom = new LineSegment(new Point(), false);
Left = new LineSegment(new Point(), false);
Figure.Segments.Add(Right);
Figure.Segments.Add(Bottom);
Figure.Segments.Add(Left);
}
开发者ID:g1ga,项目名称:Live-Charts,代码行数:11,代码来源:LineAndAreaShape.cs
示例13: UpdateShape
protected override void UpdateShape()
{
if (ShapeStart == ShapeEnd)
return;
figure.StartPoint = ShapeStart;
LineSegment segment = new LineSegment();
segment.Point = ShapeEnd;
figure.Segments.Add(segment);
}
开发者ID:mono,项目名称:lunareclipse,代码行数:11,代码来源:PenCreationTool.cs
示例14: Airbrush
/// <summary>
/// Paints on a pbgra32 WriteableBitmap with a stylized airbrush
/// </summary>
/// <param name="bmp">The bitmap to modify</param>
/// <param name="from">The starting point of the stroke</param>
/// <param name="to">The end point of the stroke</param>
/// <param name="color">The color of the stroke</param>
/// <param name="size">The size of the stroke</param>
public static unsafe void Airbrush(WriteableBitmap bmp, Point from, Point to, Color color, int size)
{
Random r = new Random();
if (bmp == null) return;
bmp.Lock();
// Create a line segment representation
LineSegment segment = new LineSegment(from, to);
// Get a bounding box for the painted area
BoundingBox bitmapbounds = new BoundingBox();
BoundingBox segmentbounds = new BoundingBox();
bitmapbounds.AddPoint(0, 0, 0);
bitmapbounds.AddPoint(bmp.PixelWidth - 1, bmp.PixelHeight - 1, 0);
segmentbounds.AddPoint((int)from.X, (int)from.Y, size + AirbrushDotRadius);
segmentbounds.AddPoint((int)to.X, (int)to.Y, size + AirbrushDotRadius);
segmentbounds.Clip(bitmapbounds);
UInt32* start = (UInt32*)bmp.BackBuffer.ToPointer();
int stride = bmp.BackBufferStride / sizeof(UInt32);
// Move from 'from' to 'to' along timestep intervals, with one dot painted per interval
for (int i = 0; i < AirbrushDots; i++)
{
int x, y;
segment.Interpolate(i, AirbrushDots, out x, out y);
int dist = r.Next() % size;
double angle = r.NextDouble() * 2 * Math.PI;
double dx = Math.Cos(angle) * dist;
double dy = Math.Sqrt(dist * dist - dx * dx);
if(angle > Math.PI) dy = -dy;
int bx = x + (int)dx;
int by = y + (int)dy;
BoundingBox dotbounds = new BoundingBox();
dotbounds.AddPoint(bx,by,AirbrushDotRadius);
dotbounds.Clip(bitmapbounds);
for (int k = dotbounds.Top, row = 0; k < dotbounds.Bottom; k++, y++, row++)
for (int j = dotbounds.Left, col = 0; j < dotbounds.Right; j++, col++)
WriteAlphaBlended(start + stride * k + j, Color.FromArgb(AirbrushDotKernel[row][col], color.R, color.G, color.B));
}
bmp.AddDirtyRect(new Int32Rect(segmentbounds.Left, segmentbounds.Top, segmentbounds.Width, segmentbounds.Height));
bmp.Unlock();
}
开发者ID:tuannsofta,项目名称:kinect4bag,代码行数:61,代码来源:BitmapHelpers.cs
示例15: InsertionAdorner
/// <summary>
/// Create the pen and triangle in a static constructor and freeze them to improve performance.
/// </summary>
static InsertionAdorner()
{
Pen = new Pen { Brush = Brushes.SkyBlue, Thickness = LineThickness };
Pen.Freeze();
var firstLine = new LineSegment(new Point(0, -TriangleWidth), false);
firstLine.Freeze();
var secondLine = new LineSegment(new Point(0, TriangleWidth), false);
secondLine.Freeze();
var figure = new PathFigure {StartPoint = new Point(TriangleWidth, 0)};
figure.Segments.Add(firstLine);
figure.Segments.Add(secondLine);
figure.Freeze();
Triangle = new PathGeometry();
Triangle.Figures.Add(figure);
Triangle.Freeze();
}
开发者ID:Orange637,项目名称:WpfStudy,代码行数:19,代码来源:InsertionAdorner.cs
示例16: GenerateBezierCurve
public static PathGeometry GenerateBezierCurve(Point[] points)
{
PathFigure pathFigure = new PathFigure();
PointCollection pointCollection = new PointCollection(points.Length);
pathFigure.StartPoint = new Point(points[0].X, points[0].Y);
PathGeometry myPathGeometry = new PathGeometry();
PathSegment pathSegment;
if (points.Length == 2)
{
pathSegment = new LineSegment();
((LineSegment)pathSegment).Point = new Point(points[1].X, points[1].Y);
}
else if (points.Length == 3)
{
pathSegment = new QuadraticBezierSegment();
((QuadraticBezierSegment)pathSegment).Point1 = new Point(points[1].X, points[1].Y);
((QuadraticBezierSegment)pathSegment).Point2 = new Point(points[2].X, points[2].Y);
}
else if (points.Length == 4)
{
for (int i = 1; i < points.Length; i++)
{
pointCollection.Add(points[i]);
}
pathSegment = new PolyBezierSegment();
((PolyBezierSegment)pathSegment).Points = pointCollection;
}
else
{
return null;
}
PathSegmentCollection pathSegmentCollection = new PathSegmentCollection();
pathSegmentCollection.Add(pathSegment);
pathFigure.Segments = pathSegmentCollection;
PathFigureCollection pathFigureCollection = new PathFigureCollection();
pathFigureCollection.Add(pathFigure);
myPathGeometry.Figures = pathFigureCollection;
return myPathGeometry;
}
开发者ID:BrettHewitt,项目名称:MWA,代码行数:47,代码来源:DrawingUtility.cs
示例17: Show
public void Show()
{
Color pixClr = new Color();
pixClr.A = 255;
pixClr.R = byte.Parse(PixelColor.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
pixClr.G = byte.Parse(PixelColor.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
pixClr.B = byte.Parse(PixelColor.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
RandomNumber = new Random();
for (int i = 0; i < 100; i++)
{
int xval = RandomNumber.Next((int)Width);
int yval = RandomNumber.Next((int)Height);
int xRval = xval+RandomNumber.Next(-20,20);
int yRval = yval + RandomNumber.Next(-20, 20);
int xR2val = xRval + RandomNumber.Next(-20, 20);
int yR2val = yRval + RandomNumber.Next(-20, 20);
Point startingPt = new Point(xval, yval);
Point randomPt = new Point(xRval, yRval);
Point randomPt2 = new Point(xR2val, yR2val);
Path pixel = new Path();
PathFigure pixelFigure = new PathFigure();
GeometryGroup geometry = new GeometryGroup();
LineSegment line1 = new LineSegment();
pixelFigure.StartPoint = startingPt;
line1.Point = randomPt;
LineSegment line2 = new LineSegment();
line2.Point = randomPt2;
LineSegment line3 = new LineSegment();
line3.Point = startingPt;
pixelFigure.Segments.Add(line1);
pixelFigure.Segments.Add(line2);
pixelFigure.Segments.Add(line3);
pixel.Stroke = new SolidColorBrush(pixClr);
pixel.Fill = new SolidColorBrush(pixClr);
// pixel.Stretch = Stretch.Fill;
PathGeometry pathGeo = new PathGeometry();
pathGeo.Figures.Add(pixelFigure);
pixel.Data = pathGeo;
ExplosionEffect.Children.Add(pixel);
}
}
开发者ID:fstn,项目名称:WindowsPhoneApps,代码行数:47,代码来源:ExplodeEffect.xaml.cs
示例18: AddPolygon
/// <summary>
/// Adds a polygon to a <see cref="PathGeometry"/>.
/// </summary>
/// <param name="pathGeometry">The <see cref="PathGeometry"/>.</param>
/// <param name="points">The points on the polygon.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="pathGeometry"/> is <see langword="null"/>.
/// </exception>
public static void AddPolygon(this PathGeometry pathGeometry, params Point[] points)
{
if (pathGeometry == null)
throw new ArgumentNullException(nameof(pathGeometry));
if (points == null || points.Length <= 1)
return;
var pathFigure = new PathFigure { StartPoint = points[0] };
for (int i = 1; i < points.Length; i++)
{
var lineSegment = new LineSegment { Point = points[i] };
pathFigure.Segments.Add(lineSegment);
}
pathGeometry.Figures.Add(pathFigure);
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:25,代码来源:PathHelper.cs
示例19: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
this.Root = base.GetTemplateChild("Root") as Border;
this.ArrowRow = base.GetTemplateChild("ArrowRow") as RowDefinition;
this.ToolTipPathFigure = base.GetTemplateChild("ToolTipPathFigure") as PathFigure;
this.BottomCenterLeft = base.GetTemplateChild("BottomCenterLeft") as LineSegment;
this.BottomLeftCorner1 = base.GetTemplateChild("BottomLeftCorner1") as LineSegment;
this.BottomLeftCorner2 = base.GetTemplateChild("BottomLeftCorner2") as ArcSegment;
this.TopLeftCorner1 = base.GetTemplateChild("TopLeftCorner1") as LineSegment;
this.TopLeftCorner2 = base.GetTemplateChild("TopLeftCorner2") as ArcSegment;
this.TopRightCorner1 = base.GetTemplateChild("TopRightCorner1") as LineSegment;
this.TopRightCorner2 = base.GetTemplateChild("TopRightCorner2") as ArcSegment;
this.BottomRightCorner1 = base.GetTemplateChild("BottomRightCorner1") as LineSegment;
this.BottomRightCorner2 = base.GetTemplateChild("BottomRightCorner2") as ArcSegment;
this.BottomCenterRight = base.GetTemplateChild("BottomCenterRight") as LineSegment;
}
开发者ID:guazipi,项目名称:bjAirPollution,代码行数:17,代码来源:PathToolTip.cs
示例20: ArrowControl
public ArrowControl()
{
endPt1 = new BezierSegment();
endPt2 = new LineSegment();
arrowPt1 = new LineSegment();
arrowPt2 = new LineSegment();
headPt = new LineSegment();
startPt2 = new BezierSegment();
startPt1 = new PathFigure()
{
Segments = new PathSegmentCollection() { endPt1, arrowPt1, headPt, arrowPt2, endPt2, startPt2 },
IsClosed = true
};
Shape = new Path() { Data = new PathGeometry() { Figures = new PathFigureCollection() { startPt1 } } };
Shape.Stroke = Brushes.Red;
Shape.Fill = fillBrush;
}
开发者ID:kellyelton,项目名称:octgnwlobby,代码行数:17,代码来源:ArrowControl.cs
注:本文中的System.Windows.Media.LineSegment类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论