/// <summary> /// Gets or creates a profile and makes sure it is set to default /// </summary> /// <param name="manager">manager for the console</param> /// <param name="profileNumber">index of the profile to retrieve. a new profile is created if this index is too big. a max of one profile will be created</param> /// <returns></returns> private ConsoleProfile SafeGetDefaultProfile(ConsoleProfilesManager manager, int profileNumber) { ConsoleProfile profile = null; try { if (manager.EnumerateConsoleProfiles().Count() > profileNumber) { profile = manager.EnumerateConsoleProfiles().ElementAt(profileNumber); } else { profile = manager.CreateConsoleProfile(true); } manager.SetDefaultProfile(profile); profile.SignIn(UserIndex.Zero); } catch (Exception ex) { MessageBox.Show("There was a problem getting a profile from " + manager.Console.Name + "\n\nException: " + ex.Message, "Certificaton Assistance Tool"); } return(profile); }
public void setup() { // get a profile manager for each console try { this.profileManager1 = xboxDevice1.XboxConsole.CreateConsoleProfilesManager(); this.profileManager2 = xboxDevice2.XboxConsole.CreateConsoleProfilesManager(); this.profileManager3 = xboxDevice3.XboxConsole.CreateConsoleProfilesManager(); } catch { } // sign out all profiles profileManager1.SignOutAllUsers(); profileManager2.SignOutAllUsers(); profileManager3.SignOutAllUsers(); // select and sign in a profile on each console if (profileManager1.EnumerateConsoleProfiles().Any()) { profileA = profileManager1.GetDefaultProfile(); if (profileA == null) { profileA = profileManager1.EnumerateConsoleProfiles().First(); profileManager1.SetDefaultProfile(profileA); } } else { profileA = profileManager1.CreateConsoleProfile(true); } profileA.SignIn(UserIndex.Zero); if (profileManager2.EnumerateConsoleProfiles().Any()) { profileB = profileManager2.GetDefaultProfile(); if (profileB == null) { profileB = profileManager2.EnumerateConsoleProfiles().First(); profileManager2.SetDefaultProfile(profileB); } } else { profileB = profileManager2.CreateConsoleProfile(true); } profileB.SignIn(UserIndex.Zero); if (profileManager3.EnumerateConsoleProfiles().Any()) { profileC = profileManager3.GetDefaultProfile(); if (profileC == null) { profileC = profileManager3.EnumerateConsoleProfiles().First(); profileManager3.SetDefaultProfile(profileC); } } else { profileC = profileManager3.CreateConsoleProfile(true); } profileC.SignIn(UserIndex.Zero); // set Play Through Speakers on all three consoles xboxDevice1.RunCatScript("Voice_Output_Set_Speakers"); xboxDevice2.RunCatScript("Voice_Output_Set_Speakers"); xboxDevice3.RunCatScript("Voice_Output_Set_Speakers"); // Set privacy settings to voice/text/video to Friends Only profile A xboxDevice1.RunCatScript("Communications_Set_Friends_Only"); // Set privace settings to voice/text/video enabled for Everyone on profile B and C xboxDevice2.RunCatScript("Communications_Set_Everyone"); xboxDevice3.RunCatScript("Communications_Set_Everyone"); // Friend profiles A and B profileA.Friends.SendFriendRequest(profileB); profileB.Friends.AcceptFriendRequest(profileA); // Launch the game on all three consoles xboxDevice1.LaunchTitle(); xboxDevice2.LaunchTitle(); xboxDevice3.LaunchTitle(); }