Skip to content

Commit 8f9870f

Browse files
committed
Strings added, chart legend added, refactor, settings etc.
1 parent 783c6ee commit 8f9870f

6 files changed

Lines changed: 125 additions & 61 deletions

File tree

‎Source/NETworkManager/Models/Settings/SettingsInfo.cs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,23 @@ public double NetworkInterface_ProfileWidth
557557
}
558558
#endregion
559559

560+
#region WiFi
561+
private string _wiFi_SelectedInterfaceId;
562+
public string WiFi_SelectedInterfaceId
563+
{
564+
get => _wiFi_SelectedInterfaceId;
565+
set
566+
{
567+
if (value == _wiFi_SelectedInterfaceId)
568+
return;
569+
570+
_wiFi_SelectedInterfaceId = value;
571+
OnPropertyChanged();
572+
SettingsChanged = true;
573+
}
574+
}
575+
#endregion
576+
560577
#region IPScanner
561578
private bool _ipScanner_ShowScanResultForAllIPAddresses;
562579
public bool IPScanner_ShowScanResultForAllIPAddresses

‎Source/NETworkManager/Resources/Localization/Strings.Designer.cs‎

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Source/NETworkManager/Resources/Localization/Strings.resx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,4 +2370,16 @@ $$hostname$$ --&gt; Hostname</value>
23702370
<data name="Channels" xml:space="preserve">
23712371
<value>Channels</value>
23722372
</data>
2373+
<data name="Channel" xml:space="preserve">
2374+
<value>Channel</value>
2375+
</data>
2376+
<data name="GHz2dot4" xml:space="preserve">
2377+
<value>2.4 GHz</value>
2378+
</data>
2379+
<data name="GHz5" xml:space="preserve">
2380+
<value>5 GHz</value>
2381+
</data>
2382+
<data name="SignalStrength" xml:space="preserve">
2383+
<value>Signal strength</value>
2384+
</data>
23732385
</root>

‎Source/NETworkManager/ViewModels/WiFiViewModel.cs‎

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.ComponentModel;
1010
using System.Linq;
1111
using System.Threading.Tasks;
12-
using System.Windows;
1312
using System.Windows.Data;
1413
using System.Windows.Input;
1514
using Windows.Devices.WiFi;
@@ -60,8 +59,8 @@ public WiFiAdapterInfo SelectedAdapter
6059

6160
if (value != null)
6261
{
63-
//if (!_isLoading)
64-
// SettingsManager.Current.NetworkInterface_SelectedInterfaceId = value.Id;
62+
if (!_isLoading)
63+
SettingsManager.Current.WiFi_SelectedInterfaceId = value.NetworkInterfaceInfo.Id;
6564

6665
ScanNetworks(value.WiFiAdapter);
6766
}
@@ -135,56 +134,7 @@ public WiFiViewModel()
135134
LoadAdapters();
136135

137136
_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+
}
188138

