Пример #1
0
        /// <summary>
        /// Creates a scroll bar with the specified orientation, value, extent, and maximum.
        /// </summary>
        /// <param name="orientation"></param>
        /// <param name="value"></param>
        /// <param name="extent">The size of the viewable area (a.k.a visible amount)</param>
        /// <param name="max"></param>
        public G2DScrollBar(GoblinEnums.Orientation orientation, int value, int extent, int max)
            : base()
        {
            if (value < 0)
            {
                throw new ArgumentException("value has to be greater than or equal to 0");
            }

            if (extent > max)
            {
                throw new ArgumentException("extent must be smaller than max");
            }

            this.orientation = orientation;
            this.extent      = extent;

            upLeftButton    = new G2DButton();
            downRightButton = new G2DButton();

            if (orientation == GoblinEnums.Orientation.Horizontal)
            {
                upLeftButton.ActionPerformedEvent    += new ActionPerformed(DecrementUnit);
                downRightButton.ActionPerformedEvent += new ActionPerformed(IncrementUnit);
            }
            else
            {
                upLeftButton.ActionPerformedEvent    += new ActionPerformed(IncrementUnit);
                downRightButton.ActionPerformedEvent += new ActionPerformed(DecrementUnit);
            }

            scrollBar                    = new G2DSlider(0, max - extent, value);
            scrollBar.Orientation        = orientation;
            scrollBar.PaintTrack         = false;
            scrollBar.SnapToTicks        = true;
            scrollBar.BackgroundColor    = Color.White;
            scrollBar.StateChangedEvent += new StateChanged(ValueChanged);

            buttonColor = Color.DarkBlue;

            unitIncrement  = 1;
            blockIncrement = 1;

            scrollBar.MinorTickSpacing = blockIncrement;
        }
