示例#1
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_DEVICECHANGE)
            {
                switch (m.WParam.ToInt32())
                {
                case DBT_DEVICEARRIVAL:
                    if (Marshal.ReadInt32(m.LParam, 4) == DBT_DEVTYP_PORT)
                    {
                        Console.WriteLine(new String('-', CONSOLE_DIVIDER));
                        Console.WriteLine(Resources.OUTPUT_DEVICE_ADDED);
                        RunDelayed(() => { Refresh.PerformClick(); }, 2 * 1000);
                    }
                    break;

                case DBT_DEVICEREMOVECOMPLETE:
                    if (Marshal.ReadInt32(m.LParam, 4) == DBT_DEVTYP_PORT)
                    {
                        Console.WriteLine(new String('-', CONSOLE_DIVIDER));
                        Console.WriteLine(Resources.OUTPUT_DEVICE_REMOVED);
                        RunDelayed(() => { Refresh.PerformClick(); }, 1 * 1000);
                    }
                    break;
                }
            }
            base.WndProc(ref m);
        }
示例#2
0
        private void OnConnectClick(object sender, EventArgs e)
        {
            var       urn = ConnectBox.Text;
            IPAddress ip;

            Console.WriteLine(new String('-', CONSOLE_DIVIDER));
            if (IPAddress.TryParse(urn.TrimEnd(':', '5'), out ip))
            {
                Console.WriteLine(Resources.OUTPUT_CONNECTION_ATTEMPT, urn);
                RunInBackground((a, b) =>
                {
                    Worker.ReportProgress(1);
                    b.Result = Adb.Connect(urn);
                    Worker.ReportProgress(100);
                },
                                (a, b) =>
                {
                    if ((bool)b.Result)
                    {
                        Console.WriteLine(Resources.OUTPUT_CONNECTION_SUCCESS, urn);
                        RunDelayed(() => { Refresh.PerformClick(); }, 2 * 1000);
                    }
                    else
                    {
                        Console.WriteLine(Resources.OUTPUT_CONNECTION_FAILED, urn);
                    }
                });
            }
            else
            {
                Console.WriteLine(Resources.OUTPUT_CONNECTION_INVALID_IP);
            }
        }
