Ejemplo n.º 1
0
        public void ExecuteCommand(string s)
        {
            string[] pole = s.Split(new char[]{' '});

            switch (pole[0])
            {
                case "AddV" :

                    int x = 0;
             					int.TryParse(pole[1],out x);
                    int y = 0;
                    int.TryParse(pole[2],out y);

                    ICommand c = new AddVToPosCommand(g, pos, x, y);

                    _invoker.ExecuteCommand(c);

                        break;

                case "DeleteV" :

                        Vertex v = nam.getVertex(pole[1]);

                        ICommand d = new DeleteVertexCommand(g, v);

                        _invoker.ExecuteCommand(d);

                        break;

                case "AddE" :

                        ICommand e = new AddEdgeCommand(g, nam.getVertex(pole[1]), nam.getVertex(pole[2]));
                        _invoker.ExecuteCommand(e);

                        break;

                case "DeleteE" :

                        ICommand f = new DeleteEdgeCommand(g, nam.getEdge(pole[1], pole[2]));
                        _invoker.ExecuteCommand(f);
                        break;

                case "Undo" :

                        _invoker.UndoCommand();

                        break;
            }
        }
Ejemplo n.º 2
0
        public void ExecuteCommand(string s)
        {
            string[] pole = s.Split(new char[]{' '});

            switch (pole[0])
            {
                case "AddV" :

                    int x = 0;
             					int.TryParse(pole[1],out x);
                    int y = 0;
                    int.TryParse(pole[2],out y);

                    ICommand c = new AddVToPosCommand(g, pos, x, y);

                    _invoker.ExecuteCommand(c);

                        break;

                case "DeleteV" :

                        Vertex v = nam.getVertex(pole[1]);

                        ICommand d = new DeleteVertexCommand(g, v);

                        _invoker.ExecuteCommand(d);

                        break;

                case "AddE" :

                        ICommand e = new AddEdgeCommand(g, nam.getVertex(pole[1]), nam.getVertex(pole[2]));
                        _invoker.ExecuteCommand(e);

                        break;

                case "DeleteE" :

                        ICommand f = new DeleteEdgeCommand(g, nam.getEdge(pole[1], pole[2]));
                        _invoker.ExecuteCommand(f);
                        break;

                case "Undo" :

                        _invoker.UndoCommand();

                        break;
            }
        }