protected virtual void drag_Changed(DragListener drag) { ArrowLine al = ExtendedItem.View as ArrowLine; var alignment = (drag.Target as DesignerThumb).Alignment; var info = operation.PlacedItems[0]; double dx = 0; double dy = 0; if (zoom != null) { dx = drag.Delta.X * (1 / zoom.CurrentZoom); dy = drag.Delta.Y * (1 / zoom.CurrentZoom); } double top, left, x, y, xtop, xleft; if (alignment == PlacementAlignment.TopLeft) { //normal values x = CurrentX2 - dx; y = CurrentY2 - dy; top = CurrentTop + dy; left = CurrentLeft + dx; //values to use when keys are pressed xtop = CurrentTop + CurrentY2; xleft = CurrentLeft + CurrentX2; } else { x = CurrentX2 + dx; y = CurrentY2 + dy; top = xtop = CurrentTop; left = xleft = CurrentLeft; } Bounds position = CalculateDrawing(x, y, left, top, xleft, xtop); ExtendedItem.Properties.GetProperty(ArrowLine.X1Property).SetValue(0); ExtendedItem.Properties.GetProperty(ArrowLine.Y1Property).SetValue(0); ExtendedItem.Properties.GetProperty(ArrowLine.X2Property).SetValue(position.X); ExtendedItem.Properties.GetProperty(ArrowLine.Y2Property).SetValue(position.Y); if (operation != null) { var result = info.OriginalBounds; result.X = position.Left; result.Y = position.Top; result.Width = Math.Abs(position.X); result.Height = Math.Abs(position.Y); info.Bounds = result.Round(); operation.CurrentContainerBehavior.BeforeSetPosition(operation); operation.CurrentContainerBehavior.SetPosition(info); } (drag.Target as DesignerThumb).InvalidateArrange(); ResetWidthHeightProperties(); }
private void initLine(Color c, LinkHeadType headType) { line = new ArrowLine(); line.ArrowAngle = 40; line.Stroke = new SolidColorBrush(c); switch (headType) { case LinkHeadType.DoubleHeaded: line.ArrowEnds = ArrowEnds.Both; break; case LinkHeadType.SingleHeaded: line.ArrowEnds = ArrowEnds.End; break; default: throw new NotSupportedException(); } line.StrokeThickness = ShapeUtils.LINE_WIDTH; line.Effect = ShapeUtils.ShadowProvider(); line.Tag = this; selMarker1 = ShapeUtils.MakeLinkEnd(); selMarker1.Tag = this; selMarker2 = ShapeUtils.MakeLinkEnd(); selMarker2.Tag = this; line.MouseWheel += MouseWheel; }
void Awake() { S = this; line = GetComponent <LineRenderer>(); line.enabled = false; points = new List <Vector3>(); }
private void EdgeLineMouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { ArrowLine templine = new ArrowLine(); templine = (ArrowLine)sender; templine.Stroke = tempStroke; }
protected virtual void Update() { if (!is_graph_invalid || graph == null) { return; } foreach (LineRenderer line in Lines.ToList()) { GameObject.Destroy(line.gameObject); } foreach (Graph.Edge edge in graph.Edges) { Color color = GetEdgeColor(edge); ArrowLine arrow_line = GameObject.Instantiate(Scene.Main.Prefabs.ArrowLine); arrow_line.transform.parent = transform; arrow_line.Line.useWorldSpace = true; arrow_line.Line.SetPosition(0, ApplyOffset(edge.A.GetPosition())); arrow_line.Line.SetPosition(1, ApplyOffset(edge.B.GetPosition())); arrow_line.Line.startWidth = arrow_line.Line.endWidth = GetEdgeWidth(edge); ColorMaterialProperty.SetValueOfOther(arrow_line.Line, color); arrow_line.Arrow.Color = color; arrow_line.Arrow.ArrowSize = GetEdgeWidth(edge) * 6; } is_graph_invalid = false; }
public GraphEdge(GraphVertex startV, GraphVertex endV, bool oriented, TextBox text, double w) { line = new ArrowLine(); this.StartVertex = startV; this.EndVertex = endV; line.Stroke = System.Windows.Media.Brushes.Black; this.line.X1 = Canvas.GetLeft(startV.ellipse) + startV.ellipse.ActualWidth / 2; this.line.Y1 = Canvas.GetTop(startV.ellipse) + startV.ellipse.ActualHeight / 2; this.line.X2 = Canvas.GetLeft(endV.ellipse) + endV.ellipse.ActualWidth / 2; this.line.Y2 = Canvas.GetTop(endV.ellipse) + endV.ellipse.ActualHeight / 2; double u_l = Math.Atan2(line.X1 - line.X2, line.Y1 - line.Y2); double u = Math.PI / 33; line.X1 = line.X1 + (-20) * Math.Sin(u_l); line.Y1 = line.Y1 + (-20) * Math.Cos(u_l); line.X2 = line.X2 + (20) * Math.Sin(u_l); line.Y2 = line.Y2 + (20) * Math.Cos(u_l); if (oriented) { this.line.ArrowEnds = ArrowEnds.End; } else { this.line.ArrowEnds = ArrowEnds.None; } line.StrokeThickness = 3; line.MouseEnter += new System.Windows.Input.MouseEventHandler(EdgeLineMouseEnter); line.MouseLeave += new System.Windows.Input.MouseEventHandler(EdgeLineMouseLeave); line.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(EdgeClick_empty_); WeightEdge = w; textBox = text; line.Tag = startV.ellipse.Tag.ToString() + ";" + endV.ellipse.Tag.ToString(); }
// TODO : Remove all hide/show extensions from here. protected virtual void drag_Started(DragListener drag) { ArrowLine al = ExtendedItem.View as ArrowLine; CurrentX2 = al.X2; CurrentY2 = al.Y2; CurrentLeft = (double)al.GetValue(Canvas.LeftProperty); CurrentTop = (double)al.GetValue(Canvas.TopProperty); var designPanel = ExtendedItem.Services.DesignPanel as DesignPanel; zoom = designPanel.TryFindParent <ZoomControl>(); if (resizeBehavior != null) { operation = PlacementOperation.Start(extendedItemArray, PlacementType.Resize); } else { changeGroup = this.ExtendedItem.Context.OpenGroup("Resize", extendedItemArray); } _isResizing = true; (drag.Target as DesignerThumb).IsPrimarySelection = false; }
private void eliminare_muchie(ArrowLine global_sageata) //eliminarea muchiei din vectorul de muchii si din matricea de adiacenta { int n1 = 0, n2 = 0; for (int i = 1; i <= nnm; i++) { if (muchii[i] == global_sageata) { for (int j = 1; j <= nnr; j++) { if (noduri[j] == ns[i]) { n1 = j; } } for (int j = 1; j <= nnr; j++) { if (noduri[j] == nf[i]) { n2 = j; } } muchii[i] = null; nf[i] = null; ns[i] = null; matrice[n1, n2] = 0; } } }
private void EdgeLineMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) { ArrowLine templine = new ArrowLine(); templine = (ArrowLine)sender; tempStroke = templine.Stroke; templine.Stroke = System.Windows.Media.Brushes.Green; templine.Cursor = System.Windows.Input.Cursors.Hand; }
public GraphEdge(ArrowLine line_, TextBox text, double w, GraphVertex v1, GraphVertex v2) { line = line_; this.StartVertex = v1; this.EndVertex = v2; line.MouseEnter += new System.Windows.Input.MouseEventHandler(EdgeLineMouseEnter); line.MouseLeave += new System.Windows.Input.MouseEventHandler(EdgeLineMouseLeave); WeightEdge = w; textBox = text; }
//class myc : IValueConverter //{ // #region IValueConverter Members // public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) // { // return value; // } // public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) // { // return value; // } // #endregion //} private void ResetLine(PrimesBigInteger counter, ArrowLine l) { if (l != null) { m_ArrowsMark.Add(counter, l); UIElementCollection children = ControlHandler.GetPropertyValue(ArrowArea, "Children") as UIElementCollection; ControlHandler.ExecuteMethod(children, "Remove", new object[] { l }); Thread.Sleep(100); ControlHandler.ExecuteMethod(children, "Add", new object[] { l }); } }
private void ResetLine(ArrowLine l) { ArrowLine ltmp = GetLine(l); if (ltmp != null) { UIElementCollection children = ControlHandler.GetPropertyValue(ArrowArea, "Children") as UIElementCollection; ControlHandler.ExecuteMethod(children, "Remove", new object[] { ltmp }); Thread.Sleep(100); ControlHandler.ExecuteMethod(children, "Add", new object[] { ltmp }); } }
private static ArrowLine GetStraightLine(Point from, Point to, Brush stroke) { var line = new ArrowLine(); line.Stroke = stroke; line.StrokeThickness = 2.0; line.ArrowEnds = ArrowEnds.End; line.ArrowLength = 8; line.X1 = from.X; line.Y1 = from.Y; line.X2 = to.X; line.Y2 = to.Y; return(line); }
//private void CreateArrow(PrimesBigInteger counter, Point from, Point to) //{ // ArrowLine l = null; // if (from.X == to.X && from.Y == to.Y) // { // AddCircle(counter, from.X, from.Y); // } // else // { // l = ControlHandler.CreateObject(typeof(ArrowLine)) as ArrowLine; // ControlHandler.SetPropertyValue(l, "Stroke", Brushes.Black); // ControlHandler.SetPropertyValue(l, "StrokeThickness", 1.5); // //ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.X1Property, new Binding("(Point.X)") { Source = from }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } }); // //ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.Y1Property, new Binding("(Point.Y)") { Source = from }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } }); // //ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.X2Property, new Binding("(Point.X)") { Source = to }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } }); // //ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.Y2Property, new Binding("(Point.Y)") { Source = to }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } }); // //l.SetBinding(Line.X1Property, new Binding("(Point.X)") { Source = from, Converter = new myc() }); // //l.SetBinding(Line.Y1Property, new Binding("(Point.Y)") { Source = from, Converter = new myc() }); // //l.SetBinding(Line.X2Property, new Binding("(Point.X)") { Source = to, Converter = new myc() }); // //l.SetBinding(Line.Y2Property, new Binding("(Point.Y)") { Source = to, Converter = new myc() }); // ControlHandler.SetPropertyValue(l, "X1", from.X); // ControlHandler.SetPropertyValue(l, "Y1", from.Y); // ControlHandler.SetPropertyValue(l, "X2", to.X); // ControlHandler.SetPropertyValue(l, "Y2", to.Y); // if (!ContainsLine(l)) // { // ControlHandler.AddChild(l, ArrowArea); // m_Arrows.Add(l); // m_ArrowsMark.Add(counter, l); // } // else // { // ResetLine(counter, l); // } // } //} private void CreateArrow(PrimesBigInteger counter, Ellipse from, Ellipse to) { if (from == to) { AddCircle(counter, from); } else { ArrowLine l = ControlHandler.CreateObject(typeof(ArrowLine)) as ArrowLine; ControlHandler.SetPropertyValue(l, "Stroke", Brushes.Black); ControlHandler.SetPropertyValue(l, "StrokeThickness", 1.5); //ControlHandler.SetPropertyValue(l, "X1", (double)ControlHandler.ExecuteMethod(PaintArea, "GetLeft", from)+3); //ControlHandler.SetPropertyValue(l, "Y1", (double)ControlHandler.ExecuteMethod(PaintArea, "GetTop", from)+3); //ControlHandler.SetPropertyValue(l, "X2", (double)ControlHandler.ExecuteMethod(PaintArea, "GetLeft", to)+3); //ControlHandler.SetPropertyValue(l, "Y2", (double)ControlHandler.ExecuteMethod(PaintArea, "GetTop", to)+3); ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.X1Property, new Binding("(Canvas.Left)") { Source = from }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } }); ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.Y1Property, new Binding("(Canvas.Top)") { Source = from }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } }); ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.X2Property, new Binding("(Canvas.Left)") { Source = to }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } }); ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.Y2Property, new Binding("(Canvas.Top)") { Source = to }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } }); Pair <Ellipse, Ellipse> pair = new Pair <Ellipse, Ellipse>(from, to); if (!m_SourceDestination.Contains(pair)) { m_SourceDestination.Add(pair); m_ArrowsWithSourceAndDestination.Add(pair, l); ControlHandler.AddChild(l, ArrowArea); //m_Arrows.Add(l); m_ArrowsMark.Add(counter, l); } else if (m_ArrowsWithSourceAndDestination.ContainsKey(pair)) { l = m_ArrowsWithSourceAndDestination[pair]; ResetLine(counter, l); } } }
private void initLine(Color c) { line = new ArrowLine(); line.Stroke = new SolidColorBrush(c); line.ArrowEnds = ArrowEnds.Start; line.ArrowAngle = 40; line.StrokeThickness = ShapeUtils.LINE_WIDTH; line.Effect = ShapeUtils.ShadowProvider(); line.Tag = this; selMarker1 = ShapeUtils.MakeMarker(); selMarker1.Tag = this; selMarker2 = ShapeUtils.MakeMarker(); selMarker2.Tag = this; }
void initLine(Color c) { line = new ArrowLine(); line.ArrowAngle = 40; line.Stroke = new SolidColorBrush(c); line.StrokeThickness = ShapeUtils.LINE_WIDTH; line.Effect = ShapeUtils.ShadowProvider(); line.Tag = this; selMarker1 = ShapeUtils.MakeLinkEnd(); selMarker1.Tag = this; selMarker2 = ShapeUtils.MakeLinkEnd(); selMarker2.Tag = this; line.MouseWheel += MouseWheel; }
private static void DrawLoop(Canvas canvas, Brush brush, Brush borderBrush, Brush labelBrush, Point location, double angle) { Brush[] brushes = new Brush[] { brush, borderBrush }; var tempPt = location.MoveTo(angle, LoopHeight); Point pt1Ctrl = tempPt.MoveTo(angle - 90, LoopHalfWidth); Point pt2Ctrl = tempPt.MoveTo(angle + 90, LoopHalfWidth); var ptArr = location.MoveTo(pt2Ctrl, StateEllipseDiameter / 2); for (int i = 0; i < brushes.Length; ++i) { if (brushes[i].Equals(Brushes.Transparent)) { continue; } // loop without arrow var bezier = new BezierSegment(); bezier.Point1 = pt1Ctrl; bezier.Point2 = pt2Ctrl; bezier.Point3 = location.MoveTo(pt2Ctrl, StateEllipseDiameter / 2 + 1); var path = new PathFigure(); path.StartPoint = location.MoveTo(pt1Ctrl, StateEllipseDiameter / 2); path.Segments.Add(bezier); var geo = new PathGeometry(); geo.Figures = new PathFigureCollection(); geo.Figures.Add(path); var loop = new Path(); loop.Data = geo; loop.Stroke = brushes[i]; loop.StrokeThickness = strokesThickness[i]; canvas.Add(loop, 0, 0, zIndexes[i]); // arrow ArrowLine arrow = MakeArrow(bezier.Point3, ptArr, brushes[i], strokesThickness[i]); canvas.Add(arrow, 0, 0, zIndexes[i]); } }
/// <summary> /// Draws a bent edge, with defined angles of exit and entry. /// </summary> /// <param name="canvas"></param> /// <param name="brush"></param> /// <param name="start"></param> /// <param name="startAngle"></param> /// <param name="end"></param> /// <param name="endAngle"></param> private static void DrawEdge(Canvas canvas, Brush brush, Brush borderBrush, Brush labelBrush, Point start, double startAngle, Point end, double endAngle) { Brush[] brushes = new Brush[] { brush, borderBrush }; double dist = start.Distance(end) / 2; Point startCtrl = start.MoveTo(startAngle, dist); Point endCtrl = end.MoveTo(endAngle, dist); var ptArr = end.MoveTo(endCtrl, StateEllipseDiameter / 2); for (int i = 0; i < brushes.Length; ++i) { if (brushes[i].Equals(Brushes.Transparent)) { continue; } // edge without arrow var bezier = new BezierSegment(); bezier.Point1 = startCtrl; bezier.Point2 = endCtrl; bezier.Point3 = end.MoveTo(endCtrl, StateEllipseDiameter / 2 + 1); var path = new PathFigure(); path.StartPoint = start.MoveTo(startCtrl, StateEllipseDiameter / 2); path.Segments.Add(bezier); var geo = new PathGeometry(); geo.Figures = new PathFigureCollection(); geo.Figures.Add(path); var edge = new Path(); edge.Data = geo; edge.Stroke = brushes[i]; edge.StrokeThickness = strokesThickness[i]; canvas.Add(edge, 0, 0, zIndexes[i]); // arrow ArrowLine arrow = MakeArrow(bezier.Point3, ptArr, brushes[i], strokesThickness[i]); canvas.Add(arrow, 0, 0, zIndexes[i]); } }
void drawArrow(Canvas canvas, Point fromPosition, Point toPosition) { ArrowLine arrow = new ArrowLine() { Stroke = new SolidColorBrush { Color = Colors.Black }, StrokeThickness = 1.5 }; arrow.X1 = fromPosition.X; arrow.Y1 = fromPosition.Y; arrow.X2 = toPosition.X + NODE_DIMENSION / 2; arrow.Y2 = toPosition.Y; canvas.Children.Add(arrow); }
private void AnalyzeAction(string command, bool undo) { try { StringReader stringReader = new StringReader(command); XmlReader xml = XmlReader.Create(stringReader); WorkSpace.Children.Clear(); Canvas tempcanv = ((Canvas)XamlReader.Load(xml)); List <object> listS = new List <object>(); foreach (var t in tempcanv.Children) { listS.Add(t); } tempcanv.Children.Clear(); graph = new Graph(WorkSpace, false); PlainIsCreated = true; foreach (var t in listS) { if (t is Ellipse) { graph.ReadVertex((Ellipse)t, graph.SearchVertexTextBox(listS, (Ellipse)t)); } } foreach (var t in listS) { if (t is ArrowLine) { if (undo) { graph.ReadEdge((ArrowLine)t, graph.SearchEdgeTextBox(listS, (ArrowLine)t), graph.SearchVertexByEllipse(graph.FileFindVertexByEllipse((ArrowLine)t, 1)), graph.SearchVertexByEllipse(graph.FileFindVertexByEllipse((ArrowLine)t, 2))); } else { ArrowLine line = (ArrowLine)t; line.ArrowEnds = ArrowEnds.None; graph.ReadEdge(line, graph.SearchEdgeTextBox(listS, line), graph.SearchVertexByEllipse(graph.FileFindVertexByEllipse(line, 1)), graph.SearchVertexByEllipse(graph.FileFindVertexByEllipse(line, 2))); } } } } catch (Exception e) { Xceed.Wpf.Toolkit.MessageBox.Show(e.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Draws straight edge from start point to end point. /// </summary> /// <param name="canvas"></param> /// <param name="brush"></param> /// <param name="start"></param> /// <param name="end"></param> private static void DrawEdge(Canvas canvas, Brush brush, Brush borderBrush, Brush labelBrush, Point start, Point end) { Brush[] brushes = new Brush[] { brush, borderBrush }; Point target = end.MoveTo(start, StateEllipseDiameter / 2); for (int i = 0; i < brushes.Length; ++i) { if (brushes[i].Equals(Brushes.Transparent)) { continue; } ArrowLine edge = MakeArrow(start, target, brushes[i], strokesThickness[i]); canvas.Add(edge, 0, 0, zIndexes[i]); } }
public void BuildCanvas() { ArrowLine aline1 = new ArrowLine(); aline1.Stroke = System.Windows.Media.Brushes.Green; aline1.StrokeThickness = 40; aline1.X1 = 0; aline1.Y1 = 50; aline1.X2 = 100; aline1.Y2 = 50; canv.Children.Add(aline1); DoubleAnimation animaDouble1 = new DoubleAnimation(10, 200, new Duration(new TimeSpan(0, 0, 0, 0, 500))); animaDouble1.AutoReverse = true; animaDouble1.RepeatBehavior = RepeatBehavior.Forever; aline1.BeginAnimation(ArrowLine.X2Property, animaDouble1); //ArrowAngleProperty }
private static ArrowLine MakeArrow(Point start, Point end, Brush strokeBrush, double strokeThickness) { ArrowLine poly = new ArrowLine(); poly.X1 = start.X; poly.Y1 = start.Y; poly.X2 = end.X; poly.Y2 = end.Y; poly.ArrowEnds = ArrowEnds.End; poly.ArrowLength = 10; poly.ArrowAngle = 60; poly.Stroke = strokeBrush; poly.StrokeThickness = strokeThickness; return(poly); }
private void CreateArrow(PrimesBigInteger i, Point from, Point to) { ArrowLine l = ControlHandler.CreateObject(typeof(ArrowLine)) as ArrowLine; ControlHandler.SetPropertyValue(l, "Stroke", Brushes.Black); ControlHandler.SetPropertyValue(l, "StrokeThickness", 1.0); ControlHandler.SetPropertyValue(l, "X1", from.X); ControlHandler.SetPropertyValue(l, "Y1", from.Y); ControlHandler.SetPropertyValue(l, "X2", to.X); ControlHandler.SetPropertyValue(l, "Y2", to.Y); if (!ContainsLine(l)) { ControlHandler.AddChild(l, ArrowArea); m_Arrows.Add(i, l); } else { ResetLine(l); } }
private void InitArrow(ShowArrowModel model) { ArrowLine arrow = new ArrowLine(); arrow.X1 = model.StartOffset.X; arrow.Y1 = model.StartOffset.Y; arrow.X2 = model.EndOffset.X; arrow.Y2 = model.EndOffset.Y; arrow.IsArrowClosed = true; arrow.ArrowEnds = ArrowEnds.End; SolidColorBrush brush = new SolidColorBrush(Colors.White); arrow.Stroke = brush; arrow.StrokeThickness = 15; LayoutRoot.Children.Add(arrow); }
private static void DrawStartArrow(Canvas canvas, Brush brush, Brush borderBrush, Point location, double angle) { Brush[] brushes = new Brush[] { brush, borderBrush }; Point start = new Point(0, 0).MoveTo(angle, StateEllipseDiameter); Point end = new Point(0, 0).MoveTo(angle, StateEllipseDiameter / 2); for (int i = 0; i < brushes.Length; ++i) { if (brushes[i].Equals(Brushes.Transparent)) { continue; } ArrowLine poly = MakeArrow(start, end, brushes[i], strokesThickness[i]); canvas.Add(poly, location.X, location.Y, zIndexes[i]); } }
private ArrowLine GetLine(ArrowLine l) { foreach (ArrowLine line in m_Arrows.Values) { double srcx1 = (double)ControlHandler.GetPropertyValue(line, "X1"); double srcx2 = (double)ControlHandler.GetPropertyValue(line, "X2"); double srcy1 = (double)ControlHandler.GetPropertyValue(line, "Y1"); double srcy2 = (double)ControlHandler.GetPropertyValue(line, "Y2"); double destx1 = (double)ControlHandler.GetPropertyValue(l, "X1"); double destx2 = (double)ControlHandler.GetPropertyValue(l, "X2"); double desty1 = (double)ControlHandler.GetPropertyValue(l, "Y1"); double desty2 = (double)ControlHandler.GetPropertyValue(l, "Y2"); if (srcx1 == destx1 && srcx2 == destx2 && srcy1 == desty1 && srcy2 == desty2) { return(line); } } return(null); }
// This method establishes a link between selected ellipse and specified one. // Returns a line geometry with updated positions to be processed outside. // Note: this is commonly to be used for drawing links with mouse when the line object is predefined outside this class // Arrowline class is taken from Petzold.Media2D public bool LinkTo(Ellipse source, Ellipse target, LineGeometry line) { ArrowLine aline1 = new ArrowLine(); _Line.Add(line); // Save as starting line for current thumb if (StartLines.ContainsKey(source.Uid)) { StartLines[source.Uid] = _Line; } else { StartLines.Add(source.Uid, _Line); } // Save as ending line for target thumb if (EndLines.ContainsKey(target.Uid)) { EndLines[target.Uid] = _Line; } else { EndLines.Add(target.Uid, _Line); } // Ensure both tumbs the latest layout source.UpdateLayout(); target.UpdateLayout(); // Update line position line.StartPoint = new Point(Canvas.GetLeft(source) + source.ActualWidth / 2, Canvas.GetTop(source) + source.ActualHeight / 2); line.EndPoint = new Point(Canvas.GetLeft(target) + target.ActualWidth / 2, Canvas.GetTop(target) + target.ActualHeight / 2); aline1.X1 = line.StartPoint.X; aline1.Y1 = line.StartPoint.Y; aline1.X2 = line.EndPoint.X; aline1.Y2 = line.EndPoint.Y; aline1.Stroke = Brushes.Black; aline1.StrokeThickness = 1; CanvasArea.Children.Add(aline1); return(true); }
//adauga structurile in vectori // trasare muchii private void desenl(Point s1, Point s2, Ellipse es, Ellipse ef) { ArrowLine sageata = new ArrowLine(); sageata.Stroke = Brushes.FloralWhite; sageata.Opacity = 0.4; sageata.StrokeThickness = 1.6; sageata.ArrowAngle = 60; sageata.ArrowLength = 10; sageata.X1 = s1.X; sageata.Y1 = s1.Y; sageata.X2 = s2.X; sageata.Y2 = s2.Y; ecran.Children.Add(sageata); //adaugarea muchiilor si a nodurilor respective intr-o structura pentru o stergere ulterioara mai usoara muchii[nnm] = sageata; ns[nnm] = es; nf[nnm] = ef; nnm++; //--- }
// Should create line from [1,1] to [50,50] public void LineTest() { Line mockLine1 = new Line(); Line mockLine2 = new Line(); ITool CurrentTool = new LineTool(); // user clicked on point [1,1] CurrentTool.GetShape(new CanvasEventArgs(new Point(1, 1), MouseState.DOWN), style); // user hold mouse and move CurrentTool.GetShape(new CanvasEventArgs(new Point(20, 20), MouseState.MOVE), style); CurrentTool.GetShape(new CanvasEventArgs(new Point(30, 30), MouseState.MOVE), style); // user release mouse ArrowLine l = (ArrowLine)CurrentTool.GetShape(new CanvasEventArgs(new Point(50, 50), MouseState.UP), style).TikzShape.Shape; Assert.AreEqual(1, l.X1); Assert.AreEqual(50, l.X2); Assert.AreEqual(1, l.Y1); Assert.AreEqual(50, l.Y2); }
/// <summary> /// 添加线条 /// 如果不存在就创建 /// </summary> public void ShowArrowLine(GameObject go) { if (arrowLine == null) { arrowLine = ArrowLine.CreateArrowLine(); } if (arrowLine != null) { arrowLine.ShowArrowLine(go); } }