-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
714 lines (659 loc) · 25.9 KB
/
MainWindow.xaml.cs
File metadata and controls
714 lines (659 loc) · 25.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Management;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Configuration;
using System.Xml.Serialization;
namespace NetSpector
{
/// <summary>
/// 主窗体类
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// 网络配置信息对象
/// </summary>
private readonly NetworkSetting setting;
/// <summary>
/// 构造函数
/// </summary>
public MainWindow()
{
setting = NetworkSetting.GetInstance();
InitializeComponent();
InitializeSettings();
}
/// <summary>
/// 初始化配置信息
/// </summary>
public void InitializeSettings()
{
setting.MachineName = Environment.MachineName;
setting.WorkGroupName = GetWorkgroup();
RefreshNetworkInterfaces(true);
LoadPresets();
setting.Refresh();
setting.ConfigPath = ConfigurationManager.AppSettings["ini_path"];
RefreshConfig();
RefreshFirewall();
setting.RefreshConfig();
}
/// <summary>
/// 从XML文件加载预设配置列表
/// </summary>
public void LoadPresets()
{
try
{
using (StreamReader sr = new StreamReader("preset.xml", Encoding.UTF8))
{
var reader = new XmlSerializer(typeof(List<StationPreset>));
setting.PresetList = (List<StationPreset>)reader.Deserialize(sr);
}
}
catch
{
}
}
/// <summary>
/// 加载某项网络配置信息
/// </summary>
/// <param name="preset">预设网络配置对象</param>
public void LoadPreset(StationPreset preset)
{
if (preset.MachineName != null && preset.MachineName.Trim().Length > 0)
{
setting.MachineName = preset.MachineName;
}
if (preset.Workgroup != null && preset.Workgroup.Trim().Length > 0)
{
setting.WorkGroupName = preset.Workgroup;
}
if (preset.Adapter != null && preset.Adapter.Trim().Length > 0)
{
try
{
Regex regex = new Regex(preset.Adapter);
NetworkInterface network = setting.NetworkInterfaceList.Where(item => regex.IsMatch(item.Description)).FirstOrDefault();
if (network != null)
{
setting.NetworkSelectionIndex = setting.NetworkInterfaceList.IndexOf(network);
RefreshNetworkProperties(network);
}
}
catch
{
}
}
setting.IP = preset.IP;
setting.Mask = preset.Mask;
setting.Gateway = preset.Gateway;
setting.DNS = preset.DNS;
setting.IsSettingUpdated = true;
setting.Refresh();
setting.RefreshNetwork();
}
/// <summary>
/// 应用当前设置
/// </summary>
public void ApplySettings()
{
Cursor = Cursors.Wait;
bool isRebootRequired = false;
try
{
if (setting.MachineName != Environment.MachineName)
{
SetMachineName(setting.MachineName);
isRebootRequired = true;
}
if (setting.WorkGroupName != GetWorkgroup())
{
SetWorkgroupName(setting.WorkGroupName);
isRebootRequired = true;
}
ApplyNetworkProperties();
RefreshNetworkInterfaces();
SaveConfig();
RefreshConfig();
}
catch (Exception e)
{
MessageBox.Show(string.Format("应用当前设置时出现错误,错误信息:{0}{1}", Environment.NewLine, e.Message), "消息警告", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
Cursor = Cursors.Arrow;
if (isRebootRequired)
{
MessageBoxResult result = MessageBox.Show("当前设置将在计算机重启后生效,是否现在重启?", "消息提示", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == MessageBoxResult.Yes)
{
Reboot();
Close();
}
}
else
{
MessageBox.Show("已成功应用当前网络设置!", "消息提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
/// <summary>
/// 获取本地计算机工作组名称
/// </summary>
/// <returns>工作组名称</returns>
private string GetWorkgroup()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\CIMV2", @"SELECT * FROM Win32_ComputerSystem");
foreach (ManagementObject obj in searcher.Get())
{
return obj["Domain"] as string;
}
return null;
}
/// <summary>
/// 使用CMD执行某段命令
/// </summary>
/// <param name="sh">执行命令</param>
/// <param name="path">工作目录</param>
/// <returns>执行结束后所返回的文本信息</returns>
private string RunCommand(string sh, string path = null)
{
Console.WriteLine(sh);
ProcessStartInfo info = new ProcessStartInfo
{
Arguments = sh,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "cmd.exe"
};
if (path != null)
{
info.WorkingDirectory = path;
}
Process process = Process.Start(info);
string result = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
bool isComplete = process.WaitForExit(30000);
Console.WriteLine(result);
if (error != null && error.Trim().Length > 0)
{
throw new Exception(error);
}
else if (!isComplete)
{
throw new Exception("网络设置指令已超时!");
}
return result;
}
/// <summary>
/// 重启本地计算机
/// </summary>
public void Reboot()
{
string sh = "/C shutdown -r -t 5";
RunCommand(sh);
}
/// <summary>
/// 设置本地计算机名称
/// </summary>
/// <param name="name">计算机名称</param>
public void SetMachineName(string name)
{
string sh = string.Format("/C WMIC computersystem where caption=\"%computername%\" rename \"{0}\" & exit", name);
RunCommand(sh);
}
/// <summary>
/// 设置本地工作组名称
/// </summary>
/// <param name="name">工作组名称</param>
public void SetWorkgroupName(string name)
{
string sh = string.Format("/C WMIC computersystem where name=\"%computername%\" call joindomainorworkgroup name=\"{0}\" & exit", name);
RunCommand(sh);
}
/// <summary>
/// 应用网络适配器设置
/// </summary>
public void ApplyNetworkProperties()
{
if (!setting.IsSettingUpdated)
{
return;
}
NetworkInterface network = setting.NetworkInterfaceList[setting.NetworkSelectionIndex];
string sh;
if (setting.Gateway != null && setting.Gateway.Trim().Length > 0)
{
sh = string.Format("/C netsh interface ip set address \"{0}\" static {1} {2} {3} 1", network.Name, setting.IP, setting.Mask, setting.Gateway);
}
else
{
sh = string.Format("/C netsh interface ip set address \"{0}\" static {1} {2} none", network.Name, setting.IP, setting.Mask);
}
if (setting.DNS != null && setting.DNS.Trim().Length > 0)
{
if (Environment.OSVersion.Version.Major > 5)
{
sh += string.Format(" & netsh interface ip set dns \"{0}\" static {1} primary validate=no & exit", network.Name, setting.DNS);
}
else
{
sh += string.Format(" & netsh interface ip set dns \"{0}\" static {1} primary & exit", network.Name, setting.DNS);
}
}
else
{
sh += string.Format(" & netsh interface ip set dns \"{0}\" static none & exit", network.Name);
}
RunCommand(sh);
}
/// <summary>
/// 刷新网络接口列表
/// </summary>
/// <param name="isInitializing">是否程序正在初始化过程中</param>
private void RefreshNetworkInterfaces(bool isInitializing = false)
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
List<NetworkInterface> interfaces = nics.Where(item => item.Supports(NetworkInterfaceComponent.IPv4) && item.NetworkInterfaceType != NetworkInterfaceType.Loopback).ToList();
setting.NetworkInterfaceList = interfaces;
setting.NetworkNameList = interfaces.Select(item => item.Name + " - " + item.Description).ToList();
if (isInitializing)
{
try
{
string pattern = ConfigurationManager.AppSettings["adapter_pattern"];
if (pattern != null && pattern.Length > 0)
{
Regex regex = new Regex(pattern);
NetworkInterface network = interfaces.Where(item => regex.IsMatch(item.Description)).FirstOrDefault();
if (network != null)
{
setting.NetworkSelectionIndex = interfaces.IndexOf(network);
}
}
}
catch
{
}
}
if (interfaces.Count > setting.NetworkSelectionIndex)
{
RefreshNetworkProperties(setting.NetworkInterfaceList[setting.NetworkSelectionIndex]);
}
else
{
RefreshNetworkProperties(null);
}
}
/// <summary>
/// 刷新单个网络接口信息
/// </summary>
/// <param name="network">网络接口对象</param>
private void RefreshNetworkProperties(NetworkInterface network)
{
if (network == null)
{
setting.NetworkStats = null;
setting.IP = null;
setting.Mask = null;
setting.Gateway = null;
setting.DNS = null;
setting.IsSettingUpdated = false;
}
else
{
IPInterfaceProperties properties = network.GetIPProperties();
UnicastIPAddressInformation ip = properties.UnicastAddresses.Where(item => item.Address.AddressFamily == AddressFamily.InterNetwork).FirstOrDefault();
setting.IsNetworkOn = network.OperationalStatus == OperationalStatus.Up;
setting.NetworkStats = string.Format("状态:{0} 带宽:{1:f1}Mbps MAC地址:{2}", network.OperationalStatus == OperationalStatus.Up ? "在线" : "离线", Math.Max(network.Speed, 0) / 1000 / 1000, string.Join(":", network.GetPhysicalAddress().GetAddressBytes().Select(item => item.ToString("x2"))).ToUpper());
setting.IP = ip?.Address.ToString();
setting.Mask = ip?.IPv4Mask.ToString();
setting.Gateway = properties.GatewayAddresses.Where(item => item.Address.AddressFamily == AddressFamily.InterNetwork).FirstOrDefault()?.Address.ToString();
setting.DNS = properties.DnsAddresses.Where(item => item.AddressFamily == AddressFamily.InterNetwork).FirstOrDefault()?.ToString();
setting.IsSettingUpdated = false;
}
setting.RefreshNetwork();
}
/// <summary>
/// 刷新INI配置信息
/// </summary>
/// <returns>是否刷新成功</returns>
private bool RefreshConfig()
{
NetworkConfig config = new NetworkConfig();
try
{
INI.IniFilePath = setting.ConfigPath;
config.Key = INI.ReadIni<string>("SETUP", "ME");
config.Neighbour = INI.ReadIni<string>("SETUP", "Neighbor");
config.IP = INI.ReadIni<string>("SETUP", "IP");
config.MaintenanceIP = INI.ReadIni<string>("SETUP", "MaintanceStation");
config.IsLoaded = true;
using (StreamReader sr = new StreamReader(setting.ConfigPath, ConfigurationManager.AppSettings["encoding_ini"] == "UTF-8" ? Encoding.UTF8:Encoding.Default))
{
config.Text = sr.ReadToEnd();
}
}
catch
{
return false;
}
setting.IsConfigUpdated = false;
setting.Config = config;
setting.RefreshConfig();
return true;
}
/// <summary>
/// 刷新防火墙状态
/// </summary>
/// <returns>是否刷新成功</returns>
private bool RefreshFirewall()
{
FirewallState firewall = new FirewallState();
try
{
string sh = "/C netsh firewall show state";
string result = RunCommand(sh);
firewall.StateText = result;
Regex regex = new Regex("操作模式(.*)= 启用");
if (regex.IsMatch(result))
{
firewall.IsEnabled = true;
}
else
{
firewall.IsEnabled = false;
}
}
catch
{
return false;
}
setting.Firewall = firewall;
setting.RefreshFirewall();
return true;
}
/// <summary>
/// 保存INI配置信息
/// </summary>
private void SaveConfig()
{
if (setting.IsConfigUpdated)
{
INI.WriteIni("SETUP", "ME", setting.Config.Key);
INI.WriteIni("SETUP", "Neighbor", setting.Config.Neighbour);
INI.WriteIni("SETUP", "IP", setting.Config.IP);
INI.WriteIni("SETUP", "MaintanceStation", setting.Config.MaintenanceIP);
}
}
/// <summary>
/// 应用INI配置预设信息
/// </summary>
/// <param name="key">主机标识</param>
public void ApplyConfigPreset(string key)
{
if (setting.PresetList == null)
{
return;
}
NetworkConfig config = new NetworkConfig
{
Text = setting.Config.Text
};
switch (key)
{
case "A":
config.Key = "A";
config.Neighbour = setting.PresetList.Where(item => item.Key == "B").FirstOrDefault()?.MachineName;
config.IP = setting.PresetList.Where(item => item.Key == "A").FirstOrDefault()?.IP;
config.MaintenanceIP = setting.PresetList.Where(item => item.Key == "M").FirstOrDefault()?.IP;
break;
case "B":
config.Key = "B";
config.Neighbour = setting.PresetList.Where(item => item.Key == "A").FirstOrDefault()?.MachineName;
config.IP = setting.PresetList.Where(item => item.Key == "B").FirstOrDefault()?.IP;
config.MaintenanceIP = setting.PresetList.Where(item => item.Key == "M").FirstOrDefault()?.IP;
break;
}
setting.IsConfigUpdated = true;
setting.Config = config;
setting.RefreshConfig();
}
/// <summary>
/// 网络接口选中项目更改事件
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void Interface_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBox comboBox = sender as ComboBox;
setting.NetworkSelectionIndex = comboBox.SelectedIndex;
RefreshNetworkProperties(setting.NetworkInterfaceList[setting.NetworkSelectionIndex]);
}
/// <summary>
/// 刷新网络接口按钮点击
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void InterfaceRefresh_Click(object sender, RoutedEventArgs e)
{
RefreshNetworkInterfaces();
}
/// <summary>
/// 应用设置按钮点击
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void ApplySettings_Click(object sender, RoutedEventArgs e)
{
ApplySettings();
}
/// <summary>
/// 取消设置按钮点击
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void Cancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
/// <summary>
/// 重启系统按钮点击
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void Reboot_Click(object sender, RoutedEventArgs e)
{
MessageBoxResult result = MessageBox.Show("即将重启计算机,未保存的任务可能会丢失,是否确定?", "消息提示", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == MessageBoxResult.Yes)
{
Reboot();
Close();
}
}
/// <summary>
/// 加载预设网络配置信息按钮点击
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void LoadPreset_Click(object sender, RoutedEventArgs e)
{
FrameworkElement element = sender as FrameworkElement;
LoadPreset(element.DataContext as StationPreset);
}
/// <summary>
/// 加载INI配置文件按钮点击
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void LoadConfig_Click(object sender, RoutedEventArgs e)
{
bool result = RefreshConfig();
if (!result)
{
MessageBox.Show("加载配置文件时出现错误!", "消息警告", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
/// <summary>
/// 加载INI预设配置按钮点击
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void LoadConfigPreset_Click(object sender, RoutedEventArgs e)
{
FrameworkElement element = sender as FrameworkElement;
ApplyConfigPreset(element.Tag?.ToString());
}
/// <summary>
/// 网络配置文本框修改事件
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void NetworkSetting_TextChanged(object sender, TextChangedEventArgs e)
{
setting.IsSettingUpdated = true;
}
/// <summary>
/// INI配置文本框修改事件
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void NetworkConfig_TextChanged(object sender, TextChangedEventArgs e)
{
setting.IsConfigUpdated = true;
}
/// <summary>
/// 启用防火墙按钮点击
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void StartFirewall_Click(object sender, RoutedEventArgs e)
{
Cursor = Cursors.Wait;
try
{
string sh = "/C netsh firewall set opmode ENABLE";
RunCommand(sh);
MessageBox.Show("已成功开启防火墙!", "消息提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
MessageBox.Show(string.Format("开启防火墙时出现错误,错误信息:{0}{1}", Environment.NewLine, ex.Message), "消息警告", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
RefreshFirewall();
Cursor = Cursors.Arrow;
}
/// <summary>
/// 关闭防火墙按钮点击
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void StopFirewall_Click(object sender, RoutedEventArgs e)
{
Cursor = Cursors.Wait;
try
{
string sh = "/C netsh firewall set opmode DISABLE";
RunCommand(sh);
MessageBox.Show("已成功关闭防火墙!", "消息提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
MessageBox.Show(string.Format("关闭防火墙时出现错误,错误信息:{0}{1}", Environment.NewLine, ex.Message), "消息警告", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
RefreshFirewall();
Cursor = Cursors.Arrow;
}
/// <summary>
/// 禁用端口按钮点击
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void BlockPort_Click(object sender, RoutedEventArgs e)
{
Cursor = Cursors.Wait;
try
{
string sh;
if (Environment.OSVersion.Version.Major > 5)
{
sh = "/C \"" + AppDomain.CurrentDomain.BaseDirectory + "bat\\blockport_win7.bat\"";
}
else
{
sh = "/C \"" + AppDomain.CurrentDomain.BaseDirectory + "bat\\blockport_xp.bat\"";
}
RunCommand(sh, AppDomain.CurrentDomain.BaseDirectory + "bat");
MessageBox.Show("已成功禁用敏感端口!", "消息提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
MessageBox.Show(string.Format("禁用端口时出现错误,错误信息:{0}{1}", Environment.NewLine, ex.Message), "消息警告", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
RefreshFirewall();
Cursor = Cursors.Arrow;
}
/// <summary>
/// 关闭安全中心
/// </summary>
/// <param name="sender">事件对象</param>
/// <param name="e">事件参数</param>
private void StopSecurityCenter_Click(object sender, RoutedEventArgs e)
{
Cursor = Cursors.Wait;
try
{
string sh = "/C sc config wscsvc start= disabled & sc stop wscsvc";
RunCommand(sh);
MessageBox.Show("已成功关闭安全中心!", "消息提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
MessageBox.Show(string.Format("关闭安全中心时出现错误,错误信息:{0}{1}", Environment.NewLine, ex.Message), "消息警告", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
Cursor = Cursors.Arrow;
}
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
TabControl tabControl = sender as TabControl;
if (tabControl.SelectedIndex == 3)
{
SystemServiceManager.RefreshAllServiceStatus();
}
}
private void ServiceEnable_Click(object sender, RoutedEventArgs e)
{
Cursor = Cursors.Wait;
if (!((sender as FrameworkElement).DataContext is ServiceItem service))
{
return;
}
SystemServiceManager.EnableService(service);
SystemServiceManager.RefreshServiceStatus(service);
Cursor = Cursors.Arrow;
}
private void ServiceDisable_Click(object sender, RoutedEventArgs e)
{
Cursor = Cursors.Wait;
if (!((sender as FrameworkElement).DataContext is ServiceItem service))
{
return;
}
SystemServiceManager.DisableService(service);
SystemServiceManager.RefreshServiceStatus(service);
Cursor = Cursors.Arrow;
}
}
}