public SelectionChangedEventArgs(BlastCorpsItem item, bool added, bool deleted) { this.SelectedItem = item; this.IsAdded = added; this.IsDeleted = deleted; }
public ItemMovedEventArgs(BlastCorpsItem item) { this.SelectedItem = item; }
private void BlastCorpsViewer_MouseUp(object sender, MouseEventArgs e) { if (level != null && e.Button == System.Windows.Forms.MouseButtons.Left) { switch (Mode) { case MouseMode.Move: if (dragItem != null) { selectedItem = dragItem; OnSelectionChangedEvent(new SelectionChangedEventArgs(selectedItem, false, false)); dragItem = null; Invalidate(); } break; case MouseMode.Add: Int16 x = (Int16)levelX(e.X); Int16 z = (Int16)levelZ(e.Y); if (AddType == typeof(AmmoBox)) { AmmoBox box = new AmmoBox(x, level.carrier.y, z, 0); selectedItem = box; level.ammoBoxes.Add(box); } else if (AddType == typeof(CommPoint)) { CommPoint comm = new CommPoint(x, level.carrier.y, z, 0); selectedItem = comm; level.commPoints.Add(comm); } else if (AddType == typeof(RDU)) { RDU rdu = new RDU(x, level.carrier.y, z); selectedItem = rdu; level.rdus.Add(rdu); } else if (AddType == typeof(TNTCrate)) { TNTCrate tnt = new TNTCrate(x, level.carrier.y, z, 0, 0, 0, 0); selectedItem = tnt; level.tntCrates.Add(tnt); } else if (AddType == typeof(SquareBlock)) { SquareBlock block = new SquareBlock(x, level.carrier.y, z, SquareBlock.Type.Block, SquareBlock.Shape.Square); selectedItem = block; level.squareBlocks.Add(block); } else if (AddType == typeof(Vehicle)) { Vehicle vehicle = new Vehicle(0, x, level.carrier.y, z, 0); selectedItem = vehicle; level.vehicles.Add(vehicle); } else if (AddType == typeof(Building)) { Building building = new Building(x, level.carrier.y, z, 0, 0, 0, 0, 0); selectedItem = building; level.buildings.Add(building); } OnSelectionChangedEvent(new SelectionChangedEventArgs(selectedItem, true, false)); Invalidate(); break; } } }
private void BlastCorpsViewer_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { switch (Mode) { case MouseMode.Select: BlastCorpsItem item = FindNearbyItem(e.X, e.Y); if (item != selectedItem) { selectedItem = item; OnSelectionChangedEvent(new SelectionChangedEventArgs(selectedItem, false, false)); Invalidate(); } break; case MouseMode.Move: dragItem = FindNearbyItem(e.X, e.Y); if (dragItem != selectedItem) { selectedItem = dragItem; OnSelectionChangedEvent(new SelectionChangedEventArgs(selectedItem, false, false)); Invalidate(); } break; case MouseMode.Add: break; } } }
private void BlastCorpsViewer_KeyDown(object sender, KeyEventArgs e) { if (selectedItem != null) { if (e.KeyCode == Keys.Delete) { OnSelectionChangedEvent(new SelectionChangedEventArgs(selectedItem, false, true)); selectedItem = null; Invalidate(); } } }
private void doPicking(int mX, int mY) { // draw to back buffer paintByNumber(); // read pixel color at mouse position mX,mY byte[] pixel = new byte[3]; int[] viewport = new int[4]; // Y-axis flipped between OpenGL and window GL.GetInteger(GetPName.Viewport, viewport); GL.ReadPixels(mX, viewport[3] - mY - glControlViewer.Location.Y, 1, 1, PixelFormat.Rgb, PixelType.UnsignedByte, pixel); // reverse color mapping from RGB to type/list index int type = (int)pixel[2]; int index = (int)pixel[1] + (((int)pixel[0]) << 8); BlastCorpsItem curItem = selectedItem; if (index > -1) { labelType.Text = String.Format("Type: {0:X02}", type); labelIndex.Text = String.Format("Index: {0:X04}", index); switch (type) { case 0x20: // Ammo if (index < level.ammoBoxes.Count) { selectedItem = level.ammoBoxes[index]; } break; case 0x28: // Comm Pt. if (index < level.commPoints.Count) { selectedItem = level.commPoints[index]; } break; case 0x34: // RDU if (index < level.rdus.Count) { selectedItem = level.rdus[index]; } break; case 0x38: // TNT if (index < level.tntCrates.Count) { selectedItem = level.tntCrates[index]; } break; case 0x3C: // square blocks if (index < level.squareBlocks.Count) { selectedItem = level.squareBlocks[index]; } break; case 0x50: // vehicles if (index < level.vehicles.Count) { selectedItem = level.vehicles[index]; } break; case 0x54: // missile carrier selectedItem = level.carrier; break; case 0x5C: // buildings if (index < level.buildings.Count) { selectedItem = level.buildings[index]; } break; case 0xFF: // nothing selectedItem = null; break; } if (curItem != selectedItem) { glControlViewer.Invalidate(); } } }