private void OnRemoveClicked(ContextMenuButton button) { _editor.Remove(_key); }
private void OnEditClicked(ContextMenuButton button) { var keyType = _editor.Values.Type.GetGenericArguments()[0]; if (keyType == typeof(string) || keyType.IsPrimitive) { var popup = RenamePopup.Show(Parent, Bounds, Text, false); popup.Validate += (renamePopup, value) => { object newKey; if (keyType.IsPrimitive) { newKey = JsonSerializer.Deserialize(value, keyType); } else { newKey = value; } return(!((IDictionary)_editor.Values[0]).Contains(newKey)); }; popup.Renamed += renamePopup => { object newKey; if (keyType.IsPrimitive) { newKey = JsonSerializer.Deserialize(renamePopup.Text, keyType); } else { newKey = renamePopup.Text; } _editor.ChangeKey(_key, newKey); _key = newKey; Text = _key.ToString(); }; } else if (keyType.IsEnum) { var popup = RenamePopup.Show(Parent, Bounds, Text, false); var picker = new EnumComboBox(keyType) { AnchorPreset = AnchorPresets.StretchAll, Offsets = Margin.Zero, Parent = popup, EnumTypeValue = _key, }; picker.ValueChanged += () => { popup.Hide(); object newKey = picker.EnumTypeValue; if (!((IDictionary)_editor.Values[0]).Contains(newKey)) { _editor.ChangeKey(_key, newKey); _key = newKey; Text = _key.ToString(); } }; } else { throw new NotImplementedException("Missing editing for dictionary key type " + keyType); } }
private void OnRemoveClicked(ContextMenuButton button) { Editor.Remove(Index); }
private void OnMoveDownClicked(ContextMenuButton button) { Editor.Move(Index, Index + 1); }
private void OnMoveUpClicked(ContextMenuButton button) { Editor.Move(Index, Index - 1); }
private void OnShowCurrentLODClicked(ContextMenuButton obj) { _showCurrentLOD = !_showCurrentLOD; _showCurrentLODButton.Icon = _showCurrentLOD ? Style.Current.CheckBoxTick : SpriteHandle.Invalid; }
private void OnShowFloorModelClicked(ContextMenuButton obj) { _floorModel.IsActive = !_floorModel.IsActive; _showFloorButton.Icon = _floorModel.IsActive ? Style.Current.CheckBoxTick : SpriteHandle.Invalid; }