コード例 #1
0
ファイル: UndoTreeSystem.cs プロジェクト: Hoodad/Editor_TLCB
        public override void Initialize()
        {
            ContentSystem contentSystem = ((ContentSystem)world.SystemManager.GetSystem<ContentSystem>()[0]);
            m_actionsystem = ((ActionSystem)world.SystemManager.GetSystem<ActionSystem>()[0]);
            Viewport viewport = contentSystem.GetViewport();

            int toolbarwindowh = 360;
            undoTreeWindow = new Window(manager);
            undoTreeWindow.Init();
            undoTreeWindow.Text = "History";
            undoTreeWindow.Width = 160;
            undoTreeWindow.Height = (int)((float)viewport.Height - toolbarwindowh);
            undoTreeWindow.Top = toolbarwindowh; // height of toolbarwindow
            undoTreeWindow.Left = viewport.Width - undoTreeWindow.Width;
            undoTreeWindow.Visible = true;
            undoTreeWindow.CloseButtonVisible = false;
            undoTreeWindow.Click += new TomShane.Neoforce.Controls.EventHandler(OnWindowClickBehavior);
            undoTreeWindow.IconVisible = false;
            undoTreeWindow.AutoScroll = false;

            //toolbarWindow.BorderVisible = false;
            //toolbar.Movable = false;
            manager.Add(undoTreeWindow);

            undoTreeContainer = new UndoTreeContainer(manager, undoTreeWindow, m_gd, m_content);
            undoTreeContainer.Init();
            undoTreeContainer.Width = viewport.Width-16;
            undoTreeContainer.Height = viewport.Height-16;
            undoTreeContainer.Parent = undoTreeWindow;
            undoTreeContainer.CanFocus = false;
            undoTreeContainer.Click += new TomShane.Neoforce.Controls.EventHandler(OnContainerClickBehavior);
            undoTreeContainer.MouseScroll += new TomShane.Neoforce.Controls.MouseEventHandler(OnContainerScrollBehaviour);
            //undoTreeContainer.MousePress += new TomShane.Neoforce.Controls.MouseEventHandler(OnContainerPanBehaviour);
            undoTreeContainer.MouseMove += new MouseEventHandler(OnContainerPanBehaviour);
            undoTreeContainer.DoubleClicks = false;

            /*
            viewMode = new RadioButton(manager);
            viewMode.Init();
            viewMode.Parent = undoTreeWindow;
            viewMode.Width = undoTreeWindow.Width / 2;
            viewMode.Height = 24;
            viewMode.Left = 0;
            viewMode.Top = 24;
            viewMode.Checked = true;
            viewMode.Text = "Tree view";
            viewMode.Click += new TomShane.Neoforce.Controls.EventHandler(ViewModeBehaviour);
             * */

            sbVert = new ScrollBar(manager, Orientation.Vertical);
            sbVert.Init();
            sbVert.Detached = false;
            sbVert.Parent = undoTreeWindow;
            sbVert.Height = undoTreeWindow.ClientHeight-16;
            sbVert.SetPosition(undoTreeWindow.ClientWidth - sbVert.Width, 0);
            sbVert.Anchor = Anchors.Top | Anchors.Right | Anchors.Bottom;
            sbVert.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(ScrollBarValueChangedY);
            // sbVert.MouseScroll += new TomShane.Neoforce.Controls.MouseEventHandler(ScrollBarMouseScroll);
            sbVert.Range = scrollMax;
            sbVert.PageSize = 0;
            sbVert.Value = 0;
            sbVert.Visible = true;
            undoTreeWindow.Add(sbVert);

            sbHorz = new ScrollBar(manager, Orientation.Horizontal);
            sbHorz.Init();
            sbHorz.Detached = false;
            sbHorz.Parent = undoTreeWindow;
            sbHorz.Width = undoTreeWindow.ClientWidth-16;
            sbHorz.SetPosition(0, undoTreeWindow.ClientHeight - sbHorz.Height);
            sbHorz.Anchor = Anchors.Left | Anchors.Right | Anchors.Bottom;
            sbHorz.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(ScrollBarValueChangedX);
            sbHorz.Range = scrollMax;
            sbHorz.PageSize = 0;
            sbHorz.Value = 0;
            sbHorz.Visible = true;
            undoTreeWindow.Add(sbHorz);

            // undoTreeContainer.Click += new TomShane.Neoforce.Controls.EventHandler(OnClick);
        }
