RoboPlayerPlugin playerActivationChanged(String playerName, Boolean activated) { RoboPlayerPlugin plugin = null; if (activated) { plugin = RoboManager.ActivatePlugin(playerName); plugin.Player.Position.PropertyChanged += Position_PropertyChanged; RoboPlayerControl control = new RoboPlayerControl(); control.RoboPlayer = plugin.Player; playerPanel.Controls.Add(control); } else { plugin = RoboManager.ActivePlayers.FirstOrDefault(elem => elem.Name == playerName); if (plugin != null) { plugin.Player.Position.PropertyChanged -= Position_PropertyChanged; RoboPlayerControl playerControl = playerPanel.Controls .Cast <RoboPlayerControl>() .FirstOrDefault(control => control.RoboPlayer == plugin.Player); if (playerControl != null) { playerPanel.Controls.Remove(playerControl); } } RoboManager.DeactivatePlugin(playerName); } return(plugin); }
private void RoboManagerControlBinding_Format(object sender, ConvertEventArgs e) { RoboPlayerControl control = new RoboPlayerControl(); control.RoboPlayer = e.Value as RoboPlayer; e.Value = control; }