Exemplo n.º 1
0
        public void Execute(params string[] parameters)
        {
            if (parameters.Length < 2)
            {
                Console.WriteLine("Не была введена ширина, или индексы фигур");
                return;
            }
            uint width = (uint)Int32.Parse(parameters[0]);

            for (int i = 1; i < parameters.Length; i++)
            {
                int index = Int32.Parse(parameters[i]);
                var shape = picture.GetShape(index);
                shape.Format.Width = width;
                picture.RemoveAt(index);
                picture.Add(index, shape);
            }
        }
Exemplo n.º 2
0
        public void Execute(params string[] parameters)
        {
            if (parameters.Length < 2)
            {
                Console.WriteLine("Не был введён цвет, или индексы фигур");
                return;
            }
            var color = ColorTranslator.FromHtml(parameters[0]);

            for (int i = 1; i < parameters.Length; i++)
            {
                int index = Int32.Parse(parameters[i]);
                var shape = picture.GetShape(index);
                shape.Format.Color = color;
                picture.RemoveAt(index);
                picture.Add(index, shape);
            }
        }
Exemplo n.º 3
0
        public void Execute(params string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Не была введена ширина, или индексы фигур");
                return;
            }

            uint width;

            try
            {
                width = (uint)Int32.Parse(args[0]);
            }
            catch (Exception e)
            {
                Console.WriteLine("Произошла ошибка при попытке распарсить ширину `{0}` : {1}",
                                  args[0], e.Message);
                return;
            }

            for (int i = 1; i < args.Length; i++)
            {
                int index = 0;
                try
                {
                    index = Int32.Parse(args[i]);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Произошла ошибка при попытке распарсить индекс '{args[i]}': {e.Message}");
                    return;
                }
                if (index < 0 || index >= picture.ShapesCount)
                {
                    Console.WriteLine($"Фигуры с индексом '{index}' не существует!");
                    return;
                }
                var shape = picture.GetShape(index);
                shape.Format.Width = width;
                picture.RemoveAt(index);
                picture.Add(index, shape);
            }
        }
Exemplo n.º 4
0
        public void Execute(params string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Не был введён цвет, или индексы фигур");
                return;
            }

            Color color = Color.Black;

            try
            {
                color = ColorTranslator.FromHtml(args[0]);
            }
            catch (Exception)
            {
                Console.WriteLine($"Произошла ошибка при попытке распарсить цвет");
                return;
            }

            for (int i = 1; i < args.Length; i++)
            {
                int index = 0;
                try
                {
                    index = Int32.Parse(args[i]);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Произошла ошибка при попытке распарсить индекс '{args[i]}': {e.Message}");
                    return;
                }
                if (index < 0 || index >= picture.ShapesCount)
                {
                    Console.WriteLine($"Фигуры с индексом '{index}' не существует!");
                    return;
                }
                var shape = picture.GetShape(index);
                shape.Format.Color = color;
                picture.RemoveAt(index);
                picture.Add(index, shape);
            }
        }