示例#3
0
        private void AddData_Click(object sender, EventArgs e)        // Run Program
        {
            if (Algoritm.SelectedItem == Algoritm.Items[0])
            {
                DatabaseScript.AddData();
                ValueView();
                foreach (DatabaseScript.Mahasiswa mhs in DatabaseScript.mahasiswa)
                {
                    DatabaseScript.AddToDatabase(mhs);
                }

                Refresh.PerformClick();
            }
            else
            {
                DatabaseScript.AddData();
                int          error  = 0;
                DialogResult dialog = MessageBox.Show("Add now to databases?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dialog == DialogResult.Yes)
                {
                    DatabaseScript.AddData();

                    foreach (DatabaseScript.Mahasiswa mhs in DatabaseScript.mahasiswa)
                    {
                        if (mhs.diterima == "-" || mhs.diterima == null)
                        {
                            error += 1;
                        }
                    }

                    if (error > 0)
                    {
                        DialogResult result = MessageBox.Show("We Find " + error + " data that dont have result, we will ignore it do you want to Process?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (result == System.Windows.Forms.DialogResult.Yes)
                        {
                            foreach (DatabaseScript.Mahasiswa mhs in DatabaseScript.mahasiswa)
                            {
                                if (mhs.diterima != "-" && mhs.diterima != null)
                                {
                                    DatabaseScript.AddToDatabase(mhs);
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (DatabaseScript.Mahasiswa mhs in DatabaseScript.mahasiswa)
                        {
                            DatabaseScript.AddToDatabase(mhs);
                        }
                    }



                    Refresh.PerformClick();
                    ValueView();
                }
            }
        }
示例#4
0
 private void OnStartClick(object sender, EventArgs e)
 {
     Console.WriteLine(new String('-', CONSOLE_DIVIDER));
     Console.WriteLine(Resources.OUTPUT_STARTING_ADB);
     RunInBackground((a, b) =>
     {
         Worker.ReportProgress(1);
         b.Result = Adb.Start();
         Worker.ReportProgress(100);
     },
                     (a, b) =>
     {
         if ((bool)b.Result)
         {
             RunDelayed(() => { Refresh.PerformClick(); }, 2 * 1000);
         }
     });
 }
示例#5
0
 private void OnDashboardLoad(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(Adb.Exe))
     {
         MessageBox.Show(Resources.ADB_NOT_FOUND_MESSAGE, Resources.ADB_NOT_FOUND_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         Close();
     }
     else
     {
         DEV_BROADCAST_HDR dbi = new DEV_BROADCAST_HDR
         {
             ClassGuid  = CLASS_GUID,
             DeviceType = DBT_DEVTYP_PORT,
             Reserved   = 0,
             Name       = 0
         };
         dbi.Size = Marshal.SizeOf(dbi);
         IntPtr buffer = Marshal.AllocHGlobal(dbi.Size);
         Marshal.StructureToPtr(dbi, buffer, true);
         hNotification = RegisterDeviceNotification(Handle, buffer, 0);
         Console.SetOut(new Writer(OutputText));
         OutputText.TextChanged += (a, b) =>
         {
             OutputText.SelectionStart = OutputText.Text.Length;
             OutputText.ScrollToCaret();
         };
         Profile.Click      += (a, b) => { Process.Start("http://forum.xda-developers.com/member.php?u=5490832"); };
         Profile.MouseEnter += (a, b) =>
         {
             Profile.Cursor    = Cursors.Hand;
             Profile.ForeColor = Color.MidnightBlue;
         };
         Profile.MouseLeave += (a, b) =>
         {
             Profile.Cursor    = Cursors.Default;
             Profile.ForeColor = Color.RoyalBlue;
         };
         RebootBox.Items.Add(new RebootItem
         {
             Text  = Resources.REBOOT_BOOTLOADER,
             Value = "bootloader"
         });
         RebootBox.Items.Add(new RebootItem
         {
             Text  = Resources.REBOOT_DOWNLOAD,
             Value = "download"
         });
         RebootBox.Items.Add(new RebootItem
         {
             Text  = Resources.REBOOT_RECOVERY,
             Value = "recovery"
         });
         RebootBox.Items.Add(new RebootItem
         {
             Text  = Resources.REBOOT_SYSTEM,
             Value = "system"
         });
         RebootBox.SelectedIndex = RebootBox.Items.Count - 1;
         Rooted.Text             = string.Format(Resources.ROOT_STATUS, "Unknown");
         Website.Click          += (a, b) => { Process.Start("http://www.vaibhavpandey.com"); };
         Website.MouseEnter     += (a, b) =>
         {
             Website.Cursor    = Cursors.Hand;
             Website.ForeColor = Color.MidnightBlue;
         };
         Website.MouseLeave += (a, b) =>
         {
             Website.Cursor    = Cursors.Default;
             Website.ForeColor = Color.RoyalBlue;
         };
         SendMessage(DevicesBox.Handle, COMBOBOX_SETIH, -1, 24);
         SendMessage(RebootBox.Handle, COMBOBOX_SETIH, -1, 24);
         ResizeTextBox(ConnectBox, 22);
         Console.WriteLine(Resources.OUTPUT_CHECKING_VERSION);
         RunInBackground((a, b) =>
         {
             Worker.ReportProgress(1);
             b.Result = Adb.Version();
             Worker.ReportProgress(100);
         },
                         (a, b) =>
         {
             Version v;
             if ((v = (Version)b.Result) != null)
             {
                 Console.WriteLine(Resources.OUTPUT_VERSION_FOUND, v);
                 Version.Text = v.ToString();
                 Refresh.PerformClick();
             }
             else
             {
                 Console.WriteLine(Resources.OUTPUT_VERSION_NOT_FOUND, v);
             }
         });
     }
 }