Communicating service state to status UI now.
parent
a43ef8040f
commit
bb5048fd87
|
@ -16,8 +16,28 @@
|
||||||
<vm:MainWindowViewModel/>
|
<vm:MainWindowViewModel/>
|
||||||
</Window.DataContext>
|
</Window.DataContext>
|
||||||
<Grid>
|
<Grid>
|
||||||
<DataGrid x:Name="DataGridNics"
|
<TabControl>
|
||||||
ItemsSource="{Binding Nics, Mode=OneWay}"
|
<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>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.ServiceProcess;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
using WifiSitter;
|
using WifiSitter;
|
||||||
|
@ -13,6 +14,7 @@ namespace WifiSitterGui.ViewModel
|
||||||
#region fields
|
#region fields
|
||||||
|
|
||||||
SimpleNetworkState _netState;
|
SimpleNetworkState _netState;
|
||||||
|
private ServiceController _sc;
|
||||||
|
|
||||||
#endregion // fields
|
#endregion // fields
|
||||||
|
|
||||||
|
@ -32,9 +34,34 @@ namespace WifiSitterGui.ViewModel
|
||||||
get { return _netState; }
|
get { return _netState; }
|
||||||
set { _netState = value; OnPropertyChanged(null); }
|
set { _netState = value; OnPropertyChanged(null); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<SimpleNic> Nics { get { return NetState.Nics; } }
|
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
|
#endregion // properties
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue