|
@@ -21,6 +21,7 @@ public partial class MainWindow : Window
|
|
|
private bool _configValidated;
|
|
private bool _configValidated;
|
|
|
private bool _suppressConfigChangeHandling;
|
|
private bool _suppressConfigChangeHandling;
|
|
|
private bool _isShowingPassword;
|
|
private bool _isShowingPassword;
|
|
|
|
|
+ private bool _isBusy;
|
|
|
private bool _suppressPasswordSync;
|
|
private bool _suppressPasswordSync;
|
|
|
|
|
|
|
|
public MainWindow()
|
|
public MainWindow()
|
|
@@ -49,18 +50,6 @@ public partial class MainWindow : Window
|
|
|
AdapterComboBox.ItemsSource = _adapters;
|
|
AdapterComboBox.ItemsSource = _adapters;
|
|
|
|
|
|
|
|
var recommendedAdapter = _networkAdapterService.GetRecommendedAdapter(_adapters);
|
|
var recommendedAdapter = _networkAdapterService.GetRecommendedAdapter(_adapters);
|
|
|
- if (recommendedAdapter is not null)
|
|
|
|
|
- {
|
|
|
|
|
- RecommendedAdapterTextBlock.Text = $"{recommendedAdapter.Name} ({recommendedAdapter.RecommendationLabel})";
|
|
|
|
|
- RecommendedReasonTextBlock.Text = recommendedAdapter.RecommendationReason;
|
|
|
|
|
- ProbeReasonTextBlock.Text = recommendedAdapter.ProbeReason;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- RecommendedAdapterTextBlock.Text = "未检测到可用有线网卡";
|
|
|
|
|
- RecommendedReasonTextBlock.Text = "请确认本机是否存在可用的以太网适配器。";
|
|
|
|
|
- ProbeReasonTextBlock.Text = "当前没有可探测的网卡。";
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
var savedPassword = _passwordStoreService.LoadPassword();
|
|
var savedPassword = _passwordStoreService.LoadPassword();
|
|
|
if (!string.IsNullOrWhiteSpace(savedPassword))
|
|
if (!string.IsNullOrWhiteSpace(savedPassword))
|
|
@@ -149,6 +138,26 @@ public partial class MainWindow : Window
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private async void RefreshAdaptersButton_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
+ {
|
|
|
|
|
+ var selectedAdapterId = (AdapterComboBox.SelectedItem as AdapterInfo)?.Id;
|
|
|
|
|
+ SetBusyState(true);
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ await RefreshAdaptersAsync(selectedAdapterId);
|
|
|
|
|
+ SetStatus("已刷新本机网卡和管理口探测结果。", true);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ SetStatus($"刷新本机网卡失败:{ex.Message}", true);
|
|
|
|
|
+ MessageBox.Show(this, ex.Message, "刷新失败", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
|
|
+ }
|
|
|
|
|
+ finally
|
|
|
|
|
+ {
|
|
|
|
|
+ SetBusyState(false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private async void DiscoverConnectButton_OnClick(object sender, RoutedEventArgs e)
|
|
private async void DiscoverConnectButton_OnClick(object sender, RoutedEventArgs e)
|
|
|
{
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(GetCurrentPassword()))
|
|
if (string.IsNullOrWhiteSpace(GetCurrentPassword()))
|
|
@@ -161,7 +170,6 @@ public partial class MainWindow : Window
|
|
|
PersistPasswordIfNeeded();
|
|
PersistPasswordIfNeeded();
|
|
|
SetBusyState(true);
|
|
SetBusyState(true);
|
|
|
SetStatus("正在检查当前网卡是否可直接访问管理口。", true);
|
|
SetStatus("正在检查当前网卡是否可直接访问管理口。", true);
|
|
|
- DiscoveredDeviceTextBlock.Text = "尚未发现设备。";
|
|
|
|
|
await Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.Render);
|
|
await Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.Render);
|
|
|
|
|
|
|
|
try
|
|
try
|
|
@@ -173,7 +181,6 @@ public partial class MainWindow : Window
|
|
|
{
|
|
{
|
|
|
_connectedBaseAddress = "http://169.254.100.2:48888";
|
|
_connectedBaseAddress = "http://169.254.100.2:48888";
|
|
|
_connectedLocalIPv4 = adapter.IPv4Address;
|
|
_connectedLocalIPv4 = adapter.IPv4Address;
|
|
|
- DiscoveredDeviceTextBlock.Text = $"已直接访问管理口:169.254.100.2 / {adapter.Name}";
|
|
|
|
|
SetStatus("连接成功,无需切换本机网卡。", true);
|
|
SetStatus("连接成功,无需切换本机网卡。", true);
|
|
|
OpenDeviceDetailsWindow(_connectedBaseAddress, _connectedLocalIPv4);
|
|
OpenDeviceDetailsWindow(_connectedBaseAddress, _connectedLocalIPv4);
|
|
|
return;
|
|
return;
|
|
@@ -205,7 +212,6 @@ public partial class MainWindow : Window
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- DiscoveredDeviceTextBlock.Text = $"已发现设备:{device.Hostname} / {device.Lan2Ip} / Agent {device.AgentVersion}";
|
|
|
|
|
SetStatus("已发现设备,正在验证连接。", true);
|
|
SetStatus("已发现设备,正在验证连接。", true);
|
|
|
|
|
|
|
|
var discoveredResult = await _agentApiService.CheckHealthAsync($"http://{device.Lan2Ip}:48888", GetCurrentPassword(), selectedAdapter?.IPv4Address ?? string.Empty);
|
|
var discoveredResult = await _agentApiService.CheckHealthAsync($"http://{device.Lan2Ip}:48888", GetCurrentPassword(), selectedAdapter?.IPv4Address ?? string.Empty);
|
|
@@ -252,8 +258,9 @@ public partial class MainWindow : Window
|
|
|
{
|
|
{
|
|
|
var adapter = AdapterComboBox.SelectedItem as AdapterInfo;
|
|
var adapter = AdapterComboBox.SelectedItem as AdapterInfo;
|
|
|
var hasAdapter = adapter is not null;
|
|
var hasAdapter = adapter is not null;
|
|
|
- SwitchMaintenanceButton.IsEnabled = hasAdapter;
|
|
|
|
|
- DiscoverConnectButton.IsEnabled = hasAdapter && adapter!.HasLink;
|
|
|
|
|
|
|
+ RefreshAdaptersButton.IsEnabled = !_isBusy;
|
|
|
|
|
+ SwitchMaintenanceButton.IsEnabled = !_isBusy && hasAdapter;
|
|
|
|
|
+ DiscoverConnectButton.IsEnabled = !_isBusy && hasAdapter && adapter!.HasLink;
|
|
|
ReloadInterfaceConfigButton.IsEnabled = RemoteTargetInterfaceComboBox.SelectedItem is RemoteInterfaceInfo;
|
|
ReloadInterfaceConfigButton.IsEnabled = RemoteTargetInterfaceComboBox.SelectedItem is RemoteInterfaceInfo;
|
|
|
ValidateConfigButton.IsEnabled = RemoteTargetInterfaceComboBox.SelectedItem is RemoteInterfaceInfo;
|
|
ValidateConfigButton.IsEnabled = RemoteTargetInterfaceComboBox.SelectedItem is RemoteInterfaceInfo;
|
|
|
ApplyConfigButton.IsEnabled = _configValidated && RemoteTargetInterfaceComboBox.SelectedItem is RemoteInterfaceInfo;
|
|
ApplyConfigButton.IsEnabled = _configValidated && RemoteTargetInterfaceComboBox.SelectedItem is RemoteInterfaceInfo;
|
|
@@ -277,9 +284,6 @@ public partial class MainWindow : Window
|
|
|
{
|
|
{
|
|
|
AdapterComboBox.SelectedItem = selected;
|
|
AdapterComboBox.SelectedItem = selected;
|
|
|
UpdateAdapterDetails(selected);
|
|
UpdateAdapterDetails(selected);
|
|
|
- RecommendedAdapterTextBlock.Text = $"{selected.Name} ({selected.RecommendationLabel})";
|
|
|
|
|
- RecommendedReasonTextBlock.Text = selected.RecommendationReason;
|
|
|
|
|
- ProbeReasonTextBlock.Text = selected.ProbeReason;
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -645,7 +649,9 @@ public partial class MainWindow : Window
|
|
|
|
|
|
|
|
private void SetBusyState(bool isBusy)
|
|
private void SetBusyState(bool isBusy)
|
|
|
{
|
|
{
|
|
|
|
|
+ _isBusy = isBusy;
|
|
|
AdapterComboBox.IsEnabled = !isBusy;
|
|
AdapterComboBox.IsEnabled = !isBusy;
|
|
|
|
|
+ RefreshAdaptersButton.IsEnabled = !isBusy;
|
|
|
PasswordBox.IsEnabled = !isBusy;
|
|
PasswordBox.IsEnabled = !isBusy;
|
|
|
PasswordTextBox.IsEnabled = !isBusy;
|
|
PasswordTextBox.IsEnabled = !isBusy;
|
|
|
TogglePasswordVisibilityButton.IsEnabled = !isBusy;
|
|
TogglePasswordVisibilityButton.IsEnabled = !isBusy;
|