コード例 #2
0
ファイル: BlankStory.cs プロジェクト: AlanFoster/Game-of-Life
        private void CreateFirstDisplayWindow(Manager manager, GameInfo gameInfo, Story red, Story black)
        {
            const int spacing = 20;
            const int width = 500;
            int yPos = spacing;
            var window = new Window(manager) { Text = "Story card", Width = 600 };
            window.Init();

            var descriptionlabel = new Label(manager) { Text = red.DisplayedMessage, Top = yPos, Width = width, Height = 70, Left = 30};
            descriptionlabel.Text =
                "When this window closes you will be required to spin the spinner.\n" +
                "If the spinner lands on a black spot you will undergo what the black card says.\n" +
                "If the spinner lands on a red spot you will undergo what the red card says.\n\n" +
                "These are stories you are spinning for!";
            yPos += descriptionlabel.Height + spacing / 2;

            var redstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 100, Parent = window, Color = Color.Red, Text = "Red Story", TextColor = Color.White};
            redstorybox.Init();
            yPos += redstorybox.Height;
            var redstorylabel = new Label(manager)
                                    {
                                        Width = redstorybox.Width,
                                        Height = redstorybox.Height,
                                        Parent = redstorybox,
                                        Text = red.DisplayedMessage,
                                        Left = spacing,
                                        StayOnTop = true
                                    };
            redstorylabel.Init();

            var blackstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 200, Parent = window, Color = Color.Black, Text = "Black Story", TextColor = Color.White };
            blackstorybox.Init();
            yPos += blackstorybox.Height+spacing/2;

            var blackstorylabel = new Label(manager)
            {
                Width = blackstorybox.Width,
                Height = blackstorybox.Height,
                Parent = blackstorybox,
                Text = black.DisplayedMessage,
                Left = spacing,
                StayOnTop = true
            };
            blackstorylabel.Init();

            var close = new Button(manager) { Text = "OK", Top = yPos, Left = window.Width / 2 - 50, Parent = window };
            close.Init();
            close.Click += (sender, args) => window.Close();
            yPos += close.Height + spacing;

            window.Add(descriptionlabel);
            window.Height = blackstorybox.Height + redstorybox.Height + yPos/2;
            manager.Add(window);

            window.Closed += (sender, args) => WindowClosed(gameInfo);

            gameInfo.CreateMessage("Click the spinner to see your story!");
        }
コード例 #3
0
ファイル: BlankStory.cs プロジェクト: AlanFoster/Game-of-Life
        private IGameState[] CardSelected(Manager manager, GameInfo gameInfo, Story story)
        {
            var storyGraphic = gameInfo.Content.Load<Texture2D>(story.StoryGraphic);
            const int spacing = 20;
            const int width = 400;
            var yPos = spacing;

            var window = new Window(manager) {
                Text =
                    String.Format("Your fate has been decided! You spun a {0} story", story.StoryType), AutoScroll = false
            };

            window.Init();

            var storybox = new GroupBox(manager) { Width = 400, Height = 100, Left = 30, Top = yPos, Parent = window, Color = story.StoryType == StoryType.Red ? Color.Red : Color.Black, Text = ""+story.StoryType, TextColor = Color.White };
            storybox.Init();

            var storylabel = new Label(manager)
            {
                Width = storybox.Width,
                Height = storybox.Height,
                Parent = storybox,
                Text = story.DisplayedMessage,
                Left = spacing,
                StayOnTop = true
            };
            storylabel.Init();

            var imageBox = new ImageBox(manager)
            {
                Left = window.Width/2-100,
                Top = 140,
                Image = storyGraphic,
                Color = Color.White,
                Width = storyGraphic.Width,
                Height = storyGraphic.Height
            };
            imageBox.Init();
            window.Add(imageBox);
            var close = new Button(manager) { Text = "OK", Top = window.Height-50-spacing, Left = window.Width / 2 - 50, Parent = window };
            close.Init();
            close.Click += (sender, args) => window.Close();

            window.Closed += (sender, args) => WindowClosed(gameInfo);

            manager.Add(window);

            if (story.Positive)
                gameInfo.Content.Load<SoundEffect>("Sounds/applause").Play();
            else
                gameInfo.Content.Load<SoundEffect>("Sounds/sadtrombone").Play();

            return new[] { story.PureLogic, waitState };
        }
