public void Execute(params string[] parameters) { float x, y; try { if (!float.TryParse(parameters[0], out x)) { Console.WriteLine("Please check the correctness of the X!"); return; } if (!float.TryParse(parameters[1], out y)) { Console.WriteLine("Please check the correctness of the Y!"); return; } Point point = new Point(x, y); picture.Add(point); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } }
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); }
public void Execute(params string[] parameters) { float x, y, radius; try { if (!float.TryParse(parameters[0], out x)) { Console.WriteLine("Please check the correctness of the X!"); return; } if (!float.TryParse(parameters[1], out y)) { Console.WriteLine("Please check the correctness of the Y!"); return; } if (!float.TryParse(parameters[2], out radius)) { Console.WriteLine("Please check the correctness of the radius!"); return; } Circle circle = new Circle(x, y, radius); picture.Add(circle); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } }
public void Execute(params string[] parameters) { if (parameters.Length != 2) { Console.WriteLine("Введено некорректное количество аргументов"); return; } Point point = new Point(Single.Parse(parameters[0]), Single.Parse(parameters[1])); picture.Add(point); }
public void Execute(params string[] parameters) { if (parameters.Length != 3) { Console.WriteLine("Введено некорректное количество аргументов"); return; } PointF centre = new PointF(Single.Parse(parameters[0]), Single.Parse(parameters[1])); Circle circle = new Circle(centre, Single.Parse(parameters[2])); picture.Add(circle); }
public void Execute(params string[] parameters) { if (parameters.Length != 4) { Console.WriteLine("Введено некорректное количество аргументов"); return; } PointF begin = new PointF(Single.Parse(parameters[0]), Single.Parse(parameters[1])); PointF end = new PointF(Single.Parse(parameters[2]), Single.Parse(parameters[3])); Line line = new Line(begin, end); picture.Add(line); }
public void Execute(params string[] parameters) { if (parameters.Length != 5) { Console.WriteLine("Введено некорректное количество аргументов"); return; } PointF centre = new PointF(Single.Parse(parameters[0]), Single.Parse(parameters[1])); SizeF axises = new SizeF(Single.Parse(parameters[2]), Single.Parse(parameters[3])); Ellipse ellipse = new Ellipse(centre, axises, Single.Parse(parameters[4])); picture.Add(ellipse); }
public void Execute(params string[] args) { if (args.Length != 2) { Console.WriteLine("Введено некорректное количество аргументов"); return; } if (CheckArgs(args, out var parameters)) { return; } Point point = new Point(parameters[0], parameters[1]); picture.Add(point); }
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); } }
public void Execute(params string[] args) { if (args.Length != 3) { Console.WriteLine("Введено некорректное количество аргументов"); return; } if (CheckArgs(args, out var parameters)) { return; } PointF centre = new PointF(parameters[0], parameters[1]); Circle circle = new Circle(centre, parameters[2]); picture.Add(circle); }
public void Execute(params string[] args) { for (int i = 0; i < args.Length; i++) { args[i] = args[i].Replace(".", ","); } try { IShape shape = new Line(); shape.TryParse(args); picture.Add(shape); } catch (Exception x) { Console.WriteLine("Ошибка. " + x.Message); } }
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); } }
public void Execute(params string[] parameters) { float x, y, horizontalAxis, verticalAxis, rotate; try { if (!float.TryParse(parameters[0], out x)) { Console.WriteLine("Please check the correctness of the X!"); return; } if (!float.TryParse(parameters[1], out y)) { Console.WriteLine("Please check the correctness of the Y!"); return; } if (!float.TryParse(parameters[2], out horizontalAxis)) { Console.WriteLine("Please check the correctness of the horizontal axis!"); return; } if (!float.TryParse(parameters[3], out verticalAxis)) { Console.WriteLine("Please check the correctness of the vertical axis!"); return; } if (!float.TryParse(parameters[4], out rotate)) { Console.WriteLine("Please check the correctness of the rotate!"); return; } Ellipse ellipse = new Ellipse(x, y, horizontalAxis, verticalAxis, rotate); picture.Add(ellipse); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } }
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); } }
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); } }
public void Execute(params string[] args) { if (args.Length != 4) { Console.WriteLine("Введено некорректное количество аргументов"); return; } if (CheckArgs(args, out var parameters)) { return; } PointF begin = new PointF(parameters[0], parameters[1]); PointF end = new PointF(parameters[2], parameters[3]); Line line = new Line(begin, end); picture.Add(line); }
public void Execute(params string[] args) { if (args.Length != 5) { Console.WriteLine("Введено некорректное количество аргументов"); return; } if (CheckArgs(args, out var parameters)) { return; } PointF centre = new PointF(parameters[0], parameters[1]); SizeF axises = new SizeF(parameters[2], parameters[3]); Ellipse ellipse = new Ellipse(centre, axises, parameters[4]); picture.Add(ellipse); }
public void Execute(params string[] parameters) { float x1, y1, x2, y2; try { if (!float.TryParse(parameters[0], out x1)) { Console.WriteLine("Please check the correctness of the X1!"); return; } if (!float.TryParse(parameters[1], out y1)) { Console.WriteLine("Please check the correctness of the Y1!"); return; } if (!float.TryParse(parameters[2], out x2)) { Console.WriteLine("Please check the correctness of the X2!"); return; } if (!float.TryParse(parameters[3], out y2)) { Console.WriteLine("Please check the correctness of the Y2!"); return; } Line line = new Line(x1, y1, x2, y2); picture.Add(line); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } }