예제 #1
0
        /// <summary>
        /// Get alphabetically first existing profile or create a new one if there are none
        /// </summary>
        /// <param name="device">The xbox to get or create a profile on</param>
        /// <param name="wasCreated">Receives a value indicating a profile was created</param>
        /// <returns>Returns the found or created profile</returns>
        private ConsoleProfile GetFirstProfile(IXboxDevice device, out bool wasCreated)
        {
            ConsoleProfile firstProfile = null;
            wasCreated = false;

            try
            {
                ConsoleProfilesManager profilesManager = device.XboxConsole.CreateConsoleProfilesManager();
                IEnumerable<ConsoleProfile> profiles = profilesManager.EnumerateConsoleProfiles();

                if (profiles.Any())
                {
                    profilesManager.SignOutAllUsers();
                    firstProfile = profiles.First();
                }
                else
                {
                    firstProfile = profilesManager.CreateConsoleProfile(true);
                    wasCreated = true;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    "There was an error getting a profile from console " + this.xboxDevice.Name + "\n\n" + e.Message,
                    "Certification Assistance Tool");
                throw;
            }

            return firstProfile;
        }
예제 #2
0
        /// <summary>
        /// Stop - called when the module is done or aborted
        /// </summary>
        public void Stop()
        {
            if (!this.moduleContext.IsModal)
            {
                return;
            }

            Mouse.OverrideCursor = Cursors.Wait;

            try
            {
                // sign-out users
                ConsoleProfilesManager profilesManager = this.xboxDevice.XboxConsole.CreateConsoleProfilesManager();
                profilesManager.SignOutAllUsers();

                // remove created profiles
                if (this.profile1IsNew)
                {
                    profilesManager.DeleteConsoleProfile(this.profile1);
                }

                if (this.profile2IsNew)
                {
                    profilesManager.DeleteConsoleProfile(this.profile2);
                }

                // stop game
                this.xboxDevice.LaunchDevDashboard();

                // restore multiplayer privilege to pre-existing profiles
                if (!this.profile1IsNew)
                {
                    if (MessageBoxResult.Yes == MessageBox.Show(
                        "Re-enable multiplayer capability for profile " + this.profile1.Gamertag + "?",
                        "Certification Assistance Tool",
                        MessageBoxButton.YesNo))
                    {
                        this.xboxDevice.RunIXBoxAutomationScript(@"Scripts\Enable_Xbox_Live_Game_Play_Privileges.xboxautomation");
                    }
                }

                this.moduleContext.Log("*************************************************************\r\n");
                this.moduleContext.Log("RESULT: " + this.passedOrFailed + "\r\n");
                this.moduleContext.Log("*************************************************************\r\n");
            }
            catch (Exception)
            {
            }

            Mouse.OverrideCursor = null;
        }
        public bool Setup1()
        {
            bool aborted        = false;
            bool friendingError = false;

            Mouse.OverrideCursor = Cursors.Wait;

            // assign xboxes
            foreach (IXboxDevice dev in this.moduleContext.SelectedDevices)
            {
                if (dev.IsDefault)
                {
                    xboxDevice1 = dev;
                }
            }

            foreach (IXboxDevice dev in this.moduleContext.SelectedDevices)
            {
                if (xboxDevice1 == null)
                {
                    xboxDevice1 = dev;
                    NotifyPropertyChanged("Console1Name");
                }
                else if (xboxDevice2 == null && xboxDevice1 != dev)
                {
                    xboxDevice2 = dev;
                    NotifyPropertyChanged("Console2Name");
                }
                else if (xboxDevice3 == null && xboxDevice1 != dev)
                {
                    xboxDevice3 = dev;
                    NotifyPropertyChanged("Console3Name");
                }
            }

            // get a profile manager for each console
            ReadyMessage  = "Getting three profiles...";
            SetupProgress = 5;
            UpdateSetup();

            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 or create and sign in a default profile on each console
            profileA = SafeGetDefaultProfile(profileManager1, 0);
            profileB = SafeGetDefaultProfile(profileManager2, 0);
            profileC = SafeGetDefaultProfile(profileManager3, 0);

            // make sure profiles are not the same one
            if (profileB.Gamertag == profileA.Gamertag)
            {
                profileB = SafeGetDefaultProfile(profileManager2, 1);
            }

            if (profileC.Gamertag == profileB.Gamertag || profileC.Gamertag == profileA.Gamertag)
            {
                profileC = SafeGetDefaultProfile(profileManager3, 1);
            }

            if (profileC.Gamertag == profileB.Gamertag || profileC.Gamertag == profileA.Gamertag)
            {
                profileC = SafeGetDefaultProfile(profileManager3, 2);
            }

            // set Play Through Speakers on all three consoles
            ReadyMessage   = "Setting voice output to speakers only...";
            SetupProgress += 15;
            UpdateSetup();

            Thread th1 = new Thread(new ParameterizedThreadStart(delegate
            {
                xboxDevice1.RunCatScript("Voice_Output_Set_Speakers");
                SetupProgress += 10;
            }));

            th1.Start();
            Thread th2 = new Thread(new ParameterizedThreadStart(delegate
            {
                xboxDevice2.RunCatScript("Voice_Output_Set_Speakers");
                SetupProgress += 10;
            }));

            th2.Start();
            Thread th3 = new Thread(new ParameterizedThreadStart(delegate
            {
                xboxDevice3.RunCatScript("Voice_Output_Set_Speakers");
                SetupProgress += 10;
            }));

            th3.Start();

            th1.Join();
            th2.Join();
            th3.Join();

            ReadyMessage = "Friending profiles...";
            UpdateSetup();

            try
            {
                // Friend profiles A and B
                if (!AreFriended(profileA, profileB))
                {
                    profileB.Friends.SendFriendRequest(profileA);
                    profileA.Friends.AcceptFriendRequest(profileB);
                }
                ProfileAFriended = "Friended";
                ProfileBFriended = "Friended";
                SetupProgress   += 10;
            }
            catch (Exception ex)
            {
                friendingError = true;
                moduleContext.Log("There was an exception friending profile " + ProfileAName + " with " + ProfileBName + ". Exception: " + ex.Message);
            }

            // enable communications for profiles B and c
            ReadyMessage = "Setting Communication Options...";
            UpdateSetup();
            th2 = new Thread(new ParameterizedThreadStart(delegate
            {
                xboxDevice2.RunCatScript("Communications_Set_Everyone");
                ProfileBCommunications = "Everyone";
                SetupProgress         += 10;
            }));
            th2.Start();
            th3 = new Thread(new ParameterizedThreadStart(delegate
            {
                xboxDevice3.RunCatScript("Communications_Set_Everyone");
                ProfileCCommunications = "Everyone";
                SetupProgress         += 10;
            }));
            th3.Start();

            // if friending failed, unblock profile A and friend again. then block profile A
            if (friendingError)
            {
                th1 = new Thread(new ParameterizedThreadStart(delegate
                {
                    xboxDevice1.RunCatScript("Communications_Set_Everyone");
                }));
                th1.Start();
                th2.Join();
                th1.Join();
                try
                {
                    // Friend profiles A and B
                    if (!AreFriended(profileA, profileB))
                    {
                        profileB.Friends.SendFriendRequest(profileB);
                        profileA.Friends.AcceptFriendRequest(profileA);
                    }
                    ProfileAFriended = "Friended";
                    ProfileBFriended = "Friended";
                    SetupProgress   += 10;
                }
                catch (Exception ex)
                {
                    moduleContext.Log("There was an exception friending profile " + ProfileAName + " with " + ProfileBName + ". Exception: " + ex.Message);
                    MessageBox.Show("Unable to friend profiles " + ProfileAName + " and " + ProfileBName + ". Aborting test", "Certificaton Assistance Tool");
                    ProfileAFriended = "Error Friending";
                    ProfileBFriended = "Error Friending";
                    ReadyMessage     = "Aborted";
                    aborted          = true;
                }
            }

            UpdateSetup();
            if (aborted)
            {
                return(false);
            }

            // block profile A
            th1 = new Thread(new ParameterizedThreadStart(delegate
            {
                xboxDevice1.RunCatScript("Communications_Set_Blocked");
                ProfileACommunications = "Blocked";
                SetupProgress         += 10;
            }));
            th1.Start();
            th2.Join();
            th3.Join();
            th1.Join();

            // Install and Launch the game on all three consoles
            ReadyMessage = "Installing and launching " + this.moduleContext.XboxTitle.Name + "...";
            UpdateSetup();
            if (xboxDevice1.IsTitleInstalled)
            {
                ProfileALaunched = "Launching...";
            }
            else
            {
                ProfileALaunched = "Installing...";
            }
            if (xboxDevice2.IsTitleInstalled)
            {
                ProfileBLaunched = "Launching...";
            }
            else
            {
                ProfileBLaunched = "Installing...";
            }
            if (xboxDevice3.IsTitleInstalled)
            {
                ProfileCLaunched = "Launching...";
            }
            else
            {
                ProfileCLaunched = "Installing...";
            }
            UpdateSetup();

            th1 = new Thread(new ParameterizedThreadStart(delegate
            {
                if (!xboxDevice1.IsTitleInstalled)
                {
                    xboxDevice1.InstallTitle(xboxDevice1.PreferredInstallDrive());
                }

                ProfileALaunched = "Launching...";
                xboxDevice1.LaunchTitle();
                ProfileALaunched = "Launched";
                SetupProgress   += 10;
            }));
            th1.Start();
            th2 = new Thread(new ParameterizedThreadStart(delegate
            {
                if (!xboxDevice2.IsTitleInstalled)
                {
                    xboxDevice2.InstallTitle(xboxDevice2.PreferredInstallDrive());
                }

                ProfileBLaunched = "Launching...";
                xboxDevice2.LaunchTitle();
                ProfileBLaunched = "Launched";
                SetupProgress   += 10;
            }));
            th2.Start();
            th3 = new Thread(new ParameterizedThreadStart(delegate
            {
                if (!xboxDevice3.IsTitleInstalled)
                {
                    xboxDevice3.InstallTitle(xboxDevice3.PreferredInstallDrive());
                }

                ProfileCLaunched = "Launching...";
                xboxDevice3.LaunchTitle();
                ProfileCLaunched = "Launched";
                SetupProgress   += 10;
            }));
            th3.Start();
            th1.Join();
            th2.Join();
            th3.Join();
            ReadyMessage = "Ready";
            Setup1Done   = true;
            LogSetup();
            UpdateSetup();
            Mouse.OverrideCursor = null;
            return(true);
        }
