private void Back_Executed(object arg) { var currentValue = _content.Data; if (_content.Data is INavigatable navigatable) { navigatable.Navigate -= Content_Navigate; } if (_content.Data is INavigationNode navigationNode) { navigationNode.Close -= NavigationNode_Close; } _content = _history.Pop(); if (_content.Data is INavigatable navigatable2) { navigatable2.Navigate += Content_Navigate; if (arg == null) { navigatable2.OnNavigatedFrom(currentValue); } } if (_content.Data is INavigationNode navigationNode2) { navigationNode2.Close += NavigationNode_Close; } Back.CanBeExecuted = _history.Any(); OnPropertyChanged(nameof(Content)); }
private void Showman_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(GameAccount.AccountType)) { UpdateShowman(); return; } if (e.PropertyName == nameof(GameAccount.SelectedAccount)) { if (_showman.SelectedAccount == _computerShowmans.Last()) // Новый ведущий { var account = new ComputerAccount { CanBeDeleted = true }; var newShowmanAccount = new ShowmanViewModel(account); newShowmanAccount.Add += NewShowmanAccount_Add; var contentBox = new ContentBox { Data = newShowmanAccount, Title = Resources.NewShowman, Cancel = _closeNewShowman }; Navigate?.Invoke(contentBox); return; } _model.Showman = _showman.SelectedAccount; CheckUniqueAccounts(); } }
private void EditComputerAccount_Executed(object arg) { var computerAccount = (ComputerAccount)arg; var newComputerAccount = new ComputerAccountViewModel(computerAccount.Clone(), computerAccount); newComputerAccount.Add += NewComputerAccount_Edit; var contentBox = new ContentBox { Data = newComputerAccount, Title = Resources.ComputerPlayer }; Navigate?.Invoke(contentBox); }
private void Human_AccountEditing() { ActiveView = new ContentBox { Data = Human, Title = Resources.ChangeAccount, Cancel = new CustomCommand(arg => { Human.NewAccount = null; Cancel_Executed(arg); }) }; }
private void SelectPackage_Executed(object arg) { var code = (PackageSourceTypes)arg; switch (code) { case PackageSourceTypes.Next: Package = new NextPackageSource(); break; case PackageSourceTypes.Random: Package = new RandomPackageSource(); break; case PackageSourceTypes.RandomServer: Package = new RandomServerPackageSource(); break; case PackageSourceTypes.Local: var packagePath = PlatformManager.Instance.SelectLocalPackage(); if (packagePath != null) { Package = new CustomPackageSource(packagePath); } break; case PackageSourceTypes.SIStorage: var contentBox = new ContentBox { Data = StorageInfo, Title = Resources.SIStorage }; StorageInfo.Init(); Navigate?.Invoke(contentBox); break; case PackageSourceTypes.VK: try { Process.Start(Resources.ThemesLink); } catch (Exception exc) { PlatformManager.Instance.ShowMessage(string.Format(Resources.VKThemesError + "\r\n{1}", Resources.ThemesLink, exc.Message), MessageType.Error); } break; } }
private void HumanPlayer_NewAccountCreating() { ActiveView = new ContentBox { Data = Human, Title = Resources.NewAccount, Cancel = new CustomCommand(arg => { Human.NewAccount = null; Human.HumanPlayer = _commonSettings.Humans2.Last(); Cancel_Executed(arg); }) { CanBeExecuted = _commonSettings.Humans2.Any() } }; }
private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e) { var acc = (GameAccount)sender; if (e.PropertyName == nameof(GameAccount.AccountType)) { UpdatePlayer(acc); } else if (e.PropertyName == nameof(GameAccount.SelectedAccount)) { var index = Players.IndexOf(acc); if (index > -1 && index < _model.Players.Length) { _model.Players[index] = acc.SelectedAccount; } if (acc.SelectedAccount == _computerPlayers.Last()) { var account = new ComputerAccount() { CanBeDeleted = true }; // Зададим ему рандомные характеристики account.Randomize(); var newComputerAccount = new ComputerAccountViewModel(account, null); newComputerAccount.Add += NewComputerAccount_Add; var contentBox = new ContentBox { Data = newComputerAccount, Title = Resources.NewPlayer, Cancel = _closeNewPlayer }; Navigate?.Invoke(contentBox); } CheckUniqueAccounts(); } }
private void NewGame_Executed(object arg) { gameSettings = new GameSettingsViewModel(_userSettings.GameSettings, _commonSettings, _userSettings, true) { Human = Human, ChangeSettings = ChangeSettings }; gameSettings.StartGame += OnStartGame; gameSettings.PrepareForGame(); Prepare(gameSettings); var contextBox = new ContentBox { Data = gameSettings, Title = Resources.NewGame }; Content = new NavigatorViewModel { Content = contextBox, Cancel = _closeContent }; }
private void Content_Navigate(ContentBox contentBox) { Content = contentBox; }