當前位置: 首頁>>代碼示例>>C#>>正文


C# Ellipse.GetRadius方法代碼示例

本文整理匯總了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);
        }
開發者ID:jnowicki,項目名稱:GraphUltra,代碼行數:53,代碼來源:MainWindow.xaml.cs


注:本文中的System.Windows.Shapes.Ellipse.GetRadius方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。