protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Right) { bSelection = false; Invalidate(); return; } else if (e.Button == MouseButtons.Left) { if (bSelection) { if (e.Clicks == 2) { executeMove(); Invalidate(); } else { if (selection.getPoint(e.X / 16, e.Y / 16 + logicalRow)) { bDraggingTiles = true; srcSelection = selection.copy(); } else { bSelection = false; } } } if (!bDraggingTiles) { bSelectingRect = true; } mx1 = mx = e.X; my1 = my = e.Y; clip(ref mx1, ref my1); clip(ref mx, ref my); mtx = (mx + 8) / 16; mty = (my + 8) / 16 + logicalRow; bmtx0 = mx / 16; bmty0 = my / 16 + logicalRow; xDrag = 0; yDrag = 0; slideTimer.Enabled = true; Capture = true; Invalidate(); } }
public void copy() { if (!bSelection) { return; } Selection s = originalSelection; if (s.height > 0 && s.width > 0) { using (pr2.IRenderImage img = pr2.RenderImage.Create(s.width * 16, s.height * 16)) { int y0 = s.y; int x0 = s.x; for (int y = 0; y < s.height; y++) { for (int x = 0; x < s.width; x++) { if (!s.getPoint(x0 + x, y0 + y)) { continue; } int tileIndex = (y0 + y) * TilesWide + x + x0; Render.render(img, x * 16, y * 16, Global.ActiveVsp.GetTile(tileIndex).Image, true); } } WindowsClipboard.setImage(img); } } }