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);
        }
 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);
 }
Esempio n. 3
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);
        }