public void Execute(IList <string> arguments)
        {
            if (arguments.Count == 1)
            {
                _writer.WriteLine("Specify shape!");
                return;
            }

            var containableShape = arguments[1];

            if (ShapeMappings.ShapeNameToTypeMap.TryGetValue(containableShape, out ShapeType type))
            {
                var   shapeAttributes = TextProcessingUtils.SplitAttributes(arguments);
                Shape newShape        = _shapeFactory.CreateShape(type, shapeAttributes);
                if (newShape is IContainable)
                {
                    var parsedShape = newShape as IContainable;
                    _shapeContainer.CheckWithin(parsedShape);
                }
                else
                {
                    _writer.WriteLine("Can't use this shape!");
                }
            }
            else
            {
                _writer.WriteLine("Shape not supported!");
            }
        }
        public void Execute(IList <string> arguments)
        {
            if (string.IsNullOrEmpty(_shapeParser.CurrentFile))
            {
                _writer.WriteLine("No file loaded!");
                return;
            }

            if (arguments.Count == 1)
            {
                _writer.WriteLine("Specify figure type!");
                return;
            }

            var shapeTypeArgument = arguments[1];

            if (ShapeMappings.ShapeNameToTypeMap.TryGetValue(shapeTypeArgument, out ShapeType reslovedShapeType))
            {
                var shapeAttributes = TextProcessingUtils.SplitAttributes(arguments);

                Shape newShape = _shapeFactory.CreateShape(reslovedShapeType, shapeAttributes);
                _shapeContainer.Shapes.Add(newShape);
                _writer.WriteLine("Successfully created shape!");
            }
            else
            {
                _writer.WriteLine("No such shape supported!");
            }
        }
        public void Execute(IList <string> arguments)
        {
            int horizontal = 0;
            int vertical   = 0;

            var attributes = TextProcessingUtils.SplitAttributes(arguments);

            if (attributes.TryGetValue("horizontal", out string value))
            {
                if (int.TryParse(value, out int parsed))
                {
                    horizontal = parsed;
                }
                else
                {
                    _writer.WriteLine("Invalid number for horizontal translation. Set to 0.");
                }
            }

            if (attributes.TryGetValue("vertical", out value))
            {
                if (int.TryParse(value, out int parsed))
                {
                    vertical = parsed;
                }
                else
                {
                    _writer.WriteLine("Invalid number for vertical translation. Set to 0.");
                }
            }

            if (arguments.Count > 3)
            {
                string shapeIndex = arguments[3];
                if (int.TryParse(shapeIndex, out int parsed))
                {
                    _shapeContainer.Translate(horizontal, vertical, parsed);
                }
                else
                {
                    _writer.WriteLine("Invalid shape number!");
                }

                return;
            }

            _shapeContainer.TranslateAll(horizontal, vertical);
        }
        private IList <Shape> ParseTagsToObjects(IList <string> tags)
        {
            IList <Shape> parsedShapes = new List <Shape>();

            foreach (var tag in tags)
            {
                IList <string> tagArguments = TextProcessingUtils.SplitTokens(tag);
                IDictionary <string, string> shapeAttributes = TextProcessingUtils.SplitAttributes(tagArguments);

                if (ShapeMappings.TagToShapeTypeMap.TryGetValue(tagArguments[0], out ShapeType type))
                {
                    Shape parsed = _shapeFactory.CreateShape(type, shapeAttributes);
                    parsedShapes.Add(parsed);
                }
            }

            return(parsedShapes);
        }
        public void InvokeCommand(string commandLine)
        {
            IList <string> arguments = TextProcessingUtils.SplitTokens(commandLine);

            if (arguments.Count == 0)
            {
                _writer.WriteLine("No command entered!");
                return;
            }

            if (_commandMap.TryGetValue(arguments[0], out ICommand mappedCommand))
            {
                mappedCommand.Execute(arguments);
            }
            else
            {
                _writer.WriteLine("Command not supported!");
            }
        }