本文整理汇总了C#中System.Windows.Shapes.Ellipse.GetRadius方法的典型用法代码示例。如果您正苦于以下问题:C# Ellipse.GetRadius方法的具体用法?C# Ellipse.GetRadius怎么用?C# Ellipse.GetRadius使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Shapes.Ellipse
的用法示例。
在下文中一共展示了Ellipse.GetRadius方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createEdge
private void createEdge(Ellipse startVert, Ellipse endVert, string edgeName)
{
Vector startVertVec = VisualTreeHelper.GetOffset(startVert);
Vector endVertVec = VisualTreeHelper.GetOffset(endVert);
// Vectors are created in the upper left corner of ellipse, so move the vector to center.
Point startCenterPt = new Point(startVertVec.X + startVert.GetRadius(), startVertVec.Y + startVert.GetRadius());
Point endCenterPt = new Point(endVertVec.X + endVert.GetRadius(), endVertVec.Y + endVert.GetRadius());
Path edge = new Path();
edge.Name= edgeName;
//make shaft
LineGeometry shaftGeo = new LineGeometry();
rescaleLine(shaftGeo, startCenterPt, endCenterPt, startVert.GetRadius(), endVert.GetRadius());
//make arrowhead
Vector vect = startCenterPt - endCenterPt;
vect.Normalize();
vect *= (Math.Sqrt(Math.Pow(startCenterPt.X - endCenterPt.X, 2) + Math.Pow(startCenterPt.Y - endCenterPt.Y, 2)) / 14) + 10;
Matrix rotationMx = new Matrix();
LineGeometry arrowHead1 = new LineGeometry();
arrowHead1.StartPoint = shaftGeo.EndPoint;
rotationMx.Rotate(30);
arrowHead1.EndPoint = shaftGeo.EndPoint + vect * rotationMx;
LineGeometry arrowHead2 = new LineGeometry();
arrowHead2.StartPoint = shaftGeo.EndPoint;
rotationMx.Rotate(-60);
arrowHead2.EndPoint = shaftGeo.EndPoint + vect * rotationMx;
// group shaft + arrowhead
GeometryGroup edgeGeo = new GeometryGroup();
edgeGeo.Children.Add(shaftGeo);
edgeGeo.Children.Add(arrowHead1);
edgeGeo.Children.Add(arrowHead2);
edge.Data = edgeGeo;
edge.Stroke = Brushes.Blue;
edge.StrokeThickness = 2;
TextBox capacityBox = new TextBox();
capacityBox.Width = 30;
capacityBox.Text = "";
capacityBox.Tag = edge;
capacityBox.Name = edgeName + "capacity";
//capacityBox.LostKeyboardFocus += capacityBox_LostKeyboardFocus;
capacityBox.KeyUp += capacityBox_KeyUp;
Canvas.SetLeft(capacityBox, (startCenterPt.X + endCenterPt.X) / 2);
Canvas.SetTop(capacityBox, (startCenterPt.Y + endCenterPt.Y) / 2);
canvas.Children.Add(capacityBox);
canvas.Children.Add(edge);
vertices.ForEach(x => x.MouseDown -= vertice_MouseDown);
capacityBox.Tag = edge;
Keyboard.Focus(capacityBox);
}