private void ZoneSpecial(System.Windows.Forms.MouseEventArgs me) { int blockSize = (int)NudBlockSize.Value; int xVal = (int)(me.Location.X / blockSize); int yVal = (int)(me.Location.Y / blockSize); FrmPlaceSpecialBlock frmPlaceSpecialBlock = new FrmPlaceSpecialBlock(xVal, yVal); frmPlaceSpecialBlock.ShowDialog(); AreaEvent res = frmPlaceSpecialBlock.res; if (res.AType == GameEnums.AreaEvent_Type.NONE) { return; } List <AreaEvent> oldOnes = listEventBlock.GetAreaEvent(res.AType, GameEnums.Direction.NONE, "", res.XVal, res.YVal); if (oldOnes.Count() > 0) { listEventBlock.eventsSource.Remove(oldOnes.First()); } listEventBlock.eventsSource.Add(res); Pen mypen = new Pen(Color.Orange, 2f); g = Graphics.FromImage(DrawArea); g.DrawLine(mypen, xVal * blockSize, yVal * blockSize, xVal * blockSize + blockSize, yVal * blockSize + blockSize); g.DrawLine(mypen, xVal * blockSize + blockSize, yVal * blockSize, xVal * blockSize, yVal * blockSize + blockSize); PbPic.Image = DrawArea; g.Dispose(); }
private void ZoneSpecial(System.Windows.Forms.MouseEventArgs me) { int blockSize = (int)NudBlockSize.Value; int xVal = (int)(me.Location.X / blockSize); int yVal = (int)(me.Location.Y / blockSize); FrmPlaceSpecialBlock frmPlaceSpecialBlock = new FrmPlaceSpecialBlock(xVal, yVal); frmPlaceSpecialBlock.ShowDialog(); Tuple <String, String, Point> res = new Tuple <String, String, Point>(frmPlaceSpecialBlock.res.Item1, frmPlaceSpecialBlock.res.Item2, new Point(xVal, yVal)); if (res.Item1 == "" | res.Item2 == "") { return; } Tuple <String, String, Point> oldOne = GetSpecialBlockInfo(xVal, yVal); if (oldOne.Item1 != "") { if (MessageBox.Show("Le block est déjà défini, voulez-vous l'écraser ?", "block déjà défini") == DialogResult.Yes) { listSpecialBlock.Remove(oldOne); } } listSpecialBlock.Add(res); Pen mypen = new Pen(Color.Orange, 2f); g = Graphics.FromImage(DrawArea); g.DrawLine(mypen, xVal * blockSize, yVal * blockSize, xVal * blockSize + blockSize, yVal * blockSize + blockSize); g.DrawLine(mypen, xVal * blockSize + blockSize, yVal * blockSize, xVal * blockSize, yVal * blockSize + blockSize); PbPic.Image = DrawArea; g.Dispose(); }