Пример #1
0
        public RemoteHaloMapViewModel()
        {
            var xboxes = NameAnsweringProtocol.Discover(10);

            if (xboxes.Any())
            {
                Xbox = xboxes.First();
                Xbox.ConnectionStateChanged += Xbox_ConnectionStateChanged;
                Xbox.Connect();
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            //Welcome
            WriteHeader();
            xboxes = NameAnsweringProtocol.Discover(10);

            //Application loop
#if DEBUG
            Test();
#endif
            Application();
        }
Пример #3
0
        private static void Test()
        {
            Xbox xbox = NameAnsweringProtocol.Discover(15).FirstOrDefault();

            if (xbox != null)
            {
                xbox.Connect();
                if (xbox.Connected)
                {
                    if (xbox.Screenshot(out var screenshot))
                    {
                        screenshot.Save(@"F:\screenshot.png", System.Drawing.Imaging.ImageFormat.Png);
                    }
                }
            }
        }
Пример #4
0
        private MemoryStream GetFileContents(ItemObject[] items, int index)
        {
            //Prepare
            MemoryStream ms = null;

            //Check
            if (items != null && index < items.Length)
            {
                //Prepare
                ms = new MemoryStream();
                ItemObject item = items[index];

                //Setup
                byte[] buffer = new byte[item.Size];

                //Find xbox
                Xbox xbox = NameAnsweringProtocol.Discover(xboxAddress);
                try
                {
                    //Connect
                    xbox.Connect();

                    //Download
                    if (!xbox.GetData(Path.Combine(item.Directory, item.Name), ref buffer))
                    {
                        buffer = new byte[1];
                    }

                    //Disconnect
                    xbox.Disconnect();
                }
                catch { buffer = new byte[1]; }

                //Check
                if (buffer.Length == 0)
                {
                    buffer = new byte[1];
                }
                ms.Write(buffer, 0, buffer.Length);
            }

            //Return
            return(ms);
        }
Пример #5
0
        private static void HandleCommand(params string[] cmd)
        {
            string command = cmd.First();

            string[] args = cmd.Where((s, i) => i > 0).ToArray();

            switch (command.ToUpper())
            {
            case "CONNECT":
                //Check for current Xbox
                if (currentXbox == null)
                {
                    Console.WriteLine("There is no Xbox specified.");
                    Console.Write("Please select an Xbox and try again.");
                    break;
                }

                //Connect
                currentXbox.Response += CurrentXbox_Response;
                EnterRDCP(currentXbox);
                currentXbox.Response -= CurrentXbox_Response;
                break;

            case "SELECT":
                switch ((args.FirstOrDefault() ?? string.Empty).ToUpper())
                {
                case "XBOX":
                    SelectXbox(args.Where((s, i) => i > 0).ToArray());
                    break;

                default:
                    WriteHeader();
                    Console.WriteLine("XBOX\t- Shift the focus to a debug Xbox. For example SELECT XBOX.");
                    break;
                }
                break;

            case "REFRESH":
                xboxes = NameAnsweringProtocol.Discover();
                break;

            case "LIST":
                switch ((args.FirstOrDefault() ?? string.Empty).ToUpper())
                {
                case "XBOX":
                    ListXbox();
                    break;

                default:
                    WriteHeader();
                    Console.WriteLine("XBOX\t- Display a list of debug Xbox consoles. For example LIST XBOX.");
                    break;
                }
                break;

            default:
                WriteHeader();
                Console.WriteLine("LIST\t- Display a list of objects.");
                Console.WriteLine("REFRESH\t- Discover all debug Xbox consoles on the network.");
                Console.WriteLine("SELECT\t- Shift the focus to an object.");
                Console.WriteLine("CONNECT\t- Connects to the selected Xbox");
                Console.WriteLine("EXIT\t- Exit application.");
                break;
            }

            //Write Line
            Console.WriteLine();
        }