Example #1
0
        public MainWindow()
            : base("XChess", 640, 480)
        {
            this.VSync = VSyncMode.Off;

            Board board = Board.Initial;
            Game game = new AIGame(0, board);
            this.Control = this._LayerContainer = new LayerContainer((this._View = new GameBoardView(game)));
            this.WindowState = WindowState.Maximized;
        }
Example #2
0
                /// <summary>
                /// Creates a function that displays the selection to the user.
                /// </summary>
                public Action<GUIControlContext> Display(GameBoardView BoardView)
                {
                    return delegate(GUIControlContext Context)
                    {
                        LayerContainer lc;
                        Point offset;
                        if (Context.FindAncestor<LayerContainer>(out lc, out offset))
                        {
                            FlowContainer options = new FlowContainer(20.0, Axis.Horizontal);
                            Pane pane = new Pane(new SunkenContainer(options.WithMargin(20.0)).WithBorder(1.0));
                            ModalOptions mo = new ModalOptions()
                            {
                                Lightbox = false,
                                LowestModal = pane,
                                MouseFallthrough = false
                            };

                            foreach (_Possible p in this._Items)
                            {
                                _Possible ip = p;
                                Button button = new Button(ButtonStyle.CreateSolid(Skin.Default), new _PieceIcon(p.Move.NewState).CreateControl());
                                options.AddChild(button, 150.0);
                                button.Click += delegate
                                {
                                    lc.Modal = null;
                                    pane.Dismiss();
                                    BoardView.MakeMove(ip.Move, ip.Board);
                                };
                            }

                            pane.ClientSize = new Point(options.SuggestLength + 42.0, 190.0);
                            Rectangle merect = new Rectangle(offset, Context.Control.Size);

                            lc.AddControl(pane, merect.Location + merect.Size * 0.5 - pane.Size * 0.5);
                            lc.Modal = mo;
                        }
                    };
                }