Пример #2
0
        /// <summary>
        /// Creates the Menus
        /// </summary>
        private void CreateMainMenu()
        {
            if (!menuMusic.IsPlaying)
            {
                menuMusic = soundBank.GetCue("Plunder");
                menuMusic.Play();
            }

            // Create the main panel which holds all other GUI components
            frame = new G2DPanel();
            frame.Bounds = new Rectangle(337, 175, 350, 210);
            frame.Border = GoblinEnums.BorderFactory.LineBorder;
            frame.Transparency = 0.7f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            frame2 = new G2DPanel();
            frame2.Bounds = new Rectangle(262, 150, 500, 300);
            frame2.Border = GoblinEnums.BorderFactory.LineBorder;
            frame2.Transparency = 0.7f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            //Frame after winning
            winners = new G2DPanel();
            winners.Bounds = new Rectangle(175, 400, 350, 210);
            winners.Border = GoblinEnums.BorderFactory.LineBorder;
            winners.Transparency = 0f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            howto = new G2DPanel();
            howto.Bounds = new Rectangle(250, 175, 650, 400);
            howto.Texture = Content.Load<Texture2D>(tutorial1);
            howto.Border = GoblinEnums.BorderFactory.LineBorder;
            howto.Transparency = 1f;

            G2DButton localPlay = new G2DButton("Local Play");
            localPlay.Bounds = new Rectangle(120, 30, 100, 30);
            localPlay.Name = "localPlay";
            localPlay.TextFont = textFont;
            localPlay.Texture = Content.Load<Texture2D>("Images\\three");
            localPlay.HighlightColor = Color.Red;
            localPlay.ActionPerformedEvent += new ActionPerformed(HandleLocalPlay);

            G2DButton networkPlay = new G2DButton("Network Play");
            networkPlay.Bounds = new Rectangle(120, 70, 100, 30);
            networkPlay.Name = "networkPlay";
            networkPlay.TextFont = textFont;
            networkPlay.Texture = Content.Load<Texture2D>("Images\\three");
            networkPlay.HighlightColor = Color.Red;
            networkPlay.ActionPerformedEvent += new ActionPerformed(HandleNetworkPlay);

            G2DButton store = new G2DButton("Store");
            store.Bounds = new Rectangle(120, 110, 100, 30);
            store.Name = "store";
            store.TextFont = textFont;
            store.Texture = Content.Load<Texture2D>("Images\\three");
            store.HighlightColor = Color.Red;
            store.ActionPerformedEvent += new ActionPerformed(HandleStore);

            G2DButton howToPlay = new G2DButton("How To Play");
            howToPlay.Bounds = new Rectangle(120, 150, 100, 30);
            howToPlay.Name = "howToPlay";
            howToPlay.TextFont = textFont;
            howToPlay.Texture = Content.Load<Texture2D>("Images\\three");
            howToPlay.HighlightColor = Color.Red;
            howToPlay.ActionPerformedEvent += new ActionPerformed(howToPlay_ActionPerformedEvent);
            /////////////////////////////////////////////////////////////////////////////////

            G2DButton startGame = new G2DButton("Start Game");
            startGame.Bounds = new Rectangle(120, 30, 100, 30);
            startGame.Name = "startGame";
            startGame.TextFont = textFont;
            startGame.Texture = Content.Load<Texture2D>("Images\\three");
            startGame.HighlightColor = Color.Red;
            startGame.ActionPerformedEvent += new ActionPerformed(HandleStartGame);

            G2DButton hostGame = new G2DButton("Host Game");
            hostGame.Bounds = new Rectangle(120, 30, 100, 30);
            hostGame.Name = "hostGame";
            hostGame.TextFont = textFont;
            hostGame.Texture = Content.Load<Texture2D>("Images\\three");
            hostGame.HighlightColor = Color.Red;
            hostGame.ActionPerformedEvent += new ActionPerformed(HandleHostGame);

            G2DButton joinGame = new G2DButton("Join Game");
            joinGame.Bounds = new Rectangle(120, 70, 100, 30);
            joinGame.Name = "joinGame";
            joinGame.TextFont = textFont;
            joinGame.Texture = Content.Load<Texture2D>("Images\\three");
            joinGame.HighlightColor = Color.Red;
            joinGame.ActionPerformedEvent += new ActionPerformed(HandleJoinGame);

            G2DButton buyUpgrades = new G2DButton("Buy Upgrades");
            buyUpgrades.Bounds = new Rectangle(120, 30, 100, 30);
            buyUpgrades.Name = "buyUpgrades";
            buyUpgrades.TextFont = textFont;
            buyUpgrades.Texture = Content.Load<Texture2D>("Images\\three");
            buyUpgrades.HighlightColor = Color.Red;
            buyUpgrades.ActionPerformedEvent += new ActionPerformed(HandleBuyUpgrades);

            G2DButton back = new G2DButton("Back");
            back.Bounds = new Rectangle(120, 150, 100, 30);
            back.Name = "back";
            back.TextFont = textFont;
            back.Texture = Content.Load<Texture2D>("Images\\three");
            back.HighlightColor = Color.Red;
            back.ActionPerformedEvent += new ActionPerformed(HandleBack);

            G2DButton back2 = new G2DButton("Back");
            back2.Bounds = new Rectangle(110, 160, 100, 30);
            back2.Name = "back2";
            back2.TextFont = textFont;
            back2.Texture = Content.Load<Texture2D>("Images\\three");
            back2.HighlightColor = Color.Red;
            back2.ActionPerformedEvent += new ActionPerformed(HandleBack);

            G2DButton save = new G2DButton("Save");
            save.Bounds = new Rectangle(230, 160, 100, 30);
            save.Name = "save";
            save.TextFont = textFont;
            save.Texture = Content.Load<Texture2D>("Images\\three");
            save.HighlightColor = Color.Red;
            save.ActionPerformedEvent += new ActionPerformed(HandleSave);

            G2DButton quit = new G2DButton("Quit");
            quit.Bounds = new Rectangle(120, 190, 100, 30);
            quit.Name = "quit";
            quit.TextFont = textFont;
            quit.Texture = Content.Load<Texture2D>("Images\\three");
            quit.HighlightColor = Color.Red;
            quit.ActionPerformedEvent += new ActionPerformed(HandleQuit);

            ////////////////////////////*****Store****//////////////////////////////////

            G2DButton upgradeSpeed = new G2DButton("Upgrade Speed");
            upgradeSpeed.Bounds = new Rectangle(20, 30, 130, 30);
            upgradeSpeed.Name = "upgradeSpeed";
            upgradeSpeed.TextFont = textFont;
            upgradeSpeed.Texture = Content.Load<Texture2D>("Images\\three");
            upgradeSpeed.HighlightColor = Color.Red;
            upgradeSpeed.ActionPerformedEvent += new ActionPerformed(upgradeSpeed_ActionPerformedEvent);

            G2DButton upgradeArmour = new G2DButton("Upgrade Armour");
            upgradeArmour.Bounds = new Rectangle(20, 70, 130, 30);
            upgradeArmour.Name = "upgradeArmour";
            upgradeArmour.TextFont = textFont;
            upgradeArmour.Texture = Content.Load<Texture2D>("Images\\three");
            upgradeArmour.HighlightColor = Color.Red;
            upgradeArmour.ActionPerformedEvent += new ActionPerformed(upgradeArmour_ActionPerformedEvent);

            G2DButton upgradeMissle = new G2DButton("Upgrade Missle");
            upgradeMissle.Bounds = new Rectangle(20, 110, 130, 30);
            upgradeMissle.Name = "upgradeMissle";
            upgradeMissle.TextFont = textFont;
            upgradeMissle.Texture = Content.Load<Texture2D>("Images\\three");
            upgradeMissle.HighlightColor = Color.Red;
            upgradeMissle.ActionPerformedEvent += new ActionPerformed(upgradeMissle_ActionPerformedEvent);

            howtonext = new G2DButton("Next");
            howtonext.Bounds = new Rectangle(225, 350, 130, 30);
            howtonext.Name = "howtonext";
            howtonext.TextFont = textFont;
            howtonext.Texture = Content.Load<Texture2D>("Images\\three");
            howtonext.HighlightColor = Color.Red;
            //change
            howtonext.ActionPerformedEvent += new ActionPerformed(howtonext_ActionPerformedEvent);

            howtomenu = new G2DButton("Main Menu");
            howtomenu.Bounds = new Rectangle(450, 350, 130, 30);
            howtomenu.Name = "howtonext";
            howtomenu.TextFont = textFont;
            howtomenu.Texture = Content.Load<Texture2D>("Images\\three");
            howtomenu.HighlightColor = Color.Red;
            //change
            howtomenu.ActionPerformedEvent += new ActionPerformed(howtomenu_ActionPerformedEvent);

            howtoback = new G2DButton("Back");
            howtoback.Bounds = new Rectangle(25, 350, 130, 30);
            howtoback.Name = "howtoback";
            howtoback.TextFont = textFont;
            howtoback.Texture = Content.Load<Texture2D>("Images\\three");
            howtoback.HighlightColor = Color.Red;
            howtoback.ActionPerformedEvent += new ActionPerformed(howtoback_ActionPerformedEvent);

            missleLevel = new G2DLabel();
            missleLevel.Bounds = new Rectangle(170, 115, 130, 30);
            missleLevel.Name = "missleLevel";
            missleLevel.TextFont = textFont;

            armourLevel = new G2DLabel();
            armourLevel.Bounds = new Rectangle(170, 75, 130, 30);
            armourLevel.Name = "armourLevel";
            armourLevel.TextFont = textFont;

            speedLevel = new G2DLabel();
            speedLevel.Bounds = new Rectangle(170, 35, 130, 30);
            speedLevel.Name = "speedLevel";
            speedLevel.TextFont = textFont;

            missleCost = new G2DLabel();
            missleCost.Bounds = new Rectangle(270, 115, 130, 30);
            missleCost.Name = "missleCost";
            missleCost.TextFont = textFont;

            armourCost = new G2DLabel();
            armourCost.Bounds = new Rectangle(270, 75, 130, 30);
            armourCost.Name = "armourCost";
            armourCost.TextFont = textFont;

            speedCost = new G2DLabel();
            speedCost.Bounds = new Rectangle(270, 35, 130, 30);
            speedCost.Name = "speedCost";
            speedCost.TextFont = textFont;

            moneyLevel = new G2DLabel();
            moneyLevel.Bounds = new Rectangle(370, 35, 130, 30);
            moneyLevel.Name = "moneyLevel";
            moneyLevel.TextFont = textFont;
            moneyLevel.TextColor = Color.ForestGreen;

            //////////////////////////////////////////////////////////////////////////////

            scene.UIRenderer.Add2DComponent(frame);
            scene.UIRenderer.Add2DComponent(frame2);
            scene.UIRenderer.Add2DComponent(winners);// added this
            scene.UIRenderer.Add2DComponent(howto);

            frame.AddChild(localPlay);
            frame.AddChild(networkPlay);
            frame.AddChild(store);
            frame.AddChild(startGame);
            frame.AddChild(joinGame);
            frame.AddChild(hostGame);
            frame.AddChild(buyUpgrades);
            frame.AddChild(back);
            frame.AddChild(howToPlay);

            frame2.AddChild(upgradeSpeed);
            frame2.AddChild(upgradeArmour);
            frame2.AddChild(upgradeMissle);
            frame2.AddChild(back2);
            frame2.AddChild(save);

            frame2.AddChild(speedLevel);
            frame2.AddChild(armourLevel);
            frame2.AddChild(missleLevel);

            frame2.AddChild(moneyLevel);

            frame2.AddChild(missleCost);
            frame2.AddChild(speedCost);
            frame2.AddChild(armourCost);
            howto.AddChild(howtonext);
            howto.AddChild(howtoback);
            howto.AddChild(howtomenu);

            localPlay.Enabled = true;
            networkPlay.Enabled = true;
            store.Enabled = true;
            startGame.Enabled = false;
            joinGame.Enabled = false;
            hostGame.Enabled = false;
            buyUpgrades.Enabled = false;
            back.Enabled = false;
            upgradeSpeed.Enabled = false;
            upgradeArmour.Enabled = false;
            upgradeMissle.Enabled = false;
            howToPlay.Enabled = true;

            frame2.Enabled = false;
            frame2.Visible = false;

            startGame.Visible = false;
            joinGame.Visible = false;
            hostGame.Visible = false;
            buyUpgrades.Visible = false;
            back.Visible = false;
            upgradeSpeed.Visible = false;
            upgradeArmour.Visible = false;
            upgradeMissle.Visible = false;
            howToPlay.Visible = true;
            howto.Visible = false;
            howto.Enabled = false;
            howtonext.Visible = false;
            howtonext.Enabled = false;
            howtoback.Visible = false;
            howtoback.Enabled = false;
            howtomenu.Visible = false;
            howtomenu.Enabled = false;
        }
 private void CreateControlPanel()
 {
     objectFrame = new G2DPanel();
     objectFrame.Bounds = new Rectangle(670, State.Height - 200, 120, 190);
     objectFrame.Border = GoblinEnums.BorderFactory.LineBorder;
     objectFrame.BorderColor = Color.Gold;
     // Ranges from 0 (fully transparent) to 1 (fully opaque)
     objectFrame.Transparency = 0.5f;
     //Label for rotation
     G2DLabel label1 = new G2DLabel("Object Rotates along:");
     label1.TextFont = textFont;
     label1.Bounds = new Rectangle(5, 5, 80, 20);
     // Create radio button for x-axis rotation.
     G2DRadioButton radioX = new G2DRadioButton("x-axis");
     radioX.TextFont = textFont;
     radioX.Bounds = new Rectangle(5, 15, 80, 20);
     radioX.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedAxisX);
     // Create radio button for y-axis rotation.
     G2DRadioButton radioY = new G2DRadioButton("y-axis");
     radioY.TextFont = textFont;
     radioY.Bounds = new Rectangle(5, 30, 80, 20);
     radioY.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedAxisY);
     // Create radio button for z-axis rotation.
     G2DRadioButton radioZ = new G2DRadioButton("z-axis");
     radioZ.TextFont = textFont;
     radioZ.Bounds = new Rectangle(5, 45, 80, 20);
     radioZ.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedAxisZ);
     //Create a ButtonGroup object which controls the radio button selections
     group1 = new ButtonGroup();
     group1.Add(radioX);
     group1.Add(radioY);
     group1.Add(radioZ);
     //Label for rotation direction.
     G2DLabel label2 = new G2DLabel("Rotation Direction:");
     label2.TextFont = textFont;
     label2.Bounds = new Rectangle(5, 65, 80, 20);
     // Create radio button for clockwise
     G2DRadioButton clockwise = new G2DRadioButton("Clockwise");
     clockwise.TextFont = textFont;
     clockwise.Bounds = new Rectangle(5, 80, 80, 20);
     clockwise.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedDirection);
     // Create radio button for counterclockwise.
     G2DRadioButton counterclockwise = new G2DRadioButton("Counterclockwise");
     counterclockwise.TextFont = textFont;
     counterclockwise.Bounds = new Rectangle(5, 95, 80, 20);
     counterclockwise.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedDirection);
     //Create a ButtonGroup object which controls the radio button selections.
     group2 = new ButtonGroup();
     group2.Add(clockwise);
     group2.Add(counterclockwise);
     //Label for speed
     G2DLabel label3 = new G2DLabel("Rotation Speed:");
     label3.TextFont = textFont;
     label3.Bounds = new Rectangle(5, 115, 80, 20);
     //Slider for speed of rotation
     slider = new G2DSlider();
     slider.TextFont = textFont;
     slider.Bounds = new Rectangle(5, 145, 110, 20);
     slider.Maximum = 8;
     slider.Minimum = 0;
     slider.MajorTickSpacing = 0;
     slider.MinorTickSpacing = 1;
     slider.Value = 0;
     slider.PaintTicks = true;
     slider.PaintLabels = true;
     slider.StateChangedEvent += new StateChanged(HandleStateChangedSpeed);
     G2DButton reset = new G2DButton("Reset");
     reset.Bounds = new Rectangle(5, 165, 55, 20);
     reset.TextFont = textFont;
     reset.ActionPerformedEvent += new ActionPerformed(HandleActionReset);
     G2DButton rotate = new G2DButton("Rotate");
     rotate.Bounds = new Rectangle(65, 165, 50, 20);
     rotate.ActionPerformedEvent += new ActionPerformed(HandleActionRotate);
     rotate.TextFont = textFont;
     objectFrame.AddChild(label1);
     objectFrame.AddChild(radioX);
     objectFrame.AddChild(radioY);
     objectFrame.AddChild(radioZ);
     objectFrame.AddChild(label2);
     objectFrame.AddChild(clockwise);
     objectFrame.AddChild(counterclockwise);
     objectFrame.AddChild(label3);
     objectFrame.AddChild(slider);
     objectFrame.AddChild(reset);
     objectFrame.AddChild(rotate);
     scene.UIRenderer.Add2DComponent(objectFrame);
 }
