Ejemplo n.º 1
0
        private void RibbonButton_Click_5(object sender, RoutedEventArgs e)
        {
            AddEdge ed = new AddEdge();

            ed.setVetices((BidirectionalGraph <object, IEdge <object> >)GraphControl.Graph);
            if (ed.ShowDialog() == true)
            {
                BidirectionalGraph <object, IEdge <object> > grafo = ((BidirectionalGraph <object, IEdge <object> >)GraphControl.Graph);
                var l = Helpers.CopyGraphSharp(grafo);
                l.AddEdge(new TaggedEdge <object, object>(ed.Origem, ed.Destino, ed.Peso));
                GraphControl.Graph = l;
            }
        }
Ejemplo n.º 2
0
        private void ChangeButtonColors()
        {
            //powrót wszystkich przycisków do default
            AddVertex.ClearValue(BackgroundProperty);
            AddEdge.ClearValue(BackgroundProperty);
            DeleteElements.ClearValue(BackgroundProperty);
            MoveElements.ClearValue(BackgroundProperty);

            //zmiana koloru odpowiedniego przycisku oraz typu kursora nad poszczególnymi obiektami
            if (vertexFlag)
            {
                AddVertex.Background = Brushes.LightGreen;
                DrawSpace.Cursor     = Cursors.Pen;
                foreach (var item in graph.Edges)
                {
                    item.Cursor = Cursors.Arrow;
                }
                foreach (var item in graph.Vertices)
                {
                    item.Cursor = Cursors.Arrow;
                }
            }
            if (edgeFlag)
            {
                AddEdge.Background = Brushes.LightGreen;
                DrawSpace.Cursor   = Cursors.Arrow;
                foreach (var item in graph.Edges)
                {
                    item.Cursor = Cursors.Arrow;
                }
                foreach (var item in graph.Vertices)
                {
                    item.Cursor = Cursors.Hand;
                }
            }
            if (deleteFlag)
            {
                DeleteElements.Background = Brushes.LightGreen;
                DrawSpace.Cursor          = Cursors.Arrow;
                foreach (var item in graph.Edges)
                {
                    item.Cursor = Cursors.No;
                }
                foreach (var item in graph.Vertices)
                {
                    item.Cursor = Cursors.No;
                }
            }
            if (moveFlag)
            {
                MoveElements.Background = Brushes.LightGreen;
                DrawSpace.Cursor        = Cursors.Arrow;
                foreach (var item in graph.Edges)
                {
                    item.Cursor = Cursors.Arrow;
                }
                foreach (var item in graph.Vertices)
                {
                    item.Cursor = Cursors.SizeAll;
                }
            }
        }