Exemplo n.º 1
0
        public ConsoleForm()
        {
            InitializeComponent();

            tbConsole.BackColor        = System.Drawing.SystemColors.Window;
            toolStripStatusLabel1.Text = ADBRunner.FindADB();
        }
Exemplo n.º 2
0
        private void RunCommandNew(string sCommand)
        {
            try
            {
                if (!consoleControl1.IsProcessRunning)
                {
                    consoleControl1.ClearOutput();
                    consoleControl1.Focus();
                    consoleControl1.StartProcess(ADBRunner.FindADB(), sCommand);
                }

                if (consoleControl1.IsProcessRunning)
                {
                    if (!consoleControl1.Focused)
                    {
                        consoleControl1.Focus();
                    }
                    tbCommand.Enabled = false;
                }
                else
                {
                    tbCommand.Enabled = true;
                    tbCommand.Focus();
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 3
0
        public PreferencesForm()
        {
            InitializeComponent();

            DeviseAddr addr = new DeviseAddr();

            if (addr.IsValid())
            {
                tbIP.Text   = addr.IP;
                tbPort.Text = addr.PORT;
            }

            if (!string.IsNullOrEmpty(addr.ADBPath))
            {
                tbADB.Text = addr.ADBPath;
            }
            else
            {
                tbADB.Text = ADBRunner.FindADB();
            }

            if (!string.IsNullOrEmpty(addr.ConnectionType))
            {
                rbUSB.Checked = addr.ConnectionType.Equals("usb");
            }

            cbDevices.Items.Clear();
            ADBCommand    commandDev = new ADBCommand();
            CommandResult retDev     = commandDev.Devices();

            if (retDev.IsSuccess)
            {
                foreach (var str in retDev.Message.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                {
                    if (!string.IsNullOrEmpty(str))
                    {
                        string[] s = str.Split(' ');
                        if (s.Any())
                        {
                            cbDevices.Items.Add(s[0]);
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(addr.UsbDevice))
            {
                if (cbDevices.Items.Contains(addr.UsbDevice))
                {
                    cbDevices.SelectedItem = addr.UsbDevice;
                }
            }
        }
Exemplo n.º 4
0
        private void RunCommand(string sCommand)
        {
            strMessage = string.Empty;
            Process build  = new Process();
            string  strADB = ADBRunner.FindADB();

            build.StartInfo.WorkingDirectory = Path.GetDirectoryName(strADB);
            build.StartInfo.FileName         = strADB;
            build.StartInfo.Arguments        = sCommand;

            build.StartInfo.UseShellExecute        = false;
            build.StartInfo.RedirectStandardOutput = true;
            //build.StandardInput.AutoFlush = true;
            build.StartInfo.RedirectStandardInput = true;
            build.StartInfo.RedirectStandardError = true;
            build.StartInfo.CreateNoWindow        = true;
            build.ErrorDataReceived  += build_ErrorDataReceived;
            build.OutputDataReceived += build_ErrorDataReceived;
            build.EnableRaisingEvents = true;
            build.Start();

            StreamWriter inputWriter = build.StandardInput;

            //StreamReader outputReader = build.StandardOutput;

            build.BeginOutputReadLine();
            build.BeginErrorReadLine();

            foreach (ProcessThread thread in build.Threads)
            {
                if (thread.ThreadState == ThreadState.Wait &&
                    thread.WaitReason == ThreadWaitReason.UserRequest)
                {
                    inputWriter.WriteLine("exit");
                    //build.StandardInput.Close();

                    /*
                     * string ss = outputReader.ReadToEnd();
                     * ss = Encoding.UTF8.GetString(Encoding.Default.GetBytes(ss));
                     * AppendText(ss, tbConsole.ForeColor, true);
                     */
                }
            }

            build.WaitForExit();
        }