コード例 #4
0
ファイル: Logic.cs プロジェクト: Rfvgyhn/Neoforce
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        void btnRandom_Click(object sender, Controls.EventArgs e)
        {
            Window win = new Window(Manager);
              Button btn = new Button(Manager);
              TextBox txt = new TextBox(Manager);

              win.Init();
              btn.Init();
              txt.Init();

              win.ClientWidth = 320;
              win.ClientHeight = 160;

              win.MinimumWidth = 128;
              win.MinimumHeight = 128;

              Random r = new Random((int)Central.Frames);
              win.ClientWidth += r.Next(-100, +100);
              win.ClientHeight += r.Next(-100, +100);

              win.Left = r.Next(200, Manager.ScreenWidth - win.ClientWidth / 2);
              win.Top = r.Next(0, Manager.ScreenHeight - win.ClientHeight / 2);
              win.Closed += new WindowClosedEventHandler(win_Closed);

            /*
              win.Width = 1024;
              win.Height = 768;
              win.Left = 220;
              win.Top = 0;
              win.StayOnBack = true;
              win.SendToBack();
            */
              btn.Anchor = Anchors.Bottom;
              btn.Left = (win.ClientWidth / 2) - (btn.Width / 2);
              btn.Top = win.ClientHeight - btn.Height - 8;
              btn.Text = "OK";

              win.Text = "Window (" + win.Width.ToString() + "x" + win.Height.ToString() + ")";

              txt.Parent = win;
              txt.Left = 8;
              txt.Top = 8;
              txt.Width = win.ClientArea.Width - 16;
              txt.Height = win.ClientArea.Height - 48;
              txt.Anchor = Anchors.All;
              txt.Mode = TextBoxMode.Multiline;
              txt.Text = "This is a Multiline TextBox.\n" +
                 "Allows to edit large texts,\n" +
                 "copy text to and from clipboard,\n" +
                 "select text with mouse or keyboard\n" +
                 "and much more...";

              txt.SelectAll();
              txt.Focused = true;
              //txt.ReadOnly = true;

              txt.ScrollBars = ScrollBars.Both;

              win.Add(btn, true);
              win.Show();
              Manager.Add(win);
        }
