public void SetSelected(int key) { MyGuiControlRadioButton radioButtonByKey = null; foreach (MyGuiControlRadioButton radioButton in m_radioButtons) { if (radioButton.Key == key) { radioButtonByKey = radioButton; break; } } if (radioButtonByKey != null) { UnselectSelected(); radioButtonByKey.OnSelect -= OnRadioButtonSelect; radioButtonByKey.Selected = true; radioButtonByKey.OnSelect += OnRadioButtonSelect; m_selected = radioButtonByKey; if (OnSelectedChanged != null) { OnSelectedChanged(this); } } }
private void UnselectSelected() { foreach (MyGuiControlRadioButton radioButton in m_radioButtons) { if (radioButton.Selected) { radioButton.Selected = false; } } m_selected = null; }
public int?GetSelectedKey() { MyGuiControlRadioButton selectedRadioButton = GetSelected(); if (selectedRadioButton != null) { return(m_selected.Key); } else { return(null); } }
public void SetSelected(int key) { MyGuiControlRadioButton radioButtonByKey = null; foreach (MyGuiControlRadioButton radioButton in m_radioButtons) { if (radioButton.Key == key) { radioButtonByKey = radioButton; break; } } if (radioButtonByKey != null) { UnselectSelected(); radioButtonByKey.OnSelect -= OnRadioButtonSelect; radioButtonByKey.Selected = true; radioButtonByKey.OnSelect += OnRadioButtonSelect; m_selected = radioButtonByKey; if(OnSelectedChanged != null) { OnSelectedChanged(this); } } }
private void OnRadioButtonSelect(MyGuiControlRadioButton sender) { SetSelected(sender.Key); }
public void Remove(MyGuiControlRadioButton radioButton) { radioButton.OnSelect -= OnRadioButtonSelect; m_radioButtons.Remove(radioButton); }
public void Add(MyGuiControlRadioButton radioButton) { m_radioButtons.Add(radioButton); radioButton.OnSelect += OnRadioButtonSelect; }
public MyGuiControlRadioButtonGroup() { m_radioButtons = new List<MyGuiControlRadioButton>(); m_selected = null; }
public MyGuiControlRadioButtonGroup() { m_radioButtons = new List <MyGuiControlRadioButton>(); m_selected = null; }
public void LoadControls() { m_controls = new List<MyGuiControlBase>(); Vector2 labelOffset = new Vector2(-0.015f, 0f); Vector2 controlsOriginLeft = m_position + new Vector2(-m_size.Value.X / 2.0f + 0.025f, -m_size.Value.Y / 2.0f + 0.025f); Vector2 controlsOriginRight = m_position + new Vector2(m_size.Value.X / 2.0f - 0.025f, -m_size.Value.Y / 2.0f + 0.025f); Vector2 controlsDelta = MyGuiConstants.CONTROLS_DELTA * 0.6f; // add panel //m_controls.Add(new MyGuiControlPanel(m_parentScreen, m_position, m_size, m_backgroundColor.Value, null, null, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); m_controls.Add(new MyGuiControlPanel(m_parent, m_position, m_size, m_backgroundColor.Value, 2, MyGuiConstants.TREEVIEW_VERTICAL_LINE_COLOR)); #region shape types m_controls.Add(new MyGuiControlLabel(m_parent, controlsOriginLeft + labelOffset, null, MyTextsWrapperEnum.EditVoxelHandShapeType, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_voxelShapeTypeRadioButtonGroup = new MyGuiControlRadioButtonGroup(); foreach (MyVoxelHandShapeType voxelShapeType in MyGuiEditorVoxelHandHelpers.MyEditorVoxelHandShapeHelperTypesEnumValues) { controlsOriginLeft += controlsDelta; MyGuiEditorVoxelHandHelper voxelHandHelper = MyGuiEditorVoxelHandHelpers.GetEditorVoxelHandShapeHelper(voxelShapeType); MyGuiControlRadioButton voxelShapeTypeRadioButton = new MyGuiControlRadioButton(m_parent, controlsOriginLeft, (int)voxelShapeType, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); MyGuiControlLabel voxelShapeTypeDescription = new MyGuiControlLabel(m_parent, controlsOriginLeft + new Vector2(voxelShapeTypeRadioButton.GetSize().Value.X, 0.0f), null, voxelHandHelper.Description, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_controls.Add(voxelShapeTypeRadioButton); m_controls.Add(voxelShapeTypeDescription); m_voxelShapeTypeRadioButtonGroup.Add(voxelShapeTypeRadioButton); } #endregion controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; #region voxel mode types m_controls.Add(new MyGuiControlLabel(m_parent, controlsOriginLeft + labelOffset, null, MyTextsWrapperEnum.EditVoxelHandShapeMode, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_voxelShapeModeRadioButtonGroup = new MyGuiControlRadioButtonGroup(); foreach (MyMwcVoxelHandModeTypeEnum voxelModeType in MyGuiEditorVoxelHandHelpers.MyEditorVoxelHandModeHelperTypesEnumValues) { controlsOriginLeft += controlsDelta; MyGuiEditorVoxelHandHelper voxelHandHelper = MyGuiEditorVoxelHandHelpers.GetEditorVoxelHandModeHelper(voxelModeType); MyGuiControlRadioButton voxelShapeModeRadioButton = new MyGuiControlRadioButton(m_parent, controlsOriginLeft, (int)voxelModeType, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); MyGuiControlLabel voxelShapeModeDescription = new MyGuiControlLabel(m_parent, controlsOriginLeft + new Vector2(voxelShapeModeRadioButton.GetSize().Value.X, 0.0f), null, voxelHandHelper.Description, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_controls.Add(voxelShapeModeRadioButton); m_controls.Add(voxelShapeModeDescription); m_voxelShapeModeRadioButtonGroup.Add(voxelShapeModeRadioButton); } #endregion controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; #region is projected m_controls.Add(new MyGuiControlLabel(m_parent, controlsOriginLeft + labelOffset, null, MyTextsWrapperEnum.EditVoxelHandIsProjected, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_controls.Add(m_isProjectedCheckbox = new MyGuiControlCheckbox(m_parent, new Vector2(controlsOriginRight.X - MyGuiConstants.CHECKBOX_SIZE.X, controlsOriginLeft.Y), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR)); m_isProjectedCheckbox.Checked = MyEditorVoxelHand.IsProjected; m_isProjectedCheckbox.OnCheck = OnCheckboxChecked; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; m_controls.Add(new MyGuiControlLabel(m_parent, controlsOriginLeft + labelOffset, null, MyTextsWrapperEnum.EditVoxelHandIsProjectedToWaypoints, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_controls.Add(m_isProjectedOnWaypointCheckbox = new MyGuiControlCheckbox(m_parent, new Vector2(controlsOriginRight.X - MyGuiConstants.CHECKBOX_SIZE.X, controlsOriginLeft.Y), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR)); m_isProjectedOnWaypointCheckbox.Checked = MyEditorVoxelHand.IsProjectedToWaypoints; m_isProjectedOnWaypointCheckbox.OnCheck = OnCheckboxChecked; #endregion controlsOriginLeft += new Vector2(0, MyGuiConstants.SLIDER_HEIGHT); m_offsetForSizeProperties = controlsOriginLeft.Y; RecreateDynamicProperties(); m_voxelShapeTypeRadioButtonGroup.SetSelected((int)MyEditorVoxelHand.VoxelHandShape.GetShapeType()); m_voxelShapeTypeRadioButtonGroup.OnSelectedChanged += OnRadioButtonSelectedChange; m_voxelShapeModeRadioButtonGroup.SetSelected((int)MyEditorVoxelHand.VoxelHandShape.ModeType); m_voxelShapeModeRadioButtonGroup.OnSelectedChanged += OnRadioButtonSelectedChange; }