Example #1
0
 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();
 }
Example #2
0
        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);
        }
Example #3
0
 public override void MouseHold(SketchControl s, Point p)
 {
     base.MouseHold(s, p);
     brush = new SolidBrush(Color.Gray);
 }
Example #4
0
 public override void Letter(SketchControl s, char c)
 {
 }
Example #5
0
 public override void MouseDrag(SketchControl s, Point p)
 {
     s.Refresh();
     this.whileDrawing(s, this.startpoint, p);
 }
Example #6
0
 public override void MouseDrag(SketchControl s, Point p)
 {
     penAction.points.Add(p);
     drawWhileDrawing(penAction, s);
 }
Example #7
0
 public void drawWhileDrawing(Action action, SketchControl s)
 {
     s.sketch.drawAction(action, s.CreateGraphics());
 }
Example #8
0
 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();
 }
Example #9
0
 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);
 }
Example #10
0
 public virtual void MouseRelease(SketchControl s, Point p)
 {
     brush = new SolidBrush(s.pencolor);
 }
Example #11
0
 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();
     }
 }
Example #12
0
 public abstract void MouseDrag(SketchControl s, Point p);
Example #13
0
 public virtual void MouseHold(SketchControl s, Point p)
 {
     startpoint = p;
     width = s.width;
 }
Example #14
0
 public abstract void Letter(SketchControl s, char c);
Example #15
0
 public override void whileDrawing(SketchControl s, Point p1, Point p2)
 {
 }
Example #16
0
 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);
 }
Example #17
0
 public override void MouseRelease(SketchControl s, Point p)
 {
     base.MouseRelease(s, p);
     this.Complete(s, this.startpoint, p);
     s.Invalidate();
 }
Example #18
0
 public override void MouseDrag(SketchControl s, Point p)
 {
 }
Example #19
0
 public abstract void whileDrawing(SketchControl s, Point p1, Point p2);
Example #20
0
 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);
 }
Example #21
0
 public override void MouseHold(SketchControl s, Point p)
 {
     s.sketch.delete(p);
     s.Refresh();
 }
Example #22
0
 public override void whileDrawing(SketchControl s, Point p1, Point p2)
 {
     Action currentAction = new lineAction(p2, 3, p1, this.brush, 0);
     drawWhileDrawing(currentAction, s);
 }
Example #23
0
 public override void MouseHold(SketchControl s, Point p)
 {
     base.MouseHold(s, p);
     base.MouseRelease(s, p);
     font = new Font(s.fontFamily, s.textSize);
 }
Example #24
0
 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;
 }
Example #25
0
 public abstract void Complete(SketchControl s, Point p1, Point p2);
Example #26
0
 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();
 }