public G2DKeyboard(int keySize, KeyboardLayout layout) : base() { this.keySize = keySize; this.layout = layout; keyTexture = null; keys = new G2DButton[53]; for (int i = 0; i < keys.Length; i++) { keys[i] = new G2DButton(); } shiftPressed = false; PrepareKeyStrings(); MapStringsToKeyButtons(); }
protected virtual void Initialize() { tooltipLabel = new G2DLabel(); controlButton = new G2DButton(); playTimeSlider = new PlayTimeSlider(tooltipLabel); playTimeLabel = new G2DLabel(); tooltipLabel.Visible = false; playTimeLabel.DrawBorder = true; playTimeSlider.DrawBorder = true; playTimeLabel.HorizontalAlignment = GoblinEnums.HorizontalAlignment.Center; playTimeLabel.VerticalAlignment = GoblinEnums.VerticalAlignment.Center; tooltipLabel.HorizontalAlignment = GoblinEnums.HorizontalAlignment.Center; tooltipLabel.VerticalAlignment = GoblinEnums.VerticalAlignment.Center; tooltipLabel.Visible = false; controlButton.ActionPerformedEvent += new ActionPerformed(HandleControlButtonPress); playTimeSlider.StateChangedEvent += new StateChanged(HandleSliderMove); playTimeSlider.Maximum = (int)(duration / 1000); durationStr = "0:00"; positionStr = "0:00"; UpdateDurationString(); playing = false; loop = false; allowNegative = false; curPosition = 0; startPosition = 0; name = "G2DMediaControl"; }
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); }
public G2DKeyboard(int keySize, KeyboardLayout layout) : base() { this.keySize = keySize; this.layout = layout; keyTexture = null; keys = new G2DButton[53]; for (int i = 0; i < keys.Length; i++) keys[i] = new G2DButton(); shiftPressed = false; PrepareKeyStrings(); MapStringsToKeyButtons(); }