private void addCircle() { ++scnt; ShapeWrapper sw = new ShapeWrapper(type.CIRCLE, new Ellipse()); shps.Add(sw); }
private void addSquare() { ++scnt; ShapeWrapper sw = new ShapeWrapper(type.SQUARE, getSquare()); shps.Add(sw); }
private void addLine() { ++scnt; ShapeWrapper sw = new ShapeWrapper(type.LINE, getLine()); shps.Add(sw); }
/// <summary> /// dots is just a pixel by pixel square, used for the pen tool. /// </summary> private Rectangle addDotToShapesList() { ShapeWrapper sw = new ShapeWrapper(type.PEN, getSquare()); shps.Add(sw); penUndoCount.Push(penUndoCount.Pop() + 1); return(sw.s as Rectangle); }
private void incDecShapeSize(ShapeWrapper last, int p) { if (last.t == type.PEN || last.t == type.LINE) { return; } last.s.Height += p; last.s.Width += p; }
private void moveShape(ShapeWrapper shapeWrapper, double directionX, double directionY) { type t = shapeWrapper.t; if (isNotLegalMove(shapeWrapper.s, directionX, directionY)) { return; } switch (t) { case type.CIRCLE: Ellipse el = (Ellipse)shapeWrapper.s; Canvas.SetLeft(el, Canvas.GetLeft(el) + directionX); Canvas.SetTop(el, Canvas.GetTop(el) + directionY); break; case type.LINE: Line l = (Line)shapeWrapper.s; l.X1 += directionX; l.X2 += directionX; l.Y1 += directionY; l.Y2 += directionY; break; case type.SQUARE: Rectangle rec = (Rectangle)shapeWrapper.s; double left = Canvas.GetLeft(rec) + directionX; double top = Canvas.GetTop(rec) + directionY; if (left > canvXSize || left < 0 || top > canvYSize || top < 0 || left + rec.Width > canvXSize || top + rec.Height > canvYSize) { break; } Canvas.SetLeft(rec, Canvas.GetLeft(rec) + directionX); Canvas.SetTop(rec, Canvas.GetTop(rec) + directionY); print(Canvas.GetTop(rec).ToString()); break; } }
private void addCircle() { ShapeWrapper sw = new ShapeWrapper(type.CIRCLE, getEllipse()); shps.Add(sw); }
/// <summary> /// Do action of respective hotkey shown in GUI. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_KeyDown(object sender, KeyEventArgs e) { switch (e.Key) { case Key.E: this.isWhite = !this.isWhite; this.isWhiteCheckBox.IsChecked = !this.isWhiteCheckBox.IsChecked; break; default: // if at all, keys that depend on the existence of a shape on screen. if (!shps.Any()) // if no object exists, done. { break; } ShapeWrapper last = shps.Last(); switch (e.Key) { case Key.U: if (!shps.Any()) { return; } if (last.t == type.PEN) // then delete scribble. { int size = penUndoCount.Peek(); for (int i = 0; i < size; ++i) { removeLastShape(); } penUndoCount.Pop(); } else { removeLastShape(); } break; // move object in direction (doesn't apply for pen tool). // didn't use arrows bc interferes with buttons and crap. case Key.A: //left moveShape(last, -1, 0); break; case Key.D: //right moveShape(last, 1, 0); break; case Key.W: //up moveShape(last, 0, -1); break; case Key.S: //down moveShape(last, 0, 1); break; case Key.Q: incDecShapeSize(last, 1); break; case Key.Z: incDecShapeSize(last, -1); break; } break; } }
private void addLineToShapesList() { ShapeWrapper sw = new ShapeWrapper(type.LINE, getLine()); shps.Add(sw); }