blob: 4e8b144e5cbfcafbbb958fdc1588c2ff1e441759 (
plain)
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Tango.Core.Commands;
using Tango.SharedUI;
using Tango.SharedUI.Helpers;
namespace Tango.StubsUtils.Service.UI.ViewModels
{
public class MainViewVM : ViewModel
{
private StubsService _service;
public StubsService Service
{
get { return _service; }
set { _service = value; RaisePropertyChangedAuto(); }
}
private bool _isTrayIconVisible;
public bool IsTrayIconVisible
{
get { return _isTrayIconVisible; }
set { _isTrayIconVisible = value; RaisePropertyChangedAuto(); }
}
public RelayCommand ExitCommand { get; set; }
public RelayCommand OpenCommand { get; set; }
public MainViewVM()
{
Init();
ExitCommand = new RelayCommand(ExitApplication);
OpenCommand = new RelayCommand(OpenMainWindow);
IsTrayIconVisible = true;
}
public async void Init()
{
Service = new StubsService();
await Service.Start();
await Task.Delay(10000);
await Service.Connect();
}
private async void OpenMainWindow()
{
Application.Current.MainWindow.Visibility = Visibility.Visible;
await Task.Delay(200);
Application.Current.MainWindow.WindowState = WindowState.Normal;
Application.Current.MainWindow.Focus();
Application.Current.MainWindow.Activate();
IsTrayIconVisible = false;
}
public async void ExitApplication()
{
IsTrayIconVisible = false;
UIHelper.DoEvents();
await Task.Delay(1000);
Environment.Exit(0);
}
}
}
|