protected override void OnMouseUp(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (bSelectingRect) { bSelectingRect = false; slideTimer.Enabled = false; Capture = false; bSelection = true; Rectangle r = Rectangle.FromLTRB( Math.Min(mtx, mtx1), Math.Min(mty, mty1), Math.Max(mtx, mtx1), Math.Max(mty, mty1)); selection.clear(); selection.setRectangle(r, true); originalSelection = selection.copy(); editLayer = new TileEditLayer(selection); Invalidate(); } if (bDraggingTiles) { slideTimer.Enabled = false; Capture = false; bSelection = true; bDraggingTiles = false; Invalidate(); } } }
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 / Global.TILE_SIZE, e.Y / Global.TILE_SIZE + 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 + Global.TILE_SIZE/2) / Global.TILE_SIZE; mty = (my + Global.TILE_SIZE/2) / Global.TILE_SIZE + logicalRow; bmtx0 = mx / Global.TILE_SIZE; bmty0 = my / Global.TILE_SIZE + logicalRow; xDrag = 0; yDrag = 0; slideTimer.Enabled = true; Capture = true; Invalidate(); } }
public void paste() { if (!WindowsClipboard.IsImage) return; if (!bSelection) return; pr2.IRenderImage img = WindowsClipboard.getImage(); int tx = img.Width / Global.TILE_SIZE; int ty = img.Height / Global.TILE_SIZE; Selection s = originalSelection; this.selection = originalSelection.copy(); if (tx != s.width) return; if (ty != s.height) return; Operations.OperationManager om = Global.opManager; om.beginGroup("VSP Manager: Paste Tiledata"); Ops.SetTiledataGroup stdg = new Ops.SetTiledataGroup(Global.ActiveVsp); int y0 = s.y; int x0 = s.x; int[] arrImg = img.GetArray(); for (int y = 0; y < s.height; y++) for (int x = 0; x < s.width; x++) { int t = (s.y + y) * TilesWide + s.x + x; stdg.addRecord(t, Global.Misc.sliceIntArrayImage(arrImg, img.Width, x * Global.TILE_SIZE, y * Global.TILE_SIZE, Global.TILE_SIZE, Global.TILE_SIZE)); } om.add(stdg); om.endGroupExec(); img.Dispose(); Invalidate(); }
public void updateGraphicsPath(GraphicsPath gp, int scale, int xofs, int yofs) { //todo: much optimization gp.Reset(); Selection sHorz = new Selection(r.Width, r.Height * 2); Selection sVert = new Selection(r.Width * 2, r.Height); int xo = r.Left * scale; int yo = r.Top * scale; for (int y = 0; y < r.Height; y++) { for (int x = 0; x < r.Width; x++) { if (getPoint(x + r.Left, y + r.Top)) { if (!getPoint(x - 1 + r.Left, y + r.Top)) { gp.StartFigure(); gp.AddLine(x * scale + xofs, y * scale + yofs, x * scale + xofs, y * scale + scale + yofs); gp.CloseFigure(); } //sVert.setPoint(x*2,y,true); if (!getPoint(x + 1 + r.Left, y + r.Top)) { gp.StartFigure(); gp.AddLine(x * scale + scale + xofs, y * scale + yofs, x * scale + scale + xofs, y * scale + scale + yofs); gp.CloseFigure(); } //sVert.setPoint(x*2+1,y,true); if (!getPoint(x + r.Left, y - 1 + r.Top)) { gp.StartFigure(); gp.AddLine(x * scale + xofs, y * scale + yofs, x * scale + scale + xofs, y * scale + yofs); gp.CloseFigure(); } // sHorz.setPoint(x,y*2,true); if (!getPoint(x + r.Left, y + 1 + r.Top)) { gp.StartFigure(); gp.AddLine(x * scale + xofs, y * scale + scale + yofs, x * scale + scale + xofs, y * scale + scale + yofs); gp.CloseFigure(); } // sHorz.setPoint(x,y*2+1,true); } } } Matrix m = new Matrix(); m.Translate((float)xo, (float)yo); gp.Transform(m); }
public Selection copy() { Selection s = new Selection(r.Width, r.Height); s.r = r; s.mask = (int[,])mask.Clone(); return s; }
public TileEditLayer(Selection sel) { }