public void BRecMouseDown(object sender, MouseButtonEventArgs e) { MyCanvas tempCanv = new MyCanvas(); tempCanv.Draw(); tempCanv.MouseLeftButtonDown += StartDrag; tempCanv.MouseRightButtonDown += RemoveClick; if (sender != null) { Ellipse Ell = (Ellipse)e.OriginalSource; Ell.MouseLeftButtonDown -= BRecMouseDown; var mouseWasDownOn = e.Source as FrameworkElement; string elementName = mouseWasDownOn.Uid; var StartCanv = SchemePlace.Children.OfType <MyCanvas>().FirstOrDefault(x => x.Uid.IndexOf(':' + elementName) > -1); Canvas.SetTop(tempCanv, Canvas.GetTop(StartCanv)); //Canvas.SetLeft(tempCanv, (Canvas.GetLeft(StartCanv) + (int)StartCanv.ElementImage.ActualWidth) // - (Canvas.GetLeft(StartCanv) + (int)StartCanv.ElementImage.ActualWidth) % 20 + 60); Canvas.SetLeft(tempCanv, (Canvas.GetLeft(StartCanv) + (int)StartCanv.ElementImage.ActualWidth) - (Canvas.GetLeft(StartCanv) + (int)StartCanv.ElementImage.ActualWidth) % 20 + 60); DrawConnectLine(StartCanv, tempCanv); DrowOutput(tempCanv); StartCanv.Children.Remove(Ell); StartCanv.Children.Remove(StartCanv.Out); tempCanv.PREVIOUS = StartCanv; StartCanv.NEXT = tempCanv; SchemePlace.Children.Add(tempCanv); } else { Canvas.SetTop(tempCanv, 20); Canvas.SetLeft(tempCanv, 20); DrowInput(tempCanv); DrowOutput(tempCanv); FirstElement = tempCanv; SchemePlace.Children.Add(tempCanv); } }