/// <summary> /// Re-bindes players data to the view from the <see cref="Models.Strategy.IStrategy"/> when a child window closes. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void Window_ChildClose(object sender, PresenterArgs args) { int pSelIndex = _view.PlayerSelectedIndex; BindPlayersData(); if (_view.PlayersListBox.Count != 1) { _view.PlayerSelectedIndex = pSelIndex; } }
/// <summary> /// Re-bindes teams and players data to the view from the <see cref="Models.Strategy.IStrategy"/> /// when a child window closes. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void Window_ChildClose(object sender, PresenterArgs args) { int tSelIndex = _view.TeamSelectedIndex; int pSelIndex = _view.PlayerSelectedIndex; int oldTeamsCount = _view.TeamsListBox.Count; List <Team> teams = BindTeamsData(); // Saftey check if child window removed or created team. if (teams.InternalCount() != oldTeamsCount) { return; } _view.TeamSelectedIndex = tSelIndex; if (_view.PlayersListBox.Count == pSelIndex) { pSelIndex--; } _view.PlayerSelectedIndex = pSelIndex; }
/// <summary> /// The method that gets called when a child windows wanting to invoke the <see cref="ChildClosed"/> event in /// order to notify all other presenters that inherit the <see cref="BasePresenter"/>. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnChildClosed(object sender, PresenterArgs e) { Log.Info($"Child window closed. Invoking ChildClosed => {e.Child}"); ChildClosed?.Invoke(sender, e); }