GetDevices() public method

public GetDevices ( ) : List
return List
Ejemplo n.º 1
0
        public frmSend(string filename)
        {
            InitializeComponent();
            _filename = filename;
            server    = new SharpAdbClient.AdbServer();
            var adbPath = @"C:\android - sdk\platform - tools\adb.exe";
            StartServerResult result;

            if (!System.IO.File.Exists(adbPath))
            {
                adbPath = @"C:\ProgramData\Microsoft\AndroidSDK\25\platform-tools\adb.exe";
            }
            if (!System.IO.File.Exists(adbPath))
            {
                MessageBox.Show("Unable to find adb.exe", "Error");
                return;
            }
            result = server.StartServer(adbPath, restartServerIfNewer: false);
            client = new SharpAdbClient.AdbClient();
            List <SharpAdbClient.DeviceData> devices = client.GetDevices();

            foreach (SharpAdbClient.DeviceData device in devices)
            {
                cboListDevices.Items.Add(device);
            }
            if (cboListDevices.Items.Count > 0)
            {
                cboListDevices.SelectedIndex = 0;
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            RestoreConfig();
            SetScrPath();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var menu = new ContextMenu();

            menu.Popup += (sender, args) =>
            {
                var client  = new SharpAdbClient.AdbClient();
                var devices = client.GetDevices();

                menu.MenuItems.Clear();

                menu.MenuItems.Add(new MenuItem("Set srccpy path", (o, eventArgs) => { ChooseScrPath(); }));

                if (CanViewDevices())
                {
                    var viewMenu = devices.Select(device =>
                                                  new MenuItem(device.Model, (o, eventArgs) => { ViewDevice(device); }))
                                   .ToArray();

                    menu.MenuItems.Add(new MenuItem("View", viewMenu));
                }

                var restartMenu = devices.Select(device => new MenuItem(device.Model,
                                                                        (o, eventArgs) => { RestartAction(client, device); })).ToArray();

                menu.MenuItems.Add(new MenuItem("Restart", restartMenu));

                menu.MenuItems.Add(new MenuItem("Exit", (o, eventArgs) => { Application.Exit(); }));
            };
            // Show the system tray icon.
            using (var pi = new ProcessIcon(menu))
            {
                pi.Display();

                // Make sure the application runs!
                Application.Run();
            }
        }