public static void DrawArc(this Graphics g, Pen p, WFArcWrapper a) { PointF[] arrow = new PointF[3] { new PointF(-10,-5), new PointF(0,0), new PointF(-10,5) }; double angle; Matrix dM; if (a.Points != null && a.Points.Length > 0) { angle = -Math.Atan2(tail.Coords.Y - a.Points[0].Y, a.Points[0].X - tail.Coords.X); PointF popravka = new PointF((float)Math.Cos(angle) * tail.Size.Width / 2, (float)Math.Sin(angle) * tail.Size.Height / 2); g.DrawLine(p, MGraphic.T(popravka.X, popravka.Y) * tail.Coords, a.Points[0]); for (int i = 0; i < a.Points.Length - 1; i++) g.DrawLine(p, a.Points[i], a.Points[i + 1]); try { angle = -Math.Atan2(a.Points[a.Points.Length - 1].Y - head.Coords.Y, head.Coords.X - a.Points[a.Points.Length - 1].X); popravka = new PointF((float)Math.Cos(angle) * head.Size.Width / 2, (float)Math.Sin(angle) * head.Size.Height / 2); g.DrawLine(p, a.Points[a.Points.Length - 1], MGraphic.T(-popravka.X, -popravka.Y) * head.Coords); dM = MGraphic.T(head.Coords.X - popravka.X, head.Coords.Y - popravka.Y) * MGraphic.R(angle * 180 / Math.PI) ; g.DrawLines(p, dM * arrow); } catch { } } else { //angle = -Math.Atan2(a.Tail.Coords.Y - a.Head.Coords.Y, a.Head.Coords.X - a.Tail.Coords.X); //PointF popravka = new PointF((float)Math.Cos(angle) * a.Head.Size.Width / 2, // (float)Math.Sin(angle) * a.Head.Size.Height / 2); //g.DrawLine(p, MGraphic.T(popravka.X, popravka.Y) * a.Tail.Coords, MGraphic.T(-popravka.X, -popravka.Y) * a.Head.Coords); //dM = // MGraphic.T(a.Head.Coords.X - popravka.X, a.Head.Coords.Y - popravka.Y) // * MGraphic.R(angle * 180 / Math.PI) // ; //g.DrawLines(p, dM * arrow); g.DrawLine(p, tail.Center, head.Center); } }
void DrawingGraph(object sender, PaintEventArgs e) { MagicLibrary.MathUtils.Matrix m = this.TransformationMatrix; e.Graphics.Transform = m.ToSystemMatrix(); graphWrapper.Draw(e.Graphics, Pens.Black); #warning гавнокод! #region Вывод куска дуги при добавлении if (selectedVertexIndex != -1 && points != null && points.Count > 0) { Arc wArc = new Arc(graphWrapper.Graph, graphWrapper.VertexWrappers[selectedVertexIndex].Name, null); WFArcWrapper arc = new WFArcWrapper(graphWrapper, wArc) { Points = points.ToArray() }; arc.Draw(e.Graphics, Pens.Gray); } #endregion if (selectionVertexIndex != -1) //e.Graphics.DrawRectangle( // Pens.Green, // graphWrapper[selectionVertexIndex].SelectionRectangle //); e.Graphics.DrawRectangle(Pens.Green, (graphWrapper.VertexWrappers[selectionVertexIndex] as WFVertexWrapper).SelectionRectangle); if (selectedVertexIndex != -1) (graphWrapper.VertexWrappers[selectedVertexIndex] as WFVertexWrapper).Draw(e.Graphics, Pens.Green); if (selectionArcIndex != -1) { WFArcWrapper selArc = graphWrapper.ArcWrappers[selectionArcIndex] as WFArcWrapper; //e.Graphics.DrawRectangle(Pens.Red, selArc.WeightRectangle(e.Graphics)); e.Graphics.DrawRectangle(Pens.Red, selArc.TextRectangle(e.Graphics)); selArc.Draw(e.Graphics, Pens.Red, true); if (selectionArcPointIndex != -1) { //e.Graphics.FillEllipse(Brushes.Azure, // selArc.Points[selectionArcPointIndex].X - 2, // selArc.Points[selectionArcPointIndex].Y - 2, // 4, // 4); //e.Graphics.DrawEllipse(Pens.Black, // selArc.Points[selectionArcPointIndex].X - 2, // selArc.Points[selectionArcPointIndex].Y - 2, // 4, // 4); e.Graphics.FillEllipse(Brushes.Azure, selArc.PointRectangle(selectionArcPointIndex)); e.Graphics.DrawEllipse(Pens.Black, selArc.PointRectangle(selectionArcPointIndex)); //MagicLibrary.Graphic.MGraphic.DrawFillEllipse(e.Graphics,Brushes.Azure, selArc.PointRectangle(selectionArcPointIndex)); //MagicLibrary.Graphic.MGraphic.DrawEllipse(e.Graphics,Pens.Black, selArc.PointRectangle(selectionArcPointIndex)); } } }