Example #1
0
        public SchetsWin()
        {
            ISchetsTool[] deTools = { new PenTool()
                                    , new LijnTool()
                                    , new RechthoekTool()
                                    , new VolRechthoekTool()
                                    , new TekstTool()
                                    , new GumTool()
                                    , new OvaalTool()
                                    , new VolOvaalTool()
                                    };
            String[] deKleuren = { "Black", "Red", "Green", "Blue"
                                 , "Yellow", "Magenta", "Cyan"
                                 };

            String text = "";

            this.ClientSize = new Size(700, 550);
            huidigeTool = deTools[0];

            schetscontrol = new SchetsControl();
            schetscontrol.Location = new Point(64, 10);
            schetscontrol.MouseDown += (object o, MouseEventArgs mea) =>
                                       {   vast=true;
                                           huidigeTool.MuisVast(schetscontrol, mea.Location);
                                           beginLocation = mea.Location;
                                       };
            schetscontrol.MouseMove += (object o, MouseEventArgs mea) =>
                                       {   if (vast)
                                           huidigeTool.MuisDrag(schetscontrol, mea.Location);
                                       };
            schetscontrol.MouseUp   += (object o, MouseEventArgs mea) =>
                                       {
                                           if (vast)
                                           {
                                               if (huidigeTool.GetType() != typeof(TekstTool))
                                               {
                                                   schetscontrol.LayerList.Add(Tuple.Create(
                                                       huidigeTool,
                                                       schetscontrol.PenKleur,
                                                       beginLocation,
                                                       mea.Location,
                                                       text,
                                                       new List<Point>(schetscontrol.Scribble)));
                                               }
                                               huidigeTool.MuisLos(schetscontrol, mea.Location);
                                               schetscontrol.Scribble.Clear();
                                               vast = false;
                                           }
                                       };
            schetscontrol.KeyPress +=  (object o, KeyPressEventArgs kpea) =>
                                       {
                                           if (huidigeTool.GetType() == typeof(TekstTool))
                                           {
                                               if (kpea.KeyChar == (char)13) //Enter
                                               {
                                                   schetscontrol.LayerList.Add(Tuple.Create(huidigeTool,
                                                       schetscontrol.PenKleur,
                                                       beginLocation,
                                                       new Point(0, 0),
                                                       text,
                                                       new List<Point>()));
                                                   text = "";
                                               }
                                               else
                                               {
                                                   text += kpea.KeyChar;
                                               }
                                           }
                                           huidigeTool.Letter(schetscontrol, kpea.KeyChar);
                                       };
            this.Controls.Add(schetscontrol);

            menuStrip = new MenuStrip();
            menuStrip.Visible = false;
            this.Controls.Add(menuStrip);
            this.maakFileMenu();
            this.maakToolMenu(deTools);
            this.maakAktieMenu(deKleuren);
            this.maakToolButtons(deTools);
            this.maakAktieButtons(deKleuren);
            this.Resize += this.veranderAfmeting;
            this.veranderAfmeting(null, null);
        }