Пример #4
0
        private void CreateControlPanel()
        {
            objectFrame = new G2DPanel();
            objectFrame.Bounds = new Rectangle(700, State.Height - 160, 90, 150);
            objectFrame.Border = GoblinEnums.BorderFactory.LineBorder;
            objectFrame.BorderColor = Color.Gold;
            // Ranges from 0 (fully transparent) to 1 (fully opaque)
            objectFrame.Transparency = 0.5f;

            G2DButton visualizeFile = new G2DButton("Visulize");
            visualizeFile.TextFont = textFont;
            visualizeFile.Bounds = new Rectangle(5, 5, 70, 20);
            visualizeFile.ActionPerformedEvent += new ActionPerformed(HandleVisualizeActionsPerformed);
            objectFrame.AddChild(visualizeFile);

            G2DRadioButton radioDownTown = new G2DRadioButton("Downtown");
            radioDownTown.TextFont = textFont;
            radioDownTown.Bounds = new Rectangle(5, 25, 70, 20);
            radioDownTown.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedSection);
            G2DRadioButton radioMidtownEast = new G2DRadioButton("MidtownEast");
            radioMidtownEast.TextFont = textFont;
            radioMidtownEast.Bounds = new Rectangle(5, 40, 70, 20);
            radioMidtownEast.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedSection);
            G2DRadioButton radioMidtownWest = new G2DRadioButton("MidtownWest");
            radioMidtownWest.TextFont = textFont;
            radioMidtownWest.Bounds = new Rectangle(5, 55, 70, 20);
            radioMidtownWest.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedSection);
            G2DRadioButton radioUptown = new G2DRadioButton("Uptown");
            radioUptown.TextFont = textFont;
            radioUptown.Bounds = new Rectangle(5, 70, 70, 20);
            radioUptown.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedSection);
            group1 = new ButtonGroup();
            group1.Add(radioDownTown);
            group1.Add(radioMidtownEast);
            group1.Add(radioMidtownWest);
            group1.Add(radioUptown);
            objectFrame.AddChild(radioDownTown);
            objectFrame.AddChild(radioMidtownEast);
            objectFrame.AddChild(radioMidtownWest);
            objectFrame.AddChild(radioUptown);

            G2DButton focusButton = new G2DButton("Camera Focus");
            focusButton.TextFont = textFont;
            focusButton.Bounds = new Rectangle(5, 95, 80, 20);
            focusButton.ActionPerformedEvent += new ActionPerformed(HandleCameraActionsPerformed);
            objectFrame.AddChild(focusButton);

            G2DButton resetButton = new G2DButton("Reset");
            resetButton.TextFont = textFont;
            resetButton.Bounds = new Rectangle(5, 120, 80, 20);
            resetButton.ActionPerformedEvent += new ActionPerformed(HandleResetActionsPerformed);
            objectFrame.AddChild(resetButton);

            scene.UIRenderer.Add2DComponent(objectFrame);
        }