189139
private void LoadSettings()
190140
{
@@ -224,7 +174,7 @@ private async void LoadAdapters()
224174
// Get the last selected interface, if it is still available on this machine...
225175
if (Adapters.Count > 0)
226176
{
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);
228178

229179
SelectedAdapter = info ?? Adapters[0];
230180
}
@@ -278,6 +228,55 @@ private async void ScanNetworks(WiFiAdapter adapter)
278228
IsNetworksLoading = false;
279229
}
280230

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+
281280
public void OnViewVisible()
282281
{
283282

‎Source/NETworkManager/Views/NetworkInterfaceView.xaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@
372372
</Style>
373373
</TextBlock.Style>
374374
</TextBlock>
375-
<liveChart:CartesianChart Grid.Row="2" Series="{Binding Series}" Margin="0,0,0,20">
375+
<liveChart:CartesianChart Grid.Row="2" Series="{Binding Series}" LegendLocation="Right" Margin="0,0,0,20">
376376
<liveChart:CartesianChart.DataTooltip>
377377
<liveChart:DefaultTooltip Background="Transparent" />
378378
</liveChart:CartesianChart.DataTooltip>

‎Source/NETworkManager/Views/WiFiView.xaml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,40 +385,40 @@
385385
<RowDefinition Height="Auto" />
386386
<RowDefinition Height="*" />
387387
</Grid.RowDefinitions>
388-
<TextBlock Grid.Row="0" Text="2.4 GHz" Style="{StaticResource HeaderTextBlock}" />
388+
<TextBlock Grid.Row="0" Text="{x:Static localization:Strings.GHz2dot4}" Style="{StaticResource HeaderTextBlock}" />
389389
<liveChart:CartesianChart Grid.Row="1" Series="{Binding Radio1Series}" LegendLocation="Right">
390390
<liveChart:CartesianChart.DataTooltip>
391391
<liveChart:DefaultTooltip SelectionMode="OnlySender" Background="Transparent" />
392392
</liveChart:CartesianChart.DataTooltip>
393393
<liveChart:CartesianChart.AxisX>
394-
<liveChart:Axis Title="Channel" Labels="{Binding Radio1Labels}">
394+
<liveChart:Axis Title="{x:Static localization:Strings.Channel}" Labels="{Binding Radio1Labels}">
395395
<liveChart:Axis.Separator>
396396
<liveChart:Separator Step="1" StrokeThickness="0" />
397397
</liveChart:Axis.Separator>
398398
</liveChart:Axis>
399399
</liveChart:CartesianChart.AxisX>
400400
<liveChart:CartesianChart.AxisY>
401-
<liveChart:Axis Title="Signal strength" MinValue="0" LabelFormatter="{Binding FormatterdBm}">
401+
<liveChart:Axis Title="{x:Static localization:Strings.SignalStrength}" MinValue="0" LabelFormatter="{Binding FormatterdBm}">
402402
<liveChart:Axis.Separator>
403403
<liveChart:Separator StrokeThickness="1" Stroke="{DynamicResource GrayBrush8}" StrokeDashArray="10" />
404404
</liveChart:Axis.Separator>
405405
</liveChart:Axis>
406406
</liveChart:CartesianChart.AxisY>
407407
</liveChart:CartesianChart>
408-
<TextBlock Grid.Row="3" Text="5 GHz" Style="{StaticResource HeaderTextBlock}" />
408+
<TextBlock Grid.Row="3" Text="{x:Static localization:Strings.GHz5}" Style="{StaticResource HeaderTextBlock}" />
409409
<liveChart:CartesianChart Grid.Row="4" Series="{Binding Radio2Series}" LegendLocation="Right">
410410
<liveChart:CartesianChart.DataTooltip>
411411
<liveChart:DefaultTooltip SelectionMode="OnlySender" Background="Transparent" />
412412
</liveChart:CartesianChart.DataTooltip>
413413
<liveChart:CartesianChart.AxisX>
414-
<liveChart:Axis Title="Channel" Labels="{Binding Radio2Labels}">
414+
<liveChart:Axis Title="{x:Static localization:Strings.Channel}" Labels="{Binding Radio2Labels}">
415415
<liveChart:Axis.Separator>
416416
<liveChart:Separator Step="1" StrokeThickness="0" />
417417
</liveChart:Axis.Separator>
418418
</liveChart:Axis>
419419
</liveChart:CartesianChart.AxisX>
420420
<liveChart:CartesianChart.AxisY>
421-
<liveChart:Axis Title="Signal strength" MinValue="0" LabelFormatter="{Binding FormatterdBm}">
421+
<liveChart:Axis Title="{x:Static localization:Strings.SignalStrength}" MinValue="0" LabelFormatter="{Binding FormatterdBm}">
422422
<liveChart:Axis.Separator>
423423
<liveChart:Separator StrokeThickness="1" Stroke="{DynamicResource GrayBrush8}" StrokeDashArray="10" />
424424
</liveChart:Axis.Separator>

0 commit comments

Comments
 (0)