public void UpdateButtonStatus() { if (InvokeRequired) { BeginInvoke((Action)UpdateButtonStatus); return; } if (_test == null) { return; } comboBoxLanguage.Enabled = !_searching && !_test.ThreadActive; buttonSearch.Enabled = !_searching && !_test.ThreadActive && ((_cli != null) || !_wlanClient.NoWifiAvailable); buttonClose.Enabled = !_searching && !_test.ThreadActive; BluetoothDeviceInfo devInfo = GetSelectedBtDevice(); WlanInterface wlanIface = GetSelectedWifiDevice(); AccessPoint ap = GetSelectedAp(); buttonTest.Enabled = buttonSearch.Enabled && ((devInfo != null) || (wlanIface != null) || (ap != null)) && !_test.ThreadActive; bool allowPatch = buttonTest.Enabled && _test.TestOk && ((wlanIface != null) || (devInfo != null)); bool allowRestore = !_searching && !_test.ThreadActive; bool bmwValid = Patch.IsValid(_ediabasDirBmw); groupBoxEdiabas.Enabled = bmwValid; buttonPatchEdiabas.Enabled = bmwValid && allowPatch; buttonRestoreEdiabas.Enabled = bmwValid && allowRestore && Patch.IsPatched(_ediabasDirBmw); bool vagValid = Patch.IsValid(_ediabasDirVag); groupBoxVasPc.Enabled = vagValid; buttonPatchVasPc.Enabled = vagValid && allowPatch && (devInfo != null); buttonRestoreVasPc.Enabled = vagValid && allowRestore && Patch.IsPatched(_ediabasDirVag); bool istadValid = Patch.IsValid(_ediabasDirIstad); groupBoxIstad.Enabled = true; buttonDirIstad.Enabled = allowRestore; buttonPatchIstad.Enabled = istadValid && allowPatch; buttonRestoreIstad.Enabled = istadValid && allowRestore && Patch.IsPatched(_ediabasDirIstad); textBoxBluetoothPin.Enabled = !_test.ThreadActive; textBoxWifiPassword.Enabled = !_test.ThreadActive; if ((devInfo != null) || (wlanIface != null)) { if (_test.TestOk && _test.ConfigPossible) { buttonTest.Text = Resources.Strings.ButtonTestConfiguration; } else { buttonTest.Text = Resources.Strings.ButtonTestCheck; } } else if (ap != null) { buttonTest.Text = Resources.Strings.ButtonTestConnect; } else { buttonTest.Text = Resources.Strings.ButtonTestCheck; } }
private void GetDirectories() { string dirBmw = Environment.GetEnvironmentVariable("ediabas_config_dir"); if (!Patch.IsValid(dirBmw)) { string path = Environment.GetEnvironmentVariable("EDIABAS_PATH"); if (!string.IsNullOrEmpty(path)) { dirBmw = Path.Combine(path, @"bin"); } } if (!Patch.IsValid(dirBmw)) { string path = LocateFileInPath(Patch.ApiDllName); if (!string.IsNullOrEmpty(path)) { dirBmw = path; } } if (Patch.IsValid(dirBmw)) { _ediabasDirBmw = dirBmw; } try { using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Softing\EDIS-VW2")) { string path = key?.GetValue("EDIABASPath", null) as string; if (!string.IsNullOrEmpty(path)) { string dirVag = Path.Combine(path, @"bin"); if (Patch.IsValid(dirVag)) { _ediabasDirVag = dirVag; } } } if (string.IsNullOrEmpty(_ediabasDirVag)) { using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\SIDIS\ENV")) { string dirVag = key?.GetValue("FLASHINIPATH", null) as string; if (Patch.IsValid(dirVag)) { _ediabasDirVag = dirVag; } } } if (string.IsNullOrEmpty(_ediabasDirVag)) { using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Softing\VASEGD2")) { string dirVag = key?.GetValue("strEdiabasApi32Path", null) as string; if (Patch.IsValid(dirVag)) { _ediabasDirVag = dirVag; } } } } catch (Exception) { // ignored } try { _ediabasDirIstad = Properties.Settings.Default.IstadDir; } catch (Exception) { // ignored } }