Esempio n. 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();
 }
Esempio n. 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);
        }
Esempio n. 3
0
 public override void MouseHold(SketchControl s, Point p)
 {
     base.MouseHold(s, p);
     brush = new SolidBrush(Color.Gray);
 }
Esempio n. 4
0
 public override void Letter(SketchControl s, char c)
 {
 }
Esempio n. 5
0
 public override void MouseDrag(SketchControl s, Point p)
 {
     s.Refresh();
     this.whileDrawing(s, this.startpoint, p);
 }
Esempio n. 6
0
 public override void MouseDrag(SketchControl s, Point p)
 {
     penAction.points.Add(p);
     drawWhileDrawing(penAction, s);
 }
Esempio n. 7
0
 public void drawWhileDrawing(Action action, SketchControl s)
 {
     s.sketch.drawAction(action, s.CreateGraphics());
 }
Esempio n. 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();
 }
Esempio n. 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);
 }
Esempio n. 10
0
 public virtual void MouseRelease(SketchControl s, Point p)
 {
     brush = new SolidBrush(s.pencolor);
 }
Esempio n. 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();
     }
 }
Esempio n. 12
0
 public abstract void MouseDrag(SketchControl s, Point p);
Esempio n. 13
0
 public virtual void MouseHold(SketchControl s, Point p)
 {
     startpoint = p;
     width = s.width;
 }
Esempio n. 14
0
 public abstract void Letter(SketchControl s, char c);
Esempio n. 15
0
 public override void whileDrawing(SketchControl s, Point p1, Point p2)
 {
 }
Esempio n. 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);
 }
Esempio n. 17
0
 public override void MouseRelease(SketchControl s, Point p)
 {
     base.MouseRelease(s, p);
     this.Complete(s, this.startpoint, p);
     s.Invalidate();
 }
Esempio n. 18
0
 public override void MouseDrag(SketchControl s, Point p)
 {
 }
Esempio n. 19
0
 public abstract void whileDrawing(SketchControl s, Point p1, Point p2);
Esempio n. 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);
 }
Esempio n. 21
0
 public override void MouseHold(SketchControl s, Point p)
 {
     s.sketch.delete(p);
     s.Refresh();
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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;
 }
Esempio n. 25
0
 public abstract void Complete(SketchControl s, Point p1, Point p2);
Esempio n. 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();
 }