コード例 #5
0
        private void CreateCareerWindow(Manager manager, GameInfo gameInfo, Career[] randomJobs, IGameState waitState)
        {
            const int spacing = 20;
            const int width = 500;

            int yPos = spacing;
            int xPos = spacing * 4;
            var window = new Window(manager) {
                Text = "Choose a career!",
                Width = width,
                CloseButtonVisible = false,
                Resizable = false
            };

            window.Init();

            var description = new Label(manager) { Text = "Choose a random unknown career!\nWhen you select the career it will show you your fate!", Width = 400, Left = 16, Top = 16, Height = 40 };
            description.Init();
            yPos += description.Height + spacing;
            window.Add(description);

            var chosenJob = new Label(manager) { Text = String.Empty, Width = 400, Left = 16, Top = 16, Height = 70 };
            chosenJob.Init();
            window.Add(chosenJob);

            var possibleJobImages = new List<Button>();
            var chooseCareerTexture = gameInfo.Content.Load<Texture2D>("Images/career_icons/BlankJob");
            foreach (var career in randomJobs) {
                var chosenCareer = career;

                var careerButton = new Button(manager) {
                    Top = yPos,
                    Left = xPos,
                    StayOnBack = true,
                    Width = 100,
                    Height = 100,
                    Glyph = new Glyph(chooseCareerTexture)
                };
                possibleJobImages.Add(careerButton);
                careerButton.Init();
                window.Add(careerButton);

                careerButton.Click += (sender, args) => {
                    gameInfo.CurrentPlayer.CurrentCareer = chosenCareer;
                    window.CloseButtonVisible = true;

                    chosenJob.Text = "Congratulations! You have become a " +
                                       chosenCareer.Title
                                       + "\n\nClose the window to receive your first Pay Day!";

                    int i = 0;
                    foreach (var possibleJob in possibleJobImages) {
                        possibleJob.Glyph = new Glyph(gameInfo.Content.Load<Texture2D>("images/career_icons/" + randomJobs[i++].Title));
                        possibleJob.Enabled = false;
                        possibleJob.SetSize(100, 100);
                    }

                    careerButton.Color = Color.Red;

                    yPos += chosenJob.Height + 16;

                    var close = new Button(manager) { Text = "OK", Parent = window, Top = yPos, Left = window.Width / 2 - 50 };
                    close.Click += (s, a) => {window.Close(); WindowClosed(gameInfo, waitState);};
                    close.Init();
                };

                xPos += careerButton.Width + 20;
            }

            yPos += possibleJobImages[0].Height + 16;

            chosenJob.Top = yPos;
            manager.Add(window);
            window.Closed += (sender, args) => WindowClosed(gameInfo, waitState);
        }
