Пример #1
0
        public void ReadEdge(Petzold.Media2D.ArrowLine line, TextBox textBox, GraphVertex v1, GraphVertex v2)
        {
            textBox.TextChanged      += new System.Windows.Controls.TextChangedEventHandler(ChangeEdgeWeight);
            textBox.KeyUp            += new KeyEventHandler(KeyEnterClickTextBox);
            textBox.MouseEnter       += new MouseEventHandler(IsMouseOnTextBox);
            textBox.MouseDoubleClick += new MouseButtonEventHandler(TextBoxVertexDoubleClick);
            textBox.MouseMove        += new MouseEventHandler(MouseMoveOnTextBox);
            GraphEdge tempEdge = new GraphEdge(line, textBox, Convert.ToDouble(textBox.Text), v1, v2);

            foreach (var t in VertexesList)
            {
                if (t.ellipse == v1.ellipse)
                {
                    t.lines.Add(tempEdge);
                }
                if (t.ellipse == v2.ellipse)
                {
                    t.lines.Add(tempEdge);
                }
            }
            tempEdge.line.MouseLeftButtonUp += new MouseButtonEventHandler(LineEdgeMouseClick);
            GraphPlain.Children.Add(tempEdge.line);
            GraphPlain.Children.Add(textBox);
            EdgesList.Add(tempEdge);
        }
Пример #2
0
        public void ConnectVertex(GraphVertex e1, GraphVertex e2)
        {
            if (e1 == e2)
            {
                return;
            }
            if (EdgeAlreadyExist(e1, e2))
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Ребро уже было добавлено!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            TextBox textBox = new System.Windows.Controls.TextBox();

            GraphEdge tempEdge_ = new GraphEdge(e1, e2, IsOriented, textBox, 0);

            RewriteTextBoxEdge(tempEdge_, textBox);
            textBox.TextChanged += new System.Windows.Controls.TextChangedEventHandler(ChangeEdgeWeight);
            textBox.KeyUp       += new KeyEventHandler(KeyEnterClickTextBox);
            textBox.CaretBrush   = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            textBox.Width        = 30;
            textBox.Height       = 25;
            textBox.FontSize     = 16;
            textBox.FontWeight   = FontWeights.Bold;
            var color = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

            textBox.Background        = Brushes.White;
            textBox.BorderThickness   = new Thickness(0, 0, 0, 0);
            textBox.TextAlignment     = TextAlignment.Center;
            textBox.Text              = "1";
            textBox.Tag               = tempEdge_.line.Tag.ToString();
            textBox.MouseEnter       += new MouseEventHandler(IsMouseOnTextBox);
            textBox.MouseDoubleClick += new MouseButtonEventHandler(TextBoxVertexDoubleClick);
            textBox.MouseMove        += new MouseEventHandler(MouseMoveOnTextBox);
            //textBox.MouseLeftButtonUp += new MouseButtonEventHandler(MouseLeftDown);
            GraphEdge tempEdge = new GraphEdge(e1, e2, IsOriented, textBox, Convert.ToDouble(textBox.Text));

            foreach (var t in VertexesList)
            {
                if (t.ellipse == e1.ellipse)
                {
                    t.lines.Add(tempEdge);
                }
                if (t.ellipse == e2.ellipse)
                {
                    t.lines.Add(tempEdge);
                }
            }
            tempEdge.line.MouseLeftButtonUp += new MouseButtonEventHandler(LineEdgeMouseClick);
            GraphPlain.Children.Add(tempEdge.line);
            GraphPlain.Children.Add(textBox);
            EdgesList.Add(tempEdge);
        }
Пример #3
0
 public void AddEdge(Edge A)
 {
     EdgesList.Add(A);
 }