private void paper_MauseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { GraphicsObject lastDrawn = drawnObjects[drawnObjects.Count - 1]; float xscale = 0.1f + Math.Abs(e.X - firstState.X) / (float)lastDrawn.getWidth(); float yscale = 0.1f + Math.Abs(e.Y - firstState.Y) / (float)lastDrawn.getHeight(); lastDrawn.scale(xscale, yscale); g.Clear(Color.Black); redrawWithoutLast(); lastDrawn.draw(g); paper.Image = bmp; } if (!drawingSomething) { return; } if (mouseMode == "line") { g.DrawLine(mainPen, firstState, e.Location); drawnObjects.Add(new GraphicsObject(mainPen, "line", firstState, e.Location)); drawingSomething = false; paper.Image = bmp; return; } int width = e.Location.X - firstState.X; int height = e.Location.Y - firstState.Y; Point endPoint = new Point(firstState.X + width, firstState.Y + height); if (mouseMode == "ellipse") { g.DrawEllipse(mainPen, firstState.X, firstState.Y, width, height); drawnObjects.Add(new GraphicsObject(mainPen, "ellipse", firstState, endPoint)); } else { g.DrawRectangle(mainPen, firstState.X, firstState.Y, width, height); drawnObjects.Add(new GraphicsObject(mainPen, "rect", firstState, endPoint)); } drawingSomething = false; paper.Image = bmp; }
private void mainForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.A) { GraphicsObject lastDrawn = drawnObjects[drawnObjects.Count - 1]; lastDrawn.rotate(5); g.Clear(Color.Black); redrawWithoutLast(); lastDrawn.draw(g); paper.Image = bmp; } else if (e.KeyCode == Keys.D) { GraphicsObject lastDrawn = drawnObjects[drawnObjects.Count - 1]; lastDrawn.rotate(-5); g.Clear(Color.Black); redrawWithoutLast(); lastDrawn.draw(g); paper.Image = bmp; } }