예제 #4
0
        /// <summary>
        /// install title to the consoles
        /// </summary>
        private void Setup()
        {
            System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

            ConsoleProfilesManager       profilesManager = this.xboxDevice.XboxConsole.CreateConsoleProfilesManager();
            IEnumerable <ConsoleProfile> profiles        = profilesManager.EnumerateConsoleProfiles();

            if (profiles.Count() == 0)
            {
                ConsoleProfile profile = profilesManager.CreateConsoleProfile(true);
                profile.SignIn(UserIndex.Zero);
            }
            else
            {
                profilesManager.SignOutAllUsers();
                ConsoleProfile firstProfile = profiles.First();
                firstProfile.SignIn(UserIndex.Zero);
            }

            System.Windows.Input.Mouse.OverrideCursor = null;

            if (this.xboxDevice.IsTitleInstalled)
            {
                MessageBoxResult messageBoxResult = MessageBox.Show("Launch " + this.moduleContext.XboxTitle.Name + "?", "Certification Assistance Tool", MessageBoxButton.YesNo);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    this.xboxDevice.LaunchTitle();
                }
            }
            else
            {
                if (this.xboxDevice.CanInstallTitle)
                {
                    MessageBoxResult messageBoxResult = MessageBox.Show("Install and launch " + this.moduleContext.XboxTitle.Name + "?", "Certification Assistance Tool", MessageBoxButton.YesNo);
                    if (messageBoxResult == MessageBoxResult.Yes)
                    {
                        this.xboxDevice.InstallTitle(this.GetBestAvailableDrive(this.xboxDevice), this.moduleContext.OpenProgressBarWindow("Installing " + this.moduleContext.XboxTitle.Name + "..."));
                        this.xboxDevice.LaunchTitle();
                    }
                }
            }

            this.xboxDevice.XboxConsole.XboxAutomation.BindController(0, 10);
            this.xboxDevice.XboxConsole.XboxAutomation.BindController(1, 10);
            this.xboxDevice.XboxConsole.XboxAutomation.BindController(2, 10);
            this.xboxDevice.XboxConsole.XboxAutomation.BindController(3, 10);
            this.controllersBound = true;

            this.xboxDevice.XboxConsole.XboxAutomation.ClearGamepadQueue(0);
            this.xboxDevice.XboxConsole.XboxAutomation.ClearGamepadQueue(1);
            this.xboxDevice.XboxConsole.XboxAutomation.ClearGamepadQueue(2);
            this.xboxDevice.XboxConsole.XboxAutomation.ClearGamepadQueue(3);

            this.xboxDevice.XboxConsole.XboxAutomation.ConnectController(0);
            this.xboxDevice.XboxConsole.XboxAutomation.ConnectController(1);
            this.xboxDevice.XboxConsole.XboxAutomation.ConnectController(2);
            this.xboxDevice.XboxConsole.XboxAutomation.ConnectController(3);

            this.Quadrant1Connected  = true;
            this.Quadrant2Connected  = true;
            this.Quadrant3Connected  = true;
            this.Quadrant4Connected  = true;
            this.Quadrant1Controlled = true;

            this.VirtualControllerVisibility = Visibility.Visible;
        }
        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();
        }