Example #1
0
        private UICanvas BuildMainMenu()
        {
            UICanvas canvas = new UICanvas();

            canvas.Add(new UIButton("Versus KI", Color.White, Color.Yellow, 32, new Vector2(0f, -120f), true)
                       .OnClick((button, scene) => {
                Player.isHost        = true;
                Player.isMultiplayer = false;
                scene.manager.Load(PreparingScene.Id);
            }));


            canvas.Add(new UIButton("Host", Color.White, Color.Yellow, 32, new Vector2(0f, -20f), true)
                       .OnClick((button, scene) => {
                Player.isHost        = true;
                Player.isMultiplayer = true;
                scene.manager.Load(PreparingScene.Id);
            }));

            canvas.Add(new UIButton("Connect", Color.White, Color.Yellow, 32, new Vector2(0f, 80f), true)
                       .OnClick((button, scene) => {
                Player.isHost        = false;
                Player.isMultiplayer = true;
                scene.manager.Load(PreparingScene.Id);
            }));

            canvas.Add(new UIButton("Exit", Color.White, Color.Yellow, 32, new Vector2(0f, 180), true)
                       .OnClick((button, scene) => Application.Close()));

            return(canvas);
        }
Example #2
0
        private int CreateLine(int y, string keyboard, UICanvas canvas)
        {
            int w = Size.Width - (((keyboard.Length) + 1) * SPACE_BETWEEN_BUTTONS);
            w = w / (keyboard.Length);

            int h = Size.Height - (SPACE_BETWEEN_BUTTONS * 5);
            h = h / 4;

            float x = Location.X + SPACE_BETWEEN_BUTTONS;

            foreach (var i in keyboard)
            {
                var button = canvas.Add<GradientButton>(() => new GradientButton()
                {
                    FontStyle = this.FontStyle,
                    Location = new System.Drawing.Point((int)x, y),
                    Size = new System.Drawing.Size((int)w, (int)h),
                    MaskImage = this.MaskImage,
                    Gradient = this.AlfanumericButtonsGradient
                });

                switch (i)
                {
                    case '\u0020':
                        button.Text = "Boşluk";
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            OnCharPressed('\u0020', KeyboardControl.SpaceBar);
                        });
                        break;

                    case '\u0025':
                        button.Text = "abc";
                        button.Gradient = this.ControlButtonsGradient;
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            this.NumericKeyboard = !this.NumericKeyboard;
                        });
                        break;

                    case '\u0021':
                        button.Gradient = this.ControlButtonsGradient;
                        button.Text = "123";
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            this.NumericKeyboard = !this.NumericKeyboard;
                        });
                        break;

                    case '\u0022':
                        button.Text = "Geri";
                        button.Gradient = this.ControlButtonsGradient;
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            OnCharPressed('\u0022', KeyboardControl.Back);
                        });
                        break;

                    case '\u0023':
                        button.Text = "Sil";
                        button.Gradient = this.ControlButtonsGradient;
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            OnCharPressed('\u0023', KeyboardControl.Backspace);
                        });
                        break;

                    case '\u0024':
                        button.Text = "Ok";
                        button.Gradient = this.ControlButtonsGradient;
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            OnCharPressed('\u0024', KeyboardControl.Enter);
                        });

                        break;

                    default:
                        button.Text = i.ToString();
                        button.OnClickEvent += new EventHandler(delegate(object sender, EventArgs e)
                        {
                            OnCharPressed(((GradientButton)sender).Text[0], KeyboardControl.Char);
                        });

                        break;
                }

                x += (SPACE_BETWEEN_BUTTONS + w);
            }

            return h;
        }