public void ReadVertex(Ellipse ell, TextBox textBox) { ell.MouseLeftButtonDown += new MouseButtonEventHandler(EllipseLeftButtonDown); ell.MouseLeftButtonUp += new MouseButtonEventHandler(VertexLeftButtonUp); ell.MouseMove += new MouseEventHandler(DragAndDropVertex); ell.MouseEnter += new MouseEventHandler(IsMouseEnterVertex); ell.MouseLeave += new MouseEventHandler(IsMouseLeaveVertex); textBox.TextChanged += new System.Windows.Controls.TextChangedEventHandler(ChangeNameVertex); textBox.MouseDoubleClick += new MouseButtonEventHandler(TextBoxVertexDoubleClick); textBox.KeyDown += new KeyEventHandler(BreakFocus); textBox.MouseEnter += new MouseEventHandler(IsMouseOnTextBox); textBox.MouseMove += new MouseEventHandler(MouseMoveOnTextBox); GraphPlain.Children.Add(ell); GraphPlain.Children.Add(textBox); VertexesList.Add(new GraphVertex(ell, new List <GraphEdge>(), textBox, textBox.Text)); }
public void AddVertexOnPlain(Ellipse ell, TextBox textBox, double x, double y) { EnumerableVertexes++; Random randColor = new System.Random(); textBox.TextChanged += new System.Windows.Controls.TextChangedEventHandler(ChangeNameVertex); textBox.MouseDoubleClick += new MouseButtonEventHandler(TextBoxVertexDoubleClick); textBox.KeyDown += new KeyEventHandler(BreakFocus); textBox.MouseEnter += new MouseEventHandler(IsMouseOnTextBox); textBox.MouseMove += new MouseEventHandler(MouseMoveOnTextBox); textBox.CaretBrush = Brushes.Black; ell.MouseLeftButtonDown += new MouseButtonEventHandler(EllipseLeftButtonDown); ell.MouseLeftButtonUp += new MouseButtonEventHandler(VertexLeftButtonUp); ell.MouseMove += new MouseEventHandler(DragAndDropVertex); ell.MouseEnter += new MouseEventHandler(IsMouseEnterVertex); ell.MouseLeave += new MouseEventHandler(IsMouseLeaveVertex); ell.Height = 40; ell.Width = 40; textBox.Width = 40; textBox.Height = 25; textBox.FontSize = 16; textBox.FontWeight = FontWeights.Bold; textBox.BorderThickness = new Thickness(0, 0, 0, 0); textBox.TextAlignment = TextAlignment.Center; var color = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)); textBox.Background = color; textBox.Text = EnumerableVertexes.ToString(); textBox.Tag = EnumerableVertexes.ToString(); ell.Tag = textBox.Text; ell.Fill = new SolidColorBrush(Color.FromArgb((byte)randColor.Next(0, 255), (byte)randColor.Next(0, 255), (byte)randColor.Next(0, 255), (byte)randColor.Next(0, 255))); ell.Stroke = Brushes.Blue; ell.StrokeThickness = 3; Canvas.SetLeft(ell, x - 15); Canvas.SetTop(ell, y - 15); Canvas.SetZIndex(ell, 1); Canvas.SetLeft(textBox, Canvas.GetLeft(ell)); Canvas.SetTop(textBox, Canvas.GetTop(ell) + ell.Height + 1); Canvas.SetZIndex(textBox, 1); GraphPlain.Children.Add(ell); GraphPlain.Children.Add(textBox); VertexesList.Add(new GraphVertex(ell, new List <GraphEdge>(), textBox, textBox.Text)); }