Skip to content

Commit 783c6ee

Browse files
committed
Channel view added
1 parent 12caaea commit 783c6ee

3 files changed

Lines changed: 37 additions & 20 deletions

File tree

‎Source/NETworkManager/Models/Network/WiFi.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,5 +253,8 @@ public static string GetHumandReadablePhyKind(WiFiPhyKind phyKind)
253253

254254
return kind;
255255
}
256+
257+
public enum Radio
258+
{ Radio1,Radio2}
256259
}
257260
}

‎Source/NETworkManager/ViewModels/WiFiViewModel.cs‎

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public WiFiNetworkInfo SelectedNetwork
117117
public SeriesCollection Radio1Series { get; set; } = new SeriesCollection();
118118
public string[] Radio1Labels { get; set; } = new string[] { " ", " ", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", " ", " " };
119119
public SeriesCollection Radio2Series { get; set; } = new SeriesCollection();
120-
public string[] Radio2Labels { get; set; }
120+
public string[] Radio2Labels { get; set; } = new string[] { " ", " ", "36", "40", "44", "48", "52", "56", "60", "64", "100", "104", "108", "112", "116", "120", "124", "128", "132", "136", "140", " ", " " };
121121
public Func<double, string> FormatterdBm { get; set; } = value => $"- {value} dBm";
122122

123123
#endregion
@@ -137,41 +137,53 @@ public WiFiViewModel()
137137
_isLoading = false;
138138
}
139139

140-
private ChartValues<double> GetDefaultValues()
140+
private ChartValues<double> GetDefaultChartValues(WiFi.Radio radio)
141141
{
142-
ChartValues<double> values = new ChartValues<double>();
142+
ChartValues<double> values = new ChartValues<double>();
143143

144-
for (int i = 0; i < 17; i++)
144+
for (int i = 0; i < (radio == WiFi.Radio.Radio1 ? Radio1Labels.Length : Radio2Labels.Length); i++)
145145
values.Add(-1);
146146

147147
return values;
148148
}
149149

150-
private void AddNetworkToRadio1Chart(WiFiNetworkInfo network)
150+
private ChartValues<double> SetChartValues(WiFiNetworkInfo network, WiFi.Radio radio, int index)
151151
{
152-
int channel = WiFi.GetChannelFromChannelFrequency(network.ChannelCenterFrequencyInKilohertz);
153-
154-
int index = channel + 1;
152+
ChartValues<double> values = GetDefaultChartValues(radio);
155153

156-
ChartValues<double> values = GetDefaultValues();
157-
158154
values[index - 2] = 0;
159-
values[index - 1] = network.NetworkRssiInDecibelMilliwatts / 2 * -1;
155+
values[index - 1] = network.NetworkRssiInDecibelMilliwatts * -1;
160156
values[index] = network.NetworkRssiInDecibelMilliwatts * -1;
161-
values[index + 1] = network.NetworkRssiInDecibelMilliwatts / 2 * -1;
157+
values[index + 1] = network.NetworkRssiInDecibelMilliwatts * -1;
162158
values[index + 2] = 0;
163159

160+
return values;
161+
}
162+
163+
private void AddNetworkToRadio1Chart(WiFiNetworkInfo network)
164+
{
165+
int index = Array.IndexOf(Radio1Labels, $"{WiFi.GetChannelFromChannelFrequency(network.ChannelCenterFrequencyInKilohertz)}");
166+
164167
Radio1Series.Add(new LineSeries
165168
{
166169
Title = network.SSID,
167-
Values = values,
168-
PointGeometry = null
170+
Values = SetChartValues(network, WiFi.Radio.Radio1, index),
171+
PointGeometry = null,
172+
LineSmoothness = 0
169173
});
170174
}
171175

172176
private void AddNetworkToRadio2Chart(WiFiNetworkInfo network)
173177
{
174-
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+
});
175187
}
176188

177189
private void LoadSettings()
@@ -261,7 +273,6 @@ private async void ScanNetworks(WiFiAdapter adapter)
261273
AddNetworkToRadio1Chart(network);
262274
else
263275
AddNetworkToRadio2Chart(network);
264-
265276
}
266277

267278
IsNetworksLoading = false;

‎Source/NETworkManager/Views/WiFiView.xaml‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@
386386
<RowDefinition Height="*" />
387387
</Grid.RowDefinitions>
388388
<TextBlock Grid.Row="0" Text="2.4 GHz" Style="{StaticResource HeaderTextBlock}" />
389-
<liveChart:CartesianChart Grid.Row="1" Series="{Binding Radio1Series}" >
389+
<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>
@@ -406,9 +406,12 @@
406406
</liveChart:CartesianChart.AxisY>
407407
</liveChart:CartesianChart>
408408
<TextBlock Grid.Row="3" Text="5 GHz" Style="{StaticResource HeaderTextBlock}" />
409-
<!--<liveChart:CartesianChart Grid.Row="4" Series="{Binding Radio1Series}">
409+
<liveChart:CartesianChart Grid.Row="4" Series="{Binding Radio2Series}" LegendLocation="Right">
410+
<liveChart:CartesianChart.DataTooltip>
411+
<liveChart:DefaultTooltip SelectionMode="OnlySender" Background="Transparent" />
412+
</liveChart:CartesianChart.DataTooltip>
410413
<liveChart:CartesianChart.AxisX>
411-
<liveChart:Axis Title="Channel" Labels="{Binding Radio1Labels}">
414+
<liveChart:Axis Title="Channel" Labels="{Binding Radio2Labels}">
412415
<liveChart:Axis.Separator>
413416
<liveChart:Separator Step="1" StrokeThickness="0" />
414417
</liveChart:Axis.Separator>
@@ -421,7 +424,7 @@
421424
</liveChart:Axis.Separator>
422425
</liveChart:Axis>
423426
</liveChart:CartesianChart.AxisY>
424-
</liveChart:CartesianChart>-->
427+
</liveChart:CartesianChart>
425428
</Grid>
426429
</TabItem>
427430
</TabControl>

0 commit comments

Comments
 (0)