public override void Complete(SketchControl s, Point p1, Point p2) { shapeAction shapeAction = new shapeAction(Shape.Circle, true, p2, width, p1, this.brush, 0); s.sketch.stuff.Add(shapeAction); s.sketch.undo.Push(shapeAction); s.sketch.redo.Clear(); }
public SketchWindow(int amount) { ISketchTool[] theTools = { new PenTool(), new TextTool(), new LineTool(), new YinYangTool(), new RectangleTool(), new FilledRectangleTool(), new EllipsTool(), new FilledEllipsTool(), new DeleteTool() }; // Lists all the available colors that can be used by the enduser to draw. List<Color> allColors = new List<Color>(); foreach (var colorValue in Enum.GetValues(typeof(KnownColor))) allColors.Add(Color.FromKnownColor((KnownColor)colorValue)); String[] theColors = new string[allColors.Count]; for (int i = 27; i < allColors.Count - 7; i++) theColors[i] = allColors[i].Name; // Makes the name of the seperate sketch windows count up. this.ClientSize = new Size(750, 640); this.Text = "Sketch " + amount; currentTool = theTools[0]; // Gives the sketch control the events that handle clicking on the bitmap. sketchcontrol = new SketchControl(); sketchcontrol.Location = new Point(64, 10); sketchcontrol.MouseDown += (object o, MouseEventArgs mea) => { set = true; currentTool.MouseHold(sketchcontrol, mea.Location); }; sketchcontrol.MouseMove += (object o, MouseEventArgs mea) => { if (set) currentTool.MouseDrag(sketchcontrol, mea.Location); }; sketchcontrol.MouseUp += (object o, MouseEventArgs mea) => { if (set) currentTool.MouseRelease(sketchcontrol, mea.Location); set = false; }; sketchcontrol.KeyPress += (object o, KeyPressEventArgs kpea) => { currentTool.Letter(sketchcontrol, kpea.KeyChar); }; this.Controls.Add(sketchcontrol); menuStrip = new MenuStrip(); menuStrip.Visible = false; this.Controls.Add(menuStrip); this.makeFileMenu(); this.makeToolMenu(theTools); this.makeActionMenu(theColors); this.makeToolButtons(theTools); this.makeActionButtons(theColors); this.Resize += this.changeDimension; this.FormClosing += this.formClosing; this.changeDimension(null, null); }
public override void MouseHold(SketchControl s, Point p) { base.MouseHold(s, p); brush = new SolidBrush(Color.Gray); }
public override void Letter(SketchControl s, char c) { }
public override void MouseDrag(SketchControl s, Point p) { s.Refresh(); this.whileDrawing(s, this.startpoint, p); }
public override void MouseDrag(SketchControl s, Point p) { penAction.points.Add(p); drawWhileDrawing(penAction, s); }
public void drawWhileDrawing(Action action, SketchControl s) { s.sketch.drawAction(action, s.CreateGraphics()); }
public override void Complete(SketchControl s, Point p1, Point p2) { yinyangAction yinyangAction = new yinyangAction(yinyangWidth, p1, this.brush, 0); s.sketch.stuff.Add(yinyangAction); s.sketch.undo.Push(yinyangAction); s.sketch.redo.Clear(); }
public override void whileDrawing(SketchControl s, Point p1, Point p2) { if (Math.Abs(p1.X - p2.X) > Math.Abs(p1.Y - p2.Y)) yinyangWidth = p2.X - p1.X; else yinyangWidth = p2.Y - p1.Y; Action currentAction = new yinyangAction(yinyangWidth, p1, this.brush, 0); drawWhileDrawing(currentAction, s); }
public virtual void MouseRelease(SketchControl s, Point p) { brush = new SolidBrush(s.pencolor); }
public override void Letter(SketchControl s, char c) { Graphics gr = s.MakeBitmapGraphics(); if (c.ToString() == " ") startpoint.X += (int) Math.Round(0.3 * font.Size); else { textAction textAction = new textAction(c, font, startpoint, brush, 0); s.sketch.stuff.Add(textAction); s.sketch.undo.Push(textAction); s.sketch.redo.Clear(); startpoint.X += (int)gr.MeasureString("" + c, font, this.startpoint, StringFormat.GenericTypographic).Width; s.Invalidate(); } }
public abstract void MouseDrag(SketchControl s, Point p);
public virtual void MouseHold(SketchControl s, Point p) { startpoint = p; width = s.width; }
public abstract void Letter(SketchControl s, char c);
public override void whileDrawing(SketchControl s, Point p1, Point p2) { }
public override void MouseHold(SketchControl s, Point p) { base.MouseHold(s, p); if (penAction == null) penAction = new penAction(new List<Point>(), width, p, brush, 0); penAction.points.Add(startpoint); }
public override void MouseRelease(SketchControl s, Point p) { base.MouseRelease(s, p); this.Complete(s, this.startpoint, p); s.Invalidate(); }
public override void MouseDrag(SketchControl s, Point p) { }
public abstract void whileDrawing(SketchControl s, Point p1, Point p2);
public override void whileDrawing(SketchControl s, Point p1, Point p2) { Action currentAction = new shapeAction(Shape.Circle, true, p2, width, p1, this.brush, 0); drawWhileDrawing(currentAction, s); }
public override void MouseHold(SketchControl s, Point p) { s.sketch.delete(p); s.Refresh(); }
public override void whileDrawing(SketchControl s, Point p1, Point p2) { Action currentAction = new lineAction(p2, 3, p1, this.brush, 0); drawWhileDrawing(currentAction, s); }
public override void MouseHold(SketchControl s, Point p) { base.MouseHold(s, p); base.MouseRelease(s, p); font = new Font(s.fontFamily, s.textSize); }
public override void Complete(SketchControl s, Point p1, Point p2) { penAction.brush = brush; s.sketch.stuff.Add(penAction); s.sketch.undo.Push(penAction); s.sketch.redo.Clear(); penAction = null; }
public abstract void Complete(SketchControl s, Point p1, Point p2);
public override void Complete(SketchControl s, Point p1, Point p2) { lineAction lineAction = new lineAction(p2, width, p1, brush, 0); s.sketch.stuff.Add(lineAction); s.sketch.undo.Push(new lineAction(p2, width, p1, brush, 0)); s.sketch.redo.Clear(); }