Communicating service state to status UI now.
parent
a43ef8040f
commit
bb5048fd87
|
@ -16,8 +16,28 @@
|
|||
<vm:MainWindowViewModel/>
|
||||
</Window.DataContext>
|
||||
<Grid>
|
||||
<DataGrid x:Name="DataGridNics"
|
||||
ItemsSource="{Binding Nics, Mode=OneWay}"
|
||||
/>
|
||||
<TabControl>
|
||||
<TabItem Header="Status">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="62"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock>
|
||||
<Run>Service Status: </Run> <Run Text="{Binding ServiceState, Mode=OneWay}"/>
|
||||
</TextBlock>
|
||||
|
||||
<DataGrid x:Name="DataGridNics"
|
||||
Grid.Row="1"
|
||||
ItemsSource="{Binding Nics, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Settings">
|
||||
|
||||
</TabItem>
|
||||
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.ServiceProcess;
|
||||
using System.Text;
|
||||
|
||||
using WifiSitter;
|
||||
|
@ -13,6 +14,7 @@ namespace WifiSitterGui.ViewModel
|
|||
#region fields
|
||||
|
||||
SimpleNetworkState _netState;
|
||||
private ServiceController _sc;
|
||||
|
||||
#endregion // fields
|
||||
|
||||
|
@ -32,9 +34,34 @@ namespace WifiSitterGui.ViewModel
|
|||
get { return _netState; }
|
||||
set { _netState = value; OnPropertyChanged(null); }
|
||||
}
|
||||
|
||||
|
||||
public List<SimpleNic> Nics { get { return NetState.Nics; } }
|
||||
|
||||
|
||||
public string ServiceState {
|
||||
get {
|
||||
try { if (_sc == null) _sc = new ServiceController("WifiSitter"); }
|
||||
catch { return "No Service"; }
|
||||
|
||||
_sc.Refresh();
|
||||
switch (_sc.Status) {
|
||||
case ServiceControllerStatus.Running:
|
||||
return "Running";
|
||||
case ServiceControllerStatus.Stopped:
|
||||
return "Stopped";
|
||||
case ServiceControllerStatus.Paused:
|
||||
return "Paused";
|
||||
case ServiceControllerStatus.StopPending:
|
||||
return "Stopping";
|
||||
case ServiceControllerStatus.StartPending:
|
||||
return "Starting";
|
||||
default:
|
||||
return "Status Changing";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // properties
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue