diff --git a/ATA-GUI/Forms/MainForm.cs b/ATA-GUI/Forms/MainForm.cs index e79859b..8d098c0 100644 --- a/ATA-GUI/Forms/MainForm.cs +++ b/ATA-GUI/Forms/MainForm.cs @@ -340,7 +340,7 @@ private void ExtractDeviceData() buttonSetRotation.Text = ATA.CurrentDeviceSelected.IsRotationFreeEnabled ? "Unset" : "Set"; LogWriteLine("device info extracted", LogType.OK); - disableEnableSystem(true); + disableSystem(false); }); } else @@ -374,7 +374,7 @@ private void ExtractDeviceData() Invoke(delegate { - disableEnableSystem(false); + disableSystem(true); buttonDisconnectIP.Enabled = false; LogWriteLine("failed to extract device info!", LogType.ERROR); MessageShowBox("Failed to extract device info\nError message: " + errorMessage, 0); @@ -511,18 +511,6 @@ private void sortApks(string[] arrayApkTmp) ATA.CurrentDeviceSelected.AppsString.Sort(); } - private void disableEnableSystem(bool enable) - { - textBoxPort.Enabled = !enable; - buttonMobileScreenShare.Enabled = enable; - groupBoxDeviceInfo.Enabled = enable; - groupBoxRebootMenu.Enabled = enable; - groupBoxAPKMenu.Enabled = enable; - buttonDeviceLogs.Enabled = enable; - buttonTaskManager.Enabled = enable; - tabPageTools.Enabled = enable; - } - private void textboxClick(object sender, EventArgs e) { if (textBoxSearch.Text == "Search" && !ata.TextboxClear) @@ -712,7 +700,7 @@ private async Task DeviceListExtractor(bool isAdb) switch (ata.Devices.Count) { case 0: - disableEnableSystem(false); + disableSystem(true); panelFastboot.Enabled = false; panelRecovery.Enabled = false; LogWriteLine("no devices detected. If this problem continues, ensure that USB debugging is enabled on your device. Additionally, verify that the correct drivers are installed; you can find the necessary links under Help -> OEM Drivers. For detailed instructions on enabling USB debugging and more information, please refer to this video tutorial: https://www.youtube.com/watch?v=W7nkxS9LMXs.", LogType.ERROR); @@ -744,6 +732,7 @@ public static bool pingCheck() reply = myPing.Send(IPAddress.Parse("1.1.1.1"), 1000, new byte[32], new PingOptions()); if (reply.Status == IPStatus.Success) { + return true; } } @@ -754,6 +743,11 @@ public static bool pingCheck() return false; } + public void updateOnlineStatus() + { + ata.IsConnected = pingCheck(); + } + private void MainForm_Shown(object sender, EventArgs e) { if (FeedbackForm.checkFeedbackFile()) @@ -777,7 +771,7 @@ private void MainForm_Shown(object sender, EventArgs e) private void DataLoadingUI() { - ata.IsConnected = pingCheck(); + updateOnlineStatus(); if (ata.IsConnected) { @@ -972,6 +966,8 @@ private async Task AdbFastbootExist(bool isAdb) } else { + updateOnlineStatus(); + await ADBDownload(false); ATA.ADBPath = ATA.FindExecutable(ata.FILEADB); ATA.FASTBOOTPath = ATA.FindExecutable(ata.FILEFastboot); @@ -1187,7 +1183,7 @@ private void comboBoxDevices_SelectedIndexChanged(object sender, EventArgs e) { ATA.CurrentDeviceSelected = ata.Devices[comboBoxDevices.SelectedIndex]; - disableEnableSystem(false); + disableSystem(true); panelFastboot.Enabled = false; panelRecovery.Enabled = false; } @@ -1219,7 +1215,7 @@ private void tabControl1_Selected(object sender, TabControlEventArgs e) buttonDeviceLogs.Enabled = false; buttonTaskManager.Enabled = false; buttonMobileScreenShare.Enabled = false; - disableEnableSystem(false); + disableSystem(true); } if (ata.CurrentTab != Tab.SYSTEM) @@ -1240,7 +1236,7 @@ public async Task ADBDownload(bool isUpdate) } Invoke(delegate { - disableEnableSystem(false); + disableSystem(true); buttonDisconnectIP.Enabled = false; }); @@ -1324,8 +1320,14 @@ private void disableSystem(bool a) { Invoke(delegate { - tabPageSystem.Enabled = !a; + textBoxPort.Enabled = a; buttonMobileScreenShare.Enabled = !a; + groupBoxDeviceInfo.Enabled = !a; + groupBoxRebootMenu.Enabled = !a; + groupBoxAPKMenu.Enabled = !a; + tabPageTools.Enabled = !a; + buttonDeviceLogs.Enabled = !a; + buttonTaskManager.Enabled = !a; }); } @@ -1380,6 +1382,8 @@ private void buttonMobileScreenShare_Click(object sender, EventArgs e) } else { + updateOnlineStatus(); + try { backgroundWorkerExeDownloader.RunWorkerAsync(); @@ -1473,6 +1477,8 @@ private async void labelSettings_Click(object sender, EventArgs e) if (dialogResult == DialogResult.Yes) { + updateOnlineStatus(); + _ = await ADBDownload(true); } }