Пример #5
0
        private void Create2DGUI()
        {
            // Create the main panel which holds all other GUI components
            G2DPanel frame = new G2DPanel();
            frame.Bounds = new Rectangle(325, State.Height - 180, 150, 170);
            frame.Border = GoblinEnums.BorderFactory.LineBorder;
            frame.Transparency = 0.7f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            label = "User Interfaces";

            // Loads the fonts used for rendering UI labels and slider labels
            uiFont = Content.Load<SpriteFont>("UIFont");
            sliderFont = Content.Load<SpriteFont>("SliderFont");

            // Create four Radio Buttons
            G2DRadioButton radio1 = new G2DRadioButton("User Interfaces");
            radio1.TextFont = uiFont;
            radio1.Bounds = new Rectangle(10, 5, 80, 20);
            radio1.DoClick(); // make this radio button selected initially
            radio1.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            G2DRadioButton radio2 = new G2DRadioButton("Computer Graphics");
            radio2.TextFont = uiFont;
            radio2.Bounds = new Rectangle(10, 25, 80, 20);
            radio2.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            G2DRadioButton radio3 = new G2DRadioButton("Augmented Reality");
            radio3.TextFont = uiFont;
            radio3.Bounds = new Rectangle(10, 45, 80, 20);
            radio3.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            sliderRadio = new G2DRadioButton("Slider Control");
            sliderRadio.TextFont = uiFont;
            sliderRadio.Bounds = new Rectangle(10, 65, 80, 20);
            sliderRadio.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            // Create a slider
            G2DSlider slider = new G2DSlider();
            slider.TextFont = sliderFont;
            slider.Bounds = new Rectangle(5, 100, 140, 30);
            slider.Maximum = 40;
            slider.MajorTickSpacing = 20;
            slider.MinorTickSpacing = 5;
            slider.PaintTicks = true;
            slider.PaintLabels = true;
            slider.StateChangedEvent += new StateChanged(HandleStateChanged);

            // Create a ButtonGroup object which controls the radio 
            // button selections
            ButtonGroup group = new ButtonGroup();
            group.Add(radio1);
            group.Add(radio2);
            group.Add(radio3);
            group.Add(sliderRadio);

            // Create a Button
            G2DButton button = new G2DButton("I Love");
            button.TextFont = uiFont;
            button.Bounds = new Rectangle(50, 145, 50, 20);
            button.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            // Add all of the components to the main panel
            frame.AddChild(radio1);
            frame.AddChild(radio2);
            frame.AddChild(radio3);
            frame.AddChild(sliderRadio);
            frame.AddChild(button);
            frame.AddChild(slider);

            scene.UIRenderer.Add2DComponent(frame);
        }
