개정판 45f9a2ad
service Controller 수정
wpf mvvm toolkit추가
Change-Id: I377702b7e388e29af1d18647108109d835b4fefb
ConvertService/ServiceBase/Markus.Service.StationController/ViewModel/MainViewModel.cs | ||
---|---|---|
4 | 4 |
using System.ServiceModel; |
5 | 5 |
using System.Text; |
6 | 6 |
using System.Threading.Tasks; |
7 |
using System.Windows.Input; |
|
8 |
using Markus.Mvvm.ToolKit; |
|
7 | 9 |
using Markus.Service.Helper; |
8 | 10 |
using Markus.Service.StationController.StationService; |
9 | 11 |
using MaterialDesignExtensions.Model; |
10 | 12 |
|
11 | 13 |
namespace Markus.Service.StationController.ViewModel |
12 | 14 |
{ |
13 |
public class MainViewModel : Base.ViewModelBase
|
|
15 |
public class MainViewModel : ViewModelBase |
|
14 | 16 |
{ |
15 | 17 |
StationService.StationServiceClient client; |
18 |
System.Windows.Threading.DispatcherTimer timer; |
|
19 |
bool IsTimer; |
|
16 | 20 |
|
17 |
public MainViewModel() |
|
21 |
#region Command |
|
22 |
|
|
23 |
private ICommand _ClosingCommand; |
|
24 |
public ICommand ClosingCommand |
|
25 |
{ |
|
26 |
get => _ClosingCommand ?? (_ClosingCommand = new RelayCommand(param => this.Closing())); |
|
27 |
} |
|
28 |
|
|
29 |
private ICommand _LoadedCommand; |
|
30 |
public ICommand LoadedCommand |
|
31 |
{ |
|
32 |
get => _LoadedCommand ?? (_LoadedCommand = new RelayCommand(param => this.Loaded())); |
|
33 |
} |
|
34 |
|
|
35 |
#endregion Command |
|
36 |
|
|
37 |
#region 프로퍼티 |
|
38 |
|
|
39 |
private string id; |
|
40 |
|
|
41 |
public string Id |
|
42 |
{ |
|
43 |
get => id; set |
|
44 |
{ |
|
45 |
id = value; |
|
46 |
OnPropertyChanged(() => Id); |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
private List<StationService.ConvertItem> aliveItems; |
|
51 |
|
|
52 |
public List<ConvertItem> AliveItems |
|
53 |
{ |
|
54 |
get => aliveItems; set |
|
55 |
{ |
|
56 |
aliveItems = value; |
|
57 |
OnPropertyChanged(() => AliveItems); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
private List<INavigationItem> navigationItems; |
|
62 |
|
|
63 |
public List<INavigationItem> NavigationItems |
|
64 |
{ |
|
65 |
get => navigationItems; set |
|
66 |
{ |
|
67 |
navigationItems = value; |
|
68 |
OnPropertyChanged(() => navigationItems); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
private INavigationItem selectNavigationItem; |
|
73 |
|
|
74 |
public INavigationItem SelectNavigationItem |
|
75 |
{ |
|
76 |
get => selectNavigationItem; set |
|
77 |
{ |
|
78 |
selectNavigationItem = value; |
|
79 |
OnPropertyChanged(() => SelectNavigationItem); |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
#endregion 프로퍼티 |
|
84 |
|
|
85 |
private void Loaded() |
|
18 | 86 |
{ |
87 |
IsTimer = true; |
|
88 |
|
|
19 | 89 |
ServiceConnection(); |
20 | 90 |
|
21 |
System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
|
|
91 |
timer = new System.Windows.Threading.DispatcherTimer(); |
|
22 | 92 |
timer.Interval = new TimeSpan(0, 0, 1); |
23 | 93 |
timer.Tick += Timer_Tick; |
24 | 94 |
timer.Start(); |
... | ... | |
34 | 104 |
SelectNavigationItem = NavigationItems.First(); |
35 | 105 |
} |
36 | 106 |
|
107 |
private void Closing() |
|
108 |
{ |
|
109 |
IsTimer = false; |
|
110 |
} |
|
111 |
|
|
37 | 112 |
private void ServiceConnection() |
38 | 113 |
{ |
39 | 114 |
try |
... | ... | |
66 | 141 |
{ |
67 | 142 |
try |
68 | 143 |
{ |
144 |
if (!IsTimer) |
|
145 |
{ |
|
146 |
timer.Stop(); |
|
147 |
} |
|
148 |
|
|
69 | 149 |
client.AliveConvertListAsync(); |
70 | 150 |
} |
71 | 151 |
catch (Exception ex) |
... | ... | |
79 | 159 |
AliveItems = e.Result; |
80 | 160 |
} |
81 | 161 |
|
82 |
private string id; |
|
83 |
|
|
84 |
public string Id |
|
85 |
{ |
|
86 |
get => id; set |
|
87 |
{ |
|
88 |
id = value; |
|
89 |
OnPropertyChanged(() => Id); |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
private List<StationService.ConvertItem> aliveItems; |
|
94 |
|
|
95 |
public List<ConvertItem> AliveItems |
|
96 |
{ |
|
97 |
get => aliveItems; set |
|
98 |
{ |
|
99 |
aliveItems = value; |
|
100 |
OnPropertyChanged(() => AliveItems); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
private List<INavigationItem> navigationItems; |
|
105 |
|
|
106 |
public List<INavigationItem> NavigationItems |
|
107 |
{ |
|
108 |
get => navigationItems; set |
|
109 |
{ |
|
110 |
navigationItems = value; |
|
111 |
OnPropertyChanged(() => navigationItems); |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
private INavigationItem selectNavigationItem; |
|
116 |
|
|
117 |
public INavigationItem SelectNavigationItem |
|
118 |
{ |
|
119 |
get => selectNavigationItem; set |
|
120 |
{ |
|
121 |
selectNavigationItem = value; |
|
122 |
OnPropertyChanged(() => SelectNavigationItem); |
|
123 |
} |
|
124 |
} |
|
125 | 162 |
|
126 | 163 |
|
127 | 164 |
} |
내보내기 Unified diff