コード例 #6
0
        public override void Init()
        {
            base.Init();
            window = new Window(Manager);
            window.Init();
            window.Text = title;
            window.Width = 375;
            window.Height = 200;
            window.Center();
            window.Visible = true;

            box = new ImageBox(Manager);
            box.Init();
            box.Height = 32;
            box.Width = 32;

            box.Top = 100-40;
            box.Left = 20;
            box.SizeMode = SizeMode.Stretched;
            box.Parent = window;

            label = new Label(Manager);
            label.Init();
            label.Width = window.Width - 80;
            label.Height = 150;
            label.Top = 0;
            label.Left = box.Left + box.Width + 10;
            label.Text = FormatString(message);
            label.Parent = window;

            if (Type == MessageBoxType.OKAY)
            {
                buttons.Add(new Button(Manager));
                buttons[0].Init();
                buttons[0].Width = 50;
                buttons[0].Height = 24;
                buttons[0].Top = (int)(window.Height * .62);
                buttons[0].Left = (window.Width / 2) - (buttons[0].Width / 2);
                buttons[0].Text = "Okay";
                buttons[0].Parent = window;
                buttons[0].Click += new TomShane.Neoforce.Controls.EventHandler(OkayButtonClick);

                box.Image = Manager.Skin.Images["Icon.Information"].Resource;
            }
            else if (Type == MessageBoxType.ERROR)
            {
                buttons.Add(new Button(Manager));
                buttons[0].Init();
                buttons[0].Width = 50;
                buttons[0].Height = 24;
                buttons[0].Top = (int)(window.Height * .62);
                buttons[0].Left = (window.Width / 2) - (buttons[0].Width / 2);
                buttons[0].Text = "Okay";
                buttons[0].Parent = window;
                buttons[0].Click += new TomShane.Neoforce.Controls.EventHandler(OkayButtonClick);
                box.Image = Manager.Skin.Images["Icon.Error"].Resource;
            }
            else if (Type == MessageBoxType.YES_NO)
            {
                buttons.Add(new Button(Manager));
                buttons[0].Init();
                buttons[0].Width = 50;
                buttons[0].Height = 24;
                buttons[0].Top = (int)(window.Height * .62);
                buttons[0].Left = (window.Width / 2) + 10;
                buttons[0].Text = "No";
                buttons[0].Parent = window;
                buttons[0].Click += new TomShane.Neoforce.Controls.EventHandler(NoButtonClick);

                buttons.Add(new Button(Manager));
                buttons[1].Init();
                buttons[1].Width = 50;
                buttons[1].Height = 24;
                buttons[1].Top = buttons[0].Top;
                buttons[1].Left = (window.Width / 2) - (buttons[1].Width) - 10;
                buttons[1].Text = "Yes";
                buttons[1].Parent = window;
                buttons[1].Click += new TomShane.Neoforce.Controls.EventHandler(YesButtonClick);

                box.Image = Manager.Skin.Images["Icon.Question"].Resource;
            }
            else if (Type == MessageBoxType.YES_NO_CANCEL)
            {
                buttons.Add(new Button(Manager));
                buttons[0].Init();
                buttons[0].Width = 50;
                buttons[0].Height = 24;
                buttons[0].Text = "Yes";
                buttons[0].Top = (int)(window.Height * .62);
                buttons[0].Left = (window.Width / 2) - (buttons[0].Width) - 40;
                buttons[0].Parent = window;
                buttons[0].Click += new TomShane.Neoforce.Controls.EventHandler(YesButtonClick);

                buttons.Add(new Button(Manager));
                buttons[1].Init();
                buttons[1].Width = 50;
                buttons[1].Height = 24;
                buttons[1].Text = "No";
                buttons[1].Top = buttons[0].Top;
                buttons[1].Left = (window.Width / 2) - (buttons[1].Width /2);
                buttons[1].Parent = window;
                buttons[1].Click += new TomShane.Neoforce.Controls.EventHandler(NoButtonClick);

                buttons.Add(new Button(Manager));
                buttons[2].Init();
                buttons[2].Width = 50;
                buttons[2].Height = 24;
                buttons[2].Text = "Cancel";
                buttons[2].Top = buttons[0].Top;
                buttons[2].Left = (window.Width / 2) + 40;

                buttons[2].Parent = window;
                buttons[2].Click += new TomShane.Neoforce.Controls.EventHandler(CancelButtonClick);

                box.Image = Manager.Skin.Images["Icon.Question"].Resource;
            }

            foreach (Button btn in buttons)
            {
                window.Add(btn);
            }
        }
