Ejemplo n.º 1
0
        private static void Run(EyeXHost eyeXHost)
        {
            Console.CursorVisible = false;
            Console.WriteLine("AVAILABLE EYEX PROFILES");
            Console.WriteLine("=======================");
            Console.WriteLine();

            // Start the EyeX host.
            Version engineVersion;

            if (!StartHost(eyeXHost, out engineVersion))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Could not connect to EyeX Engine.");
                return;
            }

            // Too old EyeX Engine installed?
            if (engineVersion.Major != 1 || engineVersion.Major == 1 && engineVersion.Minor < 4)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("This sample requires EyeX Engine 1.4.");
                return;
            }

            // Create key bindings from the profiles.
            var keyBindings = CreateKeyBindings(eyeXHost.UserProfiles);

            foreach (var keyBinding in keyBindings)
            {
                Console.WriteLine("[{0}] {1}", keyBinding.Key, keyBinding.Value);
            }

            Console.WriteLine();
            Console.WriteLine("Select a profile to set it as the current one.");
            Console.WriteLine("Press ESC to abort.");

            // Read input from the user.
            var result = Console.ReadKey(true);

            if (result.Key != ConsoleKey.Escape)
            {
                if (keyBindings.ContainsKey(result.Key))
                {
                    // Change the profile.
                    var profile = keyBindings[result.Key];
                    eyeXHost.SetCurrentUserProfile(profile);
                }
            }
        }