/// <summary> /// Совершаем действие предусмотренное элементом /// </summary> /// <param name="item">Элемент</param> public void DoAction(MenuItem item) { switch (item.Action) { case ActionType.SubMenu: { LoadSettings(item.Items); _CurrentMenu = item.Items; if (item.Name == "Звук") _Delay = 2; _Delay = 15; break; } case ActionType.PreviousMenu: { _Delay = 15; if (item.Parent.Parent != null) { LoadSettings(item.Parent.Parent.Items); _CurrentMenu = item.Parent.Parent.Items; } else { LoadSettings(_Menu.Items); _CurrentMenu = _Menu.Items; } break; } case ActionType.ReturnToGame: { _Parent.CloseSettings(); break; } case ActionType.LeaveToSystem: { _CurrentDialog = new Dialog(_Game,"Вы дейтсвительно хотите выйти из системы?"); _CurrentDialog.OnDialogClose += OnLeaveToSystem; break; } case ActionType.Leave: { _Game.ChangeScreen(ScreenType.TitleScreen); break; } } }
/// <summary> /// Обрабатываем выход в систему /// </summary> /// <param name="result">Результат модального окна</param> private void OnLeaveToSystem(ModalResult result) { if (result == ModalResult.Ok) _Game.CloseGame(); else { _CurrentDialog.OnDialogClose -= OnLeaveToSystem; _CurrentDialog = null; } }