Пример #1
0
        public MainWindow()
        {
            AllocConsole();
            InitializeComponent();
            CurrentEnviroment.Game      = new Game();
            this.ScriptEditor.IsEnabled = false;
            this.SpriteList.SpriteListView.SelectionChanged += SpriteListView_SelectionChanged;
            //this.SpriteList.BackgroundContainer.Checked += BackgroundContainer_Checked;
            this.ScriptPlayer.PlayScreen.PreviewMouseMove += PlayScreen_PreviewMouseMove;

            ScriptEditor.Register(((Color)ColorConverter.ConvertFromString("#4C97FF")), typeof(MoveStatement),
                                  typeof(RotationStatement), typeof(ReflectionStatement), typeof(SetRotationModeStatement), typeof(SetDegreeStatement),
                                  typeof(SetPositionStatement), typeof(SetPositionXStatement), typeof(SetPositionYStatement), typeof(TimedMoveStatement),
                                  typeof(XPositionExpression), typeof(YPositionExpression), typeof(DegreeExpression));

            ScriptEditor.Register(((Color)ColorConverter.ConvertFromString("#9966FF")), typeof(ResizeStatement),
                                  typeof(SetImageStatement), typeof(SetNextImageStatement), typeof(ShowStatement), typeof(HideStatement), typeof(SizeExpression));

            ScriptEditor.Register(((Color)ColorConverter.ConvertFromString("#FFBF00")), typeof(StartEventHandler),
                                  typeof(ClickEventHandler), typeof(MessageEvetHandler));

            List <ScriptStepGroup> toolbar = new List <ScriptStepGroup>();

            toolbar.Add(new ScriptStepGroup()
            {
                Name  = Localize.GetString("xc_Motion"),
                Types = new List <object>()
                {
                    new WaitStatement(),
                    new MoveStatement(),
                    new RotationStatement()
                    {
                        Direction = RotationDirection.Clockwise
                    },
                    new RotationStatement()
                    {
                        Direction = RotationDirection.CounterClockwise
                    },
                    new ReflectionStatement(),
                    new SetRotationModeStatement(),
                    new SetDegreeStatement(),
                    new SetPositionStatement(),
                    new SetPositionXStatement(),
                    new SetPositionYStatement(),
                    new TimedMoveStatement(),
                    new XPositionExpression(),
                    new YPositionExpression(),
                    new DegreeExpression()
                }
            });
            toolbar.Add(new ScriptStepGroup()
            {
                Name  = Localize.GetString("xc_Looks"),
                Types = new List <object>()
                {
                    new ResizeStatement(),
                    new SetImageStatement(),
                    new SetNextImageStatement(),
                    new ShowStatement(),
                    new HideStatement(),
                    new SizeExpression()
                }
            });
            toolbar.Add(new ScriptStepGroup()
            {
                Name  = Localize.GetString("xc_Logic"),
                Types = new List <object>()
                {
                    new BinaryExpression()
                    {
                        ValueType = "boolean", Operator = Operator.Equal
                    },                                                                      //compare operator
                    new BinaryExpression()
                    {
                        ValueType = "boolean", Operator = Operator.And
                    },                                                                   //logical operator
                    new NotExpression()
                }
            });
            toolbar.Add(new ScriptStepGroup()
            {
                Name  = Localize.GetString("xc_Operation"),
                Types = new List <object>()
                {
                    new BinaryExpression(),
                    new ConditionalExpression(),
                    new RandomExpression()
                }
            });
            toolbar.Add(new ScriptStepGroup()
            {
                Name  = Localize.GetString("xc_Control"),
                Types = new List <object>()
                {
                    new IfStatement(),
                    new IfStatement()
                    {
                        Alternate = new BlockStatement()
                    },
                    new LoopStatement(),
                    new WhileStatement(),
                    new BreakStatement(),
                    new ContinueStatement(),
                    new ReturnStatement(),
                    new LogStatement(),
                    new TryStatement()
                }
            });
            toolbar.Add(new ScriptStepGroup()
            {
                Name  = Localize.GetString("xc_Event"),
                Types = new List <object>()
                {
                    new StartEventHandler(),
                    new KeyEventHandler(),
                    new ClickEventHandler(),
                    new MessageEvetHandler()
                }
            });
            toolbar.Add(new ScriptStepGroup()
            {
                Name  = Localize.GetString("xc_Variable"),
                Types = new List <object>()
                {
                    "CreateVariable",
                    new ExpressionStatement()
                    {
                        Expression = new AssignmentExpression()
                    }
                }
            });
            toolbar.Add(new ScriptStepGroup()
            {
                Name  = Localize.GetString("xc_Method"),
                Types = new List <object>()
                {
                    "CreateFunction"
                }
            });
            ScriptEditor.SetToolBar(toolbar);
        }