Exemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Graphics g = panel1.CreateGraphics();

            controller            = new BlockController(g, this.Font, panel1.Size, () => MakeTextBox());
            controller.Modified  += new ControllerModified(controller_Modified);
            document              = new Document("Kitsune");
            document.TitleChange += new TitleChangeEvent(document_TitleChange);
            document.SetTitle();
            RegisterMethods();
            controller.InitPalette(); // after methods are registered

            vm       = new VM.VM();
            compiler = new Compiler(vm, controller.GetBlockSpace());

            runForm = panel2;
            //runForm.Location = this.Location;
            //runForm.Size = this.Size;
            runGraphics = runForm.CreateGraphics();
            stage       = new Stage.Stage(runGraphics, this.Font, runForm.ClientSize);
            kitsune     = new Sprite(BitmapExtensions.LoadBmp("kitsune2.bmp"),
                                     runForm.ClientRectangle.Center().Offseted(-15, -15),
                                     true,
                                     -90);


            runForm.Paint       += new PaintEventHandler(runForm_Paint);
            runForm.DoubleClick += new EventHandler(runForm_DoubleClick);
            stage.AddSprite(kitsune);
            stage.RedrawAll();
            PrepareVM(vm, stage);
            PrepareCompiler(compiler);


            // I really should use a testing framework
            // testSplitFuncArgs();
            // testCBlockView(new Point(10, 10));
            // testReporterBlockView(new Point(250, 10));
            // testBlockStackView(new Point(450, 10));
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Graphics g = panel1.CreateGraphics();

            controller = new BlockController(g, this.Font, panel1.Size, () => MakeTextBox());
            controller.Modified += new ControllerModified(controller_Modified);
            document = new Document("Kitsune");
            document.TitleChange += new TitleChangeEvent(document_TitleChange);
            document.SetTitle();
            RegisterMethods();
            controller.InitPalette(); // after methods are registered

            vm = new VM.VM();
            compiler = new Compiler(vm, controller.GetBlockSpace());

            runForm = panel2;
            //runForm.Location = this.Location;
            //runForm.Size = this.Size;
            runGraphics = runForm.CreateGraphics();
            stage = new Stage.Stage(runGraphics, this.Font, runForm.ClientSize);
            kitsune = new Sprite(BitmapExtensions.LoadBmp("kitsune2.bmp"),
                runForm.ClientRectangle.Center().Offseted(-15, -15),
                true,
                -90);

            runForm.Paint += new PaintEventHandler(runForm_Paint);
            runForm.DoubleClick += new EventHandler(runForm_DoubleClick);
            stage.AddSprite(kitsune);
            stage.RedrawAll();
            PrepareVM(vm, stage);
            PrepareCompiler(compiler);

            // I really should use a testing framework
            // testSplitFuncArgs();
            // testCBlockView(new Point(10, 10));
            // testReporterBlockView(new Point(250, 10));
            // testBlockStackView(new Point(450, 10));
        }
Exemplo n.º 3
0
        private void PrepareCompiler(Compiler compiler)
        {
            compiler.PrimitiveAliases["move % steps"] = "fd";
               compiler.PrimitiveAliases["move to x: % y: %"] = "gotoxy";
               compiler.PrimitiveAliases["turn % degrees right"] = "rt";
               compiler.PrimitiveAliases["turn % degrees left"] = "lt";

               compiler.PrimitiveAliases["% + %"] = "+";
               compiler.PrimitiveAliases["% - %"] = "-";
               compiler.PrimitiveAliases["% * %"] = "*";
               compiler.PrimitiveAliases["% / %"] = "/";

               compiler.PrimitiveAliases["% < %"] = "<";
               compiler.PrimitiveAliases["% = %"] = "=";
               compiler.PrimitiveAliases["% > %"] = ">";
               compiler.PrimitiveAliases["% and %"] = "and";
               compiler.PrimitiveAliases["% or %"] = "or";
               compiler.PrimitiveAliases["not %"] = "not";

               compiler.PrimitiveAliases["random from % to %"] = "random";
               compiler.PrimitiveAliases["sin %"] = "sin";
               compiler.PrimitiveAliases["cos %"] = "cos";
               compiler.PrimitiveAliases["tan %"] = "tan";
               compiler.PrimitiveAliases["asin %"] = "asin";
               compiler.PrimitiveAliases["acos %"] = "acos";
               compiler.PrimitiveAliases["atan %"] = "atan";
               compiler.PrimitiveAliases["sqrt %"] = "sqrt";

               compiler.PrimitiveAliases["say %"] = "say";
               compiler.PrimitiveAliases["when _flag_ clicked"] = "doNothing";
        }