コード例 #7
0
ファイル: Game1.cs プロジェクト: slicedpan/demo
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.

            spriteBatch = new SpriteBatch(GraphicsDevice);

            #region models

            boxmodel = Content.Load<Model>("primitives/box");
            lppbox = Content.Load<Model>("primitives/lit/box");
            lppsphere = Content.Load<Model>("primitives/lit/sphere");
            lppcapsule = Content.Load<Model>("primitives/lit/capsule");
            lppcylinder = Content.Load<Model>("primitives/lit/cylinder");
            cylindermodel = Content.Load<Model>("primitives/cylinder");
            spheremodel = Content.Load<Model>("primitives/sphere");
            capsulemodel = Content.Load<Model>("primitives/capsule");
            floormodel = Content.Load<Model>("floor/floor");
            boxdata = Content.Load<PhysicsInfo>("walls/roomphys");
            circleimg = Content.Load<Texture2D>("textures/circle");
            Model blockman = Content.Load<Model>("floor/floor");
            //Model skullmodel = Content.Load<Model>("skull/skull");
            Model wallmodel = Content.Load<Model>("room/room");
            PhysicsInfo skullphys = Content.Load<PhysicsInfo>("skull/skullphys");
            ShadowEffect = Content.Load<Effect>("shaders/Shadow");
            Model sceneModel = Content.Load<Model>("scene/scenetest");
            PhysicsInfo scenePhys = Content.Load<PhysicsInfo>("scene/scenetestphys");

            #endregion

            #region Effects
            NormalEffect = Content.Load<Effect>("shaders/LPPNormalEffect");
            BasicEffect = Content.Load<Effect>("shaders/LPPBasicEffect");
            TexturedEffect = Content.Load<Effect>("shaders/LPPTexturedEffect");
            MainEffect = Content.Load<Effect>("shaders/LPPMainEffect");
            #endregion
            Vector3 lowerButton = new Vector3(134.988f, 61.178f, 126.411f) * (2.54f / 64.0f);
            Vector3 upperButton = new Vector3(134.988f, 64.803f, 126.411f) * (2.54f / 64.0f);
            float convFactor = 2.54f / 64.0f;

            Console.Parse("physdebug false");
            Console.Parse("drawconstraints false");
            Console.Parse("drawedgemask false");
            Console.Parse("drawdepth false");
            Console.Parse("drawnormal false");
            Console.Parse("drawall false");
            Console.Parse("drawspheres false");
            Console.Parse("blur true");
            Console.Parse("drawshadowmap false");
            Console.Parse("drawlightbuffer false");
            Console.Parse("showPosition true");

            Console.LoadContent(Content);

            /*boxdata = new PhysicsInfo();
            boxdata.CreateBox(new Vector3(-1, -1, -1), Matrix.Identity, Vector3.One);
            boxdata.CreateBox(new Vector3(1, 1, 1), Matrix.Identity, Vector3.One);
            boxdata.CreateSphere(new Vector3(1, 3, 1), 1);*/

            // TODO: use this.Content to load your game content here
            projmatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), (float)graphics.PreferredBackBufferWidth / (float)graphics.PreferredBackBufferHeight, 0.01f, 2500.0f);
            /*
            fallingBox = new Component(new Vector3(3.6f, 7.5f, -2.4f), Quaternion.Identity, Vector3.One / 2.0f);
            fallingBox.SetCollision(skullphys, false);
            fallingBox.Mesh = new LPPMesh(skullmodel);
            fallingBox.Mesh.Occlude = true;
            Actors.Add(new Actor(fallingBox));*/

            /*immovableBox = new TriangleMeshActor(floormodel, Vector3.Zero, Vector3.One / 8.0f);
            immovableBox.Mesh = new LPPMesh(floormodel);
            immovableBox.Mesh.Occlude = true;

            Entities.Add(new Entity(immovableBox));*/

            immovableBox = new TriangleMeshComponent(wallmodel, Vector3.Zero, Vector3.One / (64.0f / 2.54f));
            var lppmesh = new LPPMesh(wallmodel);

            var scene = new Component(new LPPMesh(sceneModel), new Vector3(3.8f, 7.5f, -3.0f), Quaternion.Identity, Vector3.One / 64.0f);
            scene.SetCollision(scenePhys, true);
            Actors.Add(new Actor(scene));
            Actors.Add(new LiftButton(upperButton, Vector3.One / 64.0f, "lift up"));
            Actors.Add(new LiftButton(lowerButton, Vector3.One / 64.0f, "lift down"));

            lppmesh.SpecularPower = 1.0f;
            lppmesh.Shininess = 1.0f;

            immovableBox.Mesh = lppmesh;

            Actors.Add(new Actor(immovableBox));

            Actors.Add(new CeilingLamp(new Vector3(-1.5f, 11.9f, 1.68f), 0.75f));
            Actors.Add(new Ladder(new Vector3(13.735f, 5.0f, -2.32f), 1.0f, 3.5f, 0.5f));
            lift = new Lift(Vector3.Zero, 1 / 64.0f);
            Actors.Add(lift);

            Actors.Add(new PulsingLight(new Vector3(12.86f, 3.43f, 5.84f), Color.Red, 7.5f, 1.0f, 0.2f, 3.0d));
            Actors.Add(new BareBulb(new Vector3(-14.5f, 11.4f, 3f), Vector3.One / 64.0f, Color.Wheat, 10.0f, 0.6f));
            font = Content.Load<SpriteFont>("font");

            RasterizerState rs = RasterizerState.CullCounterClockwise;
            GraphicsDevice.RasterizerState = rs;

            bs = GraphicsDevice.BlendState;

            cam = new Camera();
            cam.Aspect = (float)scrwidth / (float)scrheight;
            cam.Viewport = new Viewport(0, 0, scrwidth, scrheight);
            cam.NearClip = 0.01f;
            cam.FarClip = 100.0f;
            cam.Transform = Matrix.Identity;

            characterController = new CharacterController(new Vector3(-1.0f, 2.0f, 7.311f), 3.0f, 0.75f, 0.1f, 0.2f);
            characterInput = new CharacterControllerInput(space, cam);
            characterInput.CharacterController = characterController;
            characterInput.Activate();

            camcontrol = new CameraController(cam, Vector3.Zero, Vector2.Zero);
            Actors.Add(new Actor(new FollowLight(12.5f, 1.0f, Color.White, cam)));
            lppRenderer = new LPPRenderer(GraphicsDevice, Content, scrwidth, scrheight);

            for (int i = /*200*/0; i > 0; --i)
            {
                space.Update(0.0166f);
            }

            window = new Dialog(Manager);
            window.SetPosition(0, 0);
            window.SetSize(512, 512);
            window.Text = "Console";
            textBox = new TextBox(Manager);
            textBox.SetPosition(32, 32);
            window.Add(textBox, false);
            Manager.Add(window);
        }
