public override object Clone() { List <Shape> listShapes = new List <Shape>(); for (int i = 0; i < listShapesNew.Count; i++) { listShapes.Add((Shape)(listShapesNew[i].Clone())); } NewShape newShape = new NewShape(StartX, StartY, FinishX, FinishY, listShapes); return(newShape); }
private void createNewFigureToolStripMenuItem_Click(object sender, EventArgs e) { NewShape newShape = new NewShape(0, 0, pictureBox.Width, pictureBox.Height, shapes); InputBox.InputBox inputBox = new InputBox.InputBox(); inputBox.TextMessage = "Input name:"; string nameNewShape = inputBox.getString(); if (!CheckNameFigure(nameNewShape)) { MessageBox.Show("Shape cann't create, because this name exist!", "Error create new shape", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (nameNewShape == "") { MessageBox.Show("Shape cann't create, because you don't pointer name!", "Error create new shape", MessageBoxButtons.OK, MessageBoxIcon.Warning); } newShapes.Add(nameNewShape, (NewShape)(newShape.Clone())); cb_Figures.Items.Add(nameNewShape); SaveNewFigures(); }
private Shape returnNewFigure(string name, int startX, int startY, int finishX, int finishY, Color color, int widthPen) { if (typeOfFigures.ContainsKey(name)) { Type typeFigure = typeOfFigures[name]; return((Shape)Activator.CreateInstance(typeFigure, startX, startY, finishX, finishY, color, widthPen)); } if (newShapes.ContainsKey(name)) { NewShape temp = (NewShape)(newShapes[name].Clone()); temp.StartX = startX; temp.StartY = startY; temp.FinishX = finishX; temp.FinishY = finishY; temp.Color = color; temp.WidthPen = widthPen; return((Shape)temp); } return(null); }