Пример #6
0
        /// <summary>
        /// Creates a scroll bar with the specified orientation, value, extent, and maximum.
        /// </summary>
        /// <param name="orientation"></param>
        /// <param name="value"></param>
        /// <param name="extent">The size of the viewable area (a.k.a visible amount)</param>
        /// <param name="max"></param>
        public G2DScrollBar(GoblinEnums.Orientation orientation, int value, int extent, int max)
            : base()
        {
            if (value < 0)
                throw new ArgumentException("value has to be greater than or equal to 0");

            if (extent > max)
                throw new ArgumentException("extent must be smaller than max");

            this.orientation = orientation;
            this.extent = extent;

            upLeftButton = new G2DButton();
            downRightButton = new G2DButton();

            if (orientation == GoblinEnums.Orientation.Horizontal)
            {
                upLeftButton.ActionPerformedEvent += new ActionPerformed(DecrementUnit);
                downRightButton.ActionPerformedEvent += new ActionPerformed(IncrementUnit);
            }
            else
            {
                upLeftButton.ActionPerformedEvent += new ActionPerformed(IncrementUnit);
                downRightButton.ActionPerformedEvent += new ActionPerformed(DecrementUnit);
            }

            scrollBar = new G2DSlider(0, max - extent, value);
            scrollBar.Orientation = orientation;
            scrollBar.PaintTrack = false;
            scrollBar.SnapToTicks = true;
            scrollBar.BackgroundColor = Color.White;
            scrollBar.StateChangedEvent += new StateChanged(ValueChanged);

            buttonColor = Color.DarkBlue;

            unitIncrement = 1;
            blockIncrement = 1;

            scrollBar.MinorTickSpacing = blockIncrement;
        }