コード例 #8
0
        public Button CreateMenuButton()
        {
            // Create the button that opens the window
            MenuButton = new Button(ControlManager.Manager) { Text = "Menu" };
            MenuButton.Init();
            MenuButton.Click += (sender, args) => OpenMenu();

            ControlManager.Add(MenuButton);

            // Create the window
            MenuWindow = new Window(ControlManager.Manager) { Text = "Menu window" };
            MenuWindow.Init();
            MenuWindow.Hide();

            const int padding = 16, buttonWidth = 300, buttonHeight = 30;
            var yPos = padding;
            var xPos = MenuWindow.Controls.First().Width / 2 - buttonWidth / 2;

            var descriptionLabel = new Label(ControlManager.Manager) {
                Left = padding / 2,
                Top = yPos,
                Width = 400,
                Text = "Click what option you want, or press close to continue.",
            };
            descriptionLabel.Init();
            MenuWindow.Add(descriptionLabel);
            yPos += descriptionLabel.Height + padding * 2;

            var menuInfos = new[] {
                new Tuple<string, EventHandler>("View Game Status", (sender, args) => { CloseMenuWindow(); CreateGameResult(); }),
                    new Tuple<string, EventHandler>("Sell House", (sender, args) => { CloseMenuWindow(); CreateSellHouseWindow(); }),
                    new Tuple<string, EventHandler>("Repay Loan", (sender, args) => { CloseMenuWindow(); CreateRepayLoanWindow(); }),
                    new Tuple<string, EventHandler>("Return to previous screen", (sender, args) => _returnToMainMenu()),
                    new Tuple<string, EventHandler>("Exit Game", (sender, args) => ControlManager.Manager.MainWindow.Close())
            };

            foreach (var menuInfo in menuInfos) {
                var menuButton = new Button(ControlManager.Manager) {
                    Text = menuInfo.Item1,
                    Top = yPos,
                    Left = xPos,
                    Width = buttonWidth,
                    Height = buttonHeight
                };
                menuButton.Init();
                menuButton.Click += menuInfo.Item2;
                MenuWindow.Add(menuButton);
                yPos += menuButton.Height + padding;
            }

            MenuWindow.Closing += (sender, args) => {
                MenuButton.Enabled = true;
                CloseMenuWindow();
            };

            ControlManager.Add(MenuWindow);

            return MenuButton;
        }