Added status panel for config gui
parent
3682331eb1
commit
94b0e1ba86
|
@ -41,7 +41,7 @@
|
|||
<!-- About Button -->
|
||||
<Button HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Command="{Binding ShowAbout}"
|
||||
Click="About_Button_Click"
|
||||
Margin="2">
|
||||
About
|
||||
</Button>
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace WifiSitterToolbox
|
|||
public partial class MainWindow : Window
|
||||
{
|
||||
private MainWindowViewModel ctx;
|
||||
private About _aboutWindow;
|
||||
|
||||
public MainWindow() {
|
||||
InitializeComponent();
|
||||
|
||||
|
@ -29,5 +31,18 @@ namespace WifiSitterToolbox
|
|||
ctx = new MainWindowViewModel();
|
||||
this.DataContext = ctx;
|
||||
}
|
||||
|
||||
private void About_Button_Click(object sender, RoutedEventArgs e) {
|
||||
if (_aboutWindow == null) {
|
||||
_aboutWindow = new About();
|
||||
_aboutWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
_aboutWindow.Show();
|
||||
_aboutWindow.Closed += (o, evt) => { _aboutWindow = null; };
|
||||
}
|
||||
else {
|
||||
try { _aboutWindow.Activate(); }
|
||||
catch { /* This can fail in strange edge cases and it doesn't really matter */}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,5 +8,14 @@
|
|||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Label> Interface Status View </Label>
|
||||
|
||||
<Expander ExpandDirection="Up"
|
||||
Header="Status Log"
|
||||
>
|
||||
|
||||
<ListView ItemsSource="{Binding Path=StatusLog}"
|
||||
FontFamily="Lucida Console"
|
||||
FontSize="11"/>
|
||||
</Expander>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NativeWifi;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -12,6 +13,8 @@ namespace WifiSitterToolbox.ViewModel
|
|||
#region fields
|
||||
private static string[] _ignoreNics;
|
||||
private static WifiSitter.NetworkState _netState;
|
||||
private static WlanClient _wclient;
|
||||
private static List<string> _statusLog = new List<string>();
|
||||
#endregion // fields
|
||||
|
||||
#region constructor
|
||||
|
@ -19,11 +22,42 @@ namespace WifiSitterToolbox.ViewModel
|
|||
public InterfaceStatusViewModel () {
|
||||
_ignoreNics = ReadNicWhitelist();
|
||||
_netState = new WifiSitter.NetworkState(WifiSitter.NetshHelper.DiscoverAllNetworkDevices(null, _ignoreNics, true), _ignoreNics);
|
||||
_wclient = new NativeWifi.WlanClient();
|
||||
foreach (var i in _wclient.Interfaces) {
|
||||
WriteStatusLog(String.Format("Found Wifi Interface: {0}, {1}, {2}, {3}", i.InterfaceName, i.InterfaceDescription, i.InterfaceState, i.InterfaceGuid));
|
||||
i.WlanNotification += Wifi_WlanNotification;
|
||||
i.WlanConnectionNotification += Wifi_WlanConnectionNotification;
|
||||
if (i.InterfaceState != Wlan.WlanInterfaceState.NotReady) i.Scan();
|
||||
}
|
||||
}
|
||||
|
||||
private void Wifi_WlanConnectionNotification(NativeWifi.Wlan.WlanNotificationData notifyData, NativeWifi.Wlan.WlanConnectionNotificationData connNotifyData) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void Wifi_WlanNotification(NativeWifi.Wlan.WlanNotificationData notifyData) {
|
||||
string logLine = String.Format("{0} {1}", notifyData.interfaceGuid.ToString(), notifyData.NotificationCode.ToString());
|
||||
WriteStatusLog(logLine);
|
||||
|
||||
if (notifyData.notificationSource == Wlan.WlanNotificationSource.ACM) {
|
||||
|
||||
if ((Wlan.WlanNotificationCodeAcm)(notifyData.NotificationCode) == Wlan.WlanNotificationCodeAcm.NetworkAvailable) {
|
||||
var d = notifyData;
|
||||
var i = _wclient.Interfaces.Where(x => x.InterfaceGuid == notifyData.interfaceGuid).FirstOrDefault();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion // constructor
|
||||
|
||||
#region properties
|
||||
|
||||
public List<string> StatusLog {
|
||||
get { return _statusLog; }
|
||||
}
|
||||
|
||||
#endregion // properties
|
||||
|
||||
#region methods
|
||||
|
@ -47,6 +81,12 @@ namespace WifiSitterToolbox.ViewModel
|
|||
return results.ToArray();
|
||||
}
|
||||
|
||||
|
||||
private void WriteStatusLog (string msg) {
|
||||
_statusLog.Add(String.Format("{0} {1}", DateTime.Now, msg));
|
||||
this.OnPropertyChanged("StatusLog");
|
||||
}
|
||||
|
||||
#endregion // methods
|
||||
|
||||
#region commands
|
||||
|
|
|
@ -60,15 +60,7 @@ namespace WifiSitterToolbox.ViewModel
|
|||
if (_showAbout == null) {
|
||||
_showAbout = new WifiSitterToolbox.Helper.RelayCommand(
|
||||
() => {
|
||||
if (_aboutWindow == null) {
|
||||
_aboutWindow = new About();
|
||||
_aboutWindow.Show();
|
||||
_aboutWindow.Closed += (o, e) => { _aboutWindow = null; };
|
||||
}
|
||||
else {
|
||||
try { _aboutWindow.Activate(); }
|
||||
catch { /* This can fail in strange edge cases and it doesn't really matter */}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue