private void btnOK_Click(object sender, EventArgs e) { string name = txtName.Text; int weight = 20; int volume = 30; int power = (int)nudPower.Value; int capacity = (int)nudCapacity.Value; int tempToMelt = (int) nudMeltTemp.Value; Bitmap lookingUp = new Bitmap(pboxLookingUp.Image); Bitmap lookingDown = new Bitmap(pboxLookingDown.Image); Bitmap lookingLeft = new Bitmap(pboxLookingLeft.Image); Bitmap lookingRight = new Bitmap(pboxLookingRight.Image); if (RobotEdited == null) { Components.Robot robot = new Components.Robot(name, weight, volume, power, capacity, tempToMelt, lookingUp, lookingRight, lookingDown, lookingLeft); ItemList.Add(robot); } else { RobotEdited.Name = name; RobotEdited.Power = power; RobotEdited.Capacity = capacity; RobotEdited.LookingUp = new Bitmap(lookingUp); RobotEdited.LookingDown = new Bitmap(lookingDown); RobotEdited.LookingLeft = new Bitmap(lookingLeft); RobotEdited.LookingRight = new Bitmap(lookingRight); RobotEdited.TempToMelt = tempToMelt; } }
private void btnOK_Click(object sender, EventArgs e) { string name = txtName.Text; int weight = 20; int volume = 30; int power = (int)nudPower.Value; int capacity = (int)nudCapacity.Value; int tempToMelt = (int)nudMeltTemp.Value; Bitmap lookingUp = new Bitmap(pboxLookingUp.Image); Bitmap lookingDown = new Bitmap(pboxLookingDown.Image); Bitmap lookingLeft = new Bitmap(pboxLookingLeft.Image); Bitmap lookingRight = new Bitmap(pboxLookingRight.Image); if (RobotEdited == null) { Components.Robot robot = new Components.Robot(name, weight, volume, power, capacity, tempToMelt, lookingUp, lookingRight, lookingDown, lookingLeft); ItemList.Add(robot); } else { RobotEdited.Name = name; RobotEdited.Power = power; RobotEdited.Capacity = capacity; RobotEdited.LookingUp = new Bitmap(lookingUp); RobotEdited.LookingDown = new Bitmap(lookingDown); RobotEdited.LookingLeft = new Bitmap(lookingLeft); RobotEdited.LookingRight = new Bitmap(lookingRight); RobotEdited.TempToMelt = tempToMelt; } }
/// <summary> /// Captura los clicks en el mapa. Este metodo es el encargado de modificar el mapa. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pboxGrid_MouseClick(object sender, MouseEventArgs e) { if (map != null) { int i = e.Y / map[0, 0].Image.Height; int j = e.X / map[0, 0].Image.Width; if (e.Button == MouseButtons.Left && lstCells.SelectedIndex != -1) { map[i, j] = (Cell)cellList[lstCells.SelectedIndex].Clone(); } else if (e.Button == MouseButtons.Right && lstItems.SelectedIndex != -1) { if (lstItems.SelectedIndex == itemList.Count) { map[i, j].Item = null; } else if (!(itemList[lstItems.SelectedIndex] is Components.Robot)) { map[i, j].Item = (Item)itemList[lstItems.SelectedIndex].Clone(); } else { Components.Robot robot = (Components.Robot)itemList[lstItems.SelectedIndex]; robot.PlaceInMap(map, new Point(i, j)); } } pboxGrid.Invalidate(); } }
// Para modificar un robot public DlgEditRobot(Components.Robot robotToEdit) { RobotEdited = robotToEdit; InitializeComponent(); }
public DlgEditRobot(Components.Robot robotToEdit) // Para modificar un robot { RobotEdited = robotToEdit; InitializeComponent(); }