|
9 | 9 | using System.ComponentModel; |
10 | 10 | using System.Linq; |
11 | 11 | using System.Threading.Tasks; |
12 | | -using System.Windows; |
13 | 12 | using System.Windows.Data; |
14 | 13 | using System.Windows.Input; |
15 | 14 | using Windows.Devices.WiFi; |
@@ -60,8 +59,8 @@ public WiFiAdapterInfo SelectedAdapter |
60 | 59 |
|
61 | 60 | if (value != null) |
62 | 61 | { |
63 | | - //if (!_isLoading) |
64 | | - // SettingsManager.Current.NetworkInterface_SelectedInterfaceId = value.Id; |
| 62 | + if (!_isLoading) |
| 63 | + SettingsManager.Current.WiFi_SelectedInterfaceId = value.NetworkInterfaceInfo.Id; |
65 | 64 |
|
66 | 65 | ScanNetworks(value.WiFiAdapter); |
67 | 66 | } |
@@ -135,56 +134,7 @@ public WiFiViewModel() |
135 | 134 | LoadAdapters(); |
136 | 135 |
|
137 | 136 | _isLoading = false; |
138 | | - } |
139 | | - |
140 | | - private ChartValues<double> GetDefaultChartValues(WiFi.Radio radio) |
141 | | - { |
142 | | - ChartValues<double> values = new ChartValues<double>(); |
143 | | - |
144 | | - for (int i = 0; i < (radio == WiFi.Radio.Radio1 ? Radio1Labels.Length : Radio2Labels.Length); i++) |
145 | | - values.Add(-1); |
146 | | - |
147 | | - return values; |
148 | | - } |
149 | | - |
150 | | - private ChartValues<double> SetChartValues(WiFiNetworkInfo network, WiFi.Radio radio, int index) |
151 | | - { |
152 | | - ChartValues<double> values = GetDefaultChartValues(radio); |
153 | | - |
154 | | - values[index - 2] = 0; |
155 | | - values[index - 1] = network.NetworkRssiInDecibelMilliwatts * -1; |
156 | | - values[index] = network.NetworkRssiInDecibelMilliwatts * -1; |
157 | | - values[index + 1] = network.NetworkRssiInDecibelMilliwatts * -1; |
158 | | - values[index + 2] = 0; |
159 | | - |
160 | | - return values; |
161 | | - } |
162 | | - |
163 | | - private void AddNetworkToRadio1Chart(WiFiNetworkInfo network) |
164 | | - { |
165 | | - int index = Array.IndexOf(Radio1Labels, $"{WiFi.GetChannelFromChannelFrequency(network.ChannelCenterFrequencyInKilohertz)}"); |
166 | | - |
167 | | - Radio1Series.Add(new LineSeries |
168 | | - { |
169 | | - Title = network.SSID, |
170 | | - Values = SetChartValues(network, WiFi.Radio.Radio1, index), |
171 | | - PointGeometry = null, |
172 | | - LineSmoothness = 0 |
173 | | - }); |
174 | | - } |
175 | | - |
176 | | - private void AddNetworkToRadio2Chart(WiFiNetworkInfo network) |
177 | | - { |
178 | | - int index = Array.IndexOf(Radio2Labels, $"{WiFi.GetChannelFromChannelFrequency(network.ChannelCenterFrequencyInKilohertz)}"); |
179 | | - |
180 | | - Radio2Series.Add(new LineSeries |
181 | | - { |
182 | | - Title = network.SSID, |
183 | | - Values = SetChartValues(network, WiFi.Radio.Radio2, index), |
184 | | - PointGeometry = null, |
185 | | - LineSmoothness = 0 |
186 | | - }); |
187 | | - } |
| 137 | + } |
188 | 138 |
|
189 | 139 | private void LoadSettings() |
190 | 140 | { |
@@ -224,7 +174,7 @@ private async void LoadAdapters() |
224 | 174 | // Get the last selected interface, if it is still available on this machine... |
225 | 175 | if (Adapters.Count > 0) |
226 | 176 | { |
227 | | - var info = Adapters.FirstOrDefault(s => s.NetworkInterfaceInfo.Id.ToString() == SettingsManager.Current.NetworkInterface_SelectedInterfaceId); |
| 177 | + var info = Adapters.FirstOrDefault(s => s.NetworkInterfaceInfo.Id.ToString() == SettingsManager.Current.WiFi_SelectedInterfaceId); |
228 | 178 |
|
229 | 179 | SelectedAdapter = info ?? Adapters[0]; |
230 | 180 | } |
@@ -278,6 +228,55 @@ private async void ScanNetworks(WiFiAdapter adapter) |
278 | 228 | IsNetworksLoading = false; |
279 | 229 | } |
280 | 230 |
|
| 231 | + private ChartValues<double> GetDefaultChartValues(WiFi.Radio radio) |
| 232 | + { |
| 233 | + ChartValues<double> values = new ChartValues<double>(); |
| 234 | + |
| 235 | + for (int i = 0; i < (radio == WiFi.Radio.Radio1 ? Radio1Labels.Length : Radio2Labels.Length); i++) |
| 236 | + values.Add(-1); |
| 237 | + |
| 238 | + return values; |
| 239 | + } |
| 240 | + |
| 241 | + private ChartValues<double> SetChartValues(WiFiNetworkInfo network, WiFi.Radio radio, int index) |
| 242 | + { |
| 243 | + ChartValues<double> values = GetDefaultChartValues(radio); |
| 244 | + |
| 245 | + values[index - 2] = 0; |
| 246 | + values[index - 1] = network.NetworkRssiInDecibelMilliwatts * -1; |
| 247 | + values[index] = network.NetworkRssiInDecibelMilliwatts * -1; |
| 248 | + values[index + 1] = network.NetworkRssiInDecibelMilliwatts * -1; |
| 249 | + values[index + 2] = 0; |
| 250 | + |
| 251 | + return values; |
| 252 | + } |
| 253 | + |
| 254 | + private void AddNetworkToRadio1Chart(WiFiNetworkInfo network) |
| 255 | + { |
| 256 | + int index = Array.IndexOf(Radio1Labels, $"{WiFi.GetChannelFromChannelFrequency(network.ChannelCenterFrequencyInKilohertz)}"); |
| 257 | + |
| 258 | + Radio1Series.Add(new LineSeries |
| 259 | + { |
| 260 | + Title = network.SSID, |
| 261 | + Values = SetChartValues(network, WiFi.Radio.Radio1, index), |
| 262 | + PointGeometry = null, |
| 263 | + LineSmoothness = 0 |
| 264 | + }); |
| 265 | + } |
| 266 | + |
| 267 | + private void AddNetworkToRadio2Chart(WiFiNetworkInfo network) |
| 268 | + { |
| 269 | + int index = Array.IndexOf(Radio2Labels, $"{WiFi.GetChannelFromChannelFrequency(network.ChannelCenterFrequencyInKilohertz)}"); |
| 270 | + |
| 271 | + Radio2Series.Add(new LineSeries |
| 272 | + { |
| 273 | + Title = network.SSID, |
| 274 | + Values = SetChartValues(network, WiFi.Radio.Radio2, index), |
| 275 | + PointGeometry = null, |
| 276 | + LineSmoothness = 0 |
| 277 | + }); |
| 278 | + } |
| 279 | + |
281 | 280 | public void OnViewVisible() |
282 | 281 | { |
283 | 282 |
|
|
0 commit comments