Example #1
0
        public void Execute(params string[] parameters)
        {
            if (parameters.Length > 0)
            {
                Console.WriteLine("undo не нужны аргументы");
                return;
            }
            var shapes = CommandHistoryContainer.GetInstance().OnUndo();

            if (shapes == null)
            {
                Console.WriteLine("Нет действий, которые можно было бы откатить");
                return;
            }

            var currentShapes = picture.shapes;

            foreach (var shape in currentShapes.ToList())
            {
                picture.Remove(shape);
            }

            foreach (var shape in shapes)
            {
                picture.Add(shape);
            }

            SelectionContainer.GetInstance().OnUndo(picture.shapes);
        }
Example #2
0
        public void Execute(params string[] parameters)
        {
            try
            {
                if (parameters.Length < 1)
                {
                    throw new ArgumentException("Отсуствует аргумент");
                }

                picture.Group(parameters);

                CommandHistoryContainer.GetInstance().OnEdit();
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            var picture = new Picture();
            var ui      = new DrawableGUI(picture);
            var app     = new Application();

            app.AddCommand(new ExitCommand(app));
            app.AddCommand(new ExplainCommand(app));
            app.AddCommand(new HelpCommand(app));
            app.AddCommand(new DrawPointCommand(picture));
            app.AddCommand(new DrawLineCommand(picture));
            app.AddCommand(new DrawEllipseCommand(picture));
            app.AddCommand(new DrawCircleCommand(picture));
            app.AddCommand(new ListCommand(picture));
            app.AddCommand(new RemoveCommand(picture));
            app.AddCommand(new RotateCommand(picture));
            app.AddCommand(new ScaleCommand(picture));
            app.AddCommand(new TranslateCommand(picture));
            app.AddCommand(new GroupCommand(picture));
            app.AddCommand(new UngroupCommand(picture));
            app.AddCommand(new SelectionListCommand());
            app.AddCommand(new SelectCommand(picture));
            app.AddCommand(new SelectionAddCommand(picture));
            app.AddCommand(new SelectionRemoveCommand(picture));
            app.AddCommand(new UndoCommand(picture));
            app.AddCommand(new RedoCommand(picture));
            app.AddCommand(new SaveCommand(picture));
            app.AddCommand(new LoadCommand(app, picture));
            app.AddCommand(new ExportCommand(picture, new SvgExporter()));

            CommandHistoryContainer.Init(picture);

            picture.Changed += ui.Refresh;
            ui.Start();
            app.Run(Console.In);
            ui.Stop();
        }
Example #4
0
 public static void Init(Picture pic)
 {
     container = new CommandHistoryContainer();
     container.ToUndoStack.Push(new List <IShape>());
     picture = pic;
 }
Example #5
0
 public void UpdateHitory()
 {
     CommandHistoryContainer.GetInstance().OnEdit();
 }