コード例 #1
0
        /// <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);
        }
コード例 #2
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;
        }
コード例 #3
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;
        }
コード例 #4
0
        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();
        }