/// <summary> /// Constructor. /// </summary> public OpponentsInfo() { // set the opponents if (OpponentsSettings.Default.TwoPlayersMode) { opponents = new NoAIOpponent(); } else if (OpponentsSettings.Default.WebServiceOpponent) { opponents = new HumanVsWebService(); } // set the opponents info text using settings values SetOpponentsInfoText(); // listen for events OpponentsSettings.Default.PropertyChanged += property_Changed; }
private void property_Changed(object sender, PropertyChangedEventArgs e) { // if the opponents type property has changed if (e.PropertyName == "TwoPlayersMode" && OpponentsSettings.Default.TwoPlayersMode && !(opponents is NoAIOpponent)) { // dispose the old opponents opponents.Dispose(); // set the opponents opponents = new NoAIOpponent(); // set the model opponents.Model = model; // set the opponents info text using settings values SetOpponentsInfoText(); } else if (e.PropertyName == "WebServiceOpponent" && OpponentsSettings.Default.WebServiceOpponent && !(opponents is HumanVsWebService)) { // dispose the old opponents opponents.Dispose(); // set the opponents opponents = new HumanVsWebService(); // set the model opponents.Model = model; // set the opponents info text using settings values SetOpponentsInfoText(); } else if (e.PropertyName == "AIOpponentPlaysWhite") { // set the opponents info text using settings values SetOpponentsInfoText(); } }