@@ -26,14 +26,14 @@ public partial class HikVisions
2626 private string _userName = "admin" ;
2727 private bool _inited ;
2828
29- private bool _loginStatus = true ;
30- private bool _logoutStatus = true ;
31- private bool _startRealPlayStatus = true ;
32- private bool _stopRealPlayStatus = true ;
33- private bool _openSoundStatus = true ;
34- private bool _closeSoundStatus = true ;
35- private bool _startRecordStatus = true ;
36- private bool _stopRecordStatus = true ;
29+ private bool _loginStatus => _hikVision . IsLogin ;
30+ private bool _logoutStatus => ! _hikVision . IsLogin ;
31+ private bool _startRealPlayStatus => _hikVision is not { IsLogin : true , IsRealPlaying : false } ;
32+ private bool _stopRealPlayStatus => _hikVision is not { IsLogin : true , IsRealPlaying : true } ;
33+ private bool _openSoundStatus => _hikVision is not { IsLogin : true , IsRealPlaying : true , IsOpenSound : false } ;
34+ private bool _closeSoundStatus => _hikVision is not { IsLogin : true , IsRealPlaying : true , IsOpenSound : true } ;
35+ private bool _startRecordStatus => _hikVision is not { IsLogin : true , IsRealPlaying : true , IsStartRecord : false } ;
36+ private bool _stopRecordStatus => _hikVision is not { IsLogin : true , IsRealPlaying : true , IsStartRecord : true } ;
3737
3838 private List < SelectedItem > _analogChannels = [ ] ;
3939 private int _channelId = 1 ;
@@ -48,36 +48,22 @@ public partial class HikVisions
4848
4949 private async Task OnLogin ( )
5050 {
51- _loginStatus = true ;
52- _logoutStatus = true ;
53- _loginStatus = await _hikVision . Login ( _ip , _port , _userName , _password , HikVisionLoginType . Http ) ;
51+ await _hikVision . Login ( _ip , _port , _userName , _password , HikVisionLoginType . Http ) ;
5452 }
5553
5654 private async Task OnLogout ( )
5755 {
5856 _analogChannels . Clear ( ) ;
59- _loginStatus = true ;
60- _logoutStatus = true ;
61- _startRealPlayStatus = true ;
62- _stopRealPlayStatus = true ;
63- _openSoundStatus = true ;
64- _closeSoundStatus = true ;
6557 await _hikVision . Logout ( ) ;
6658 }
6759
6860 private async Task OnStartRealPlay ( )
6961 {
70- _startRealPlayStatus = true ;
71- _stopRealPlayStatus = true ;
7262 await _hikVision . StartRealPlay ( _streamType , _channelId ) ;
7363 }
7464
7565 private async Task OnStopRealPlay ( )
7666 {
77- _startRealPlayStatus = true ;
78- _stopRealPlayStatus = true ;
79- _openSoundStatus = true ;
80- _closeSoundStatus = true ;
8167 await _hikVision . StopRealPlay ( ) ;
8268 }
8369
@@ -86,8 +72,6 @@ private async Task OnOpenSound()
8672 var result = await _hikVision . OpenSound ( ) ;
8773 if ( result )
8874 {
89- _openSoundStatus = true ;
90- _closeSoundStatus = false ;
9175 await ToastService . Success ( "消息通知" , "打开声音成功" ) ;
9276 }
9377 else
@@ -101,8 +85,6 @@ private async Task OnCloseSound()
10185 var result = await _hikVision . CloseSound ( ) ;
10286 if ( result )
10387 {
104- _openSoundStatus = false ;
105- _closeSoundStatus = true ;
10688 await ToastService . Success ( "消息通知" , "关闭声音成功" ) ;
10789 }
10890 else
@@ -121,8 +103,6 @@ private async Task OnStartRecord()
121103 var result = await _hikVision . StartRecord ( ) ;
122104 if ( result )
123105 {
124- _startRecordStatus = true ;
125- _stopRecordStatus = false ;
126106 await ToastService . Success ( "消息通知" , "开始录像成功" ) ;
127107 }
128108 else
@@ -136,8 +116,6 @@ private async Task OnStopRecord()
136116 var result = await _hikVision . StopRecord ( ) ;
137117 if ( result )
138118 {
139- _startRecordStatus = false ;
140- _stopRecordStatus = true ;
141119 await ToastService . Success ( "消息通知" , "结束录像成功" ) ;
142120 }
143121 else
@@ -151,7 +129,6 @@ private async Task OnInitedAsync(bool initialized)
151129 _inited = initialized ;
152130 if ( _inited )
153131 {
154- _loginStatus = false ;
155132 StateHasChanged ( ) ;
156133 }
157134 else
@@ -181,10 +158,6 @@ await SwalService.Show(new SwalOption()
181158
182159 private Task OnLoginAsync ( )
183160 {
184- _loginStatus = true ;
185- _logoutStatus = ! _loginStatus ;
186- _startRealPlayStatus = _logoutStatus ;
187- _stopRealPlayStatus = ! _startRealPlayStatus ;
188161 StateHasChanged ( ) ;
189162 return Task . CompletedTask ;
190163 }
@@ -199,34 +172,18 @@ private Task OnGetChannelsAsync(HikVisionChannel channel)
199172
200173 private Task OnLogoutAsync ( )
201174 {
202- _loginStatus = _hikVision . IsLogin ;
203- _logoutStatus = ! _loginStatus ;
204- _startRealPlayStatus = true ;
205- _stopRealPlayStatus = true ;
206175 StateHasChanged ( ) ;
207176 return Task . CompletedTask ;
208177 }
209178
210179 private Task OnStartRealPlayedAsync ( )
211180 {
212- _startRealPlayStatus = _hikVision . IsRealPlaying ;
213- _stopRealPlayStatus = ! _startRealPlayStatus ;
214- _openSoundStatus = false ;
215- _closeSoundStatus = true ;
216- _startRecordStatus = false ;
217- _stopRecordStatus = true ;
218181 StateHasChanged ( ) ;
219182 return Task . CompletedTask ;
220183 }
221184
222185 private Task OnStopRealPlayedAsync ( )
223186 {
224- _startRealPlayStatus = _hikVision . IsRealPlaying ;
225- _stopRealPlayStatus = ! _startRealPlayStatus ;
226- _openSoundStatus = true ;
227- _closeSoundStatus = true ;
228- _startRecordStatus = true ;
229- _stopRecordStatus = true ;
230187 StateHasChanged ( ) ;
231188 return Task . CompletedTask ;
232189 }
0 commit comments