/// <summary> /// Handles state changed events. /// </summary> /// <param name="source"></param> private void HandleStateChanged(object source) { G2DComponent comp = (G2DComponent)source; if (comp is G2DSlider) { sliderRadio.DoClick(); label = "Slider value is " + ((G2DSlider)comp).Value; rotationRate = ((G2DSlider)comp).Value * 0.2f; } }
/// <summary> /// Handles action performed events. /// </summary> /// <param name="source"></param> private void HandleActionPerformed(object source) { G2DComponent comp = (G2DComponent)source; if (comp is G2DButton) { label = comp.Text + " Goblin XNA!!"; } else if (comp is G2DRadioButton) { label = comp.Text; } }
/// <summary> /// Adds a 2D UI component to be rendered on the screen. /// </summary> /// <remarks>You should only add top-level components that do not have a parent component.</remarks> /// <param name="comp2d">A top-level G2DComponent object</param> public void Add2DComponent(G2DComponent comp2d) { if (!comp2Ds.Contains(comp2d)) { if (comp2d.HasParent) { throw new GoblinException("You should only add root components to this list. " + "Any component with parents are automatically rendered by its parent " + "component"); } else { comp2Ds.Add(comp2d); comp2d.RegisterKeyInput(); comp2d.RegisterMouseInput(); } } }
/// <summary> /// Removes a 2D UI component from the rendering process. /// </summary> /// <param name="comp2d"></param> public void Remove2DComponent(G2DComponent comp2d) { comp2Ds.Remove(comp2d); comp2d.RemoveKeyInput(); comp2d.RemoveMouseInput(); }