22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33// Website: https://www.blazor.zone or https://argozhang.github.io/
44
5+ using Microsoft . AspNetCore . Components ;
6+
57namespace BootstrapBlazor . Components ;
68
79/// <summary>
@@ -10,9 +12,89 @@ namespace BootstrapBlazor.Components;
1012[ JSModuleAutoLoader ( "./_content/BootstrapBlazor.HikVision/Components/HikVision.razor.js" ) ]
1113public partial class HikVision
1214{
13- private string PreviewId => $ "{ Id } _preview";
15+ /// <summary>
16+ /// 获得/设置 网络摄像机 IP 地址
17+ /// </summary>
18+ [ Parameter ]
19+ public string ? Ip { get ; set ; }
20+
21+ /// <summary>
22+ /// 获得/设置 网络摄像机 端口号 默认值 80
23+ /// </summary>
24+ [ Parameter ]
25+ public int Port { get ; set ; } = 80 ;
26+
27+ /// <summary>
28+ /// 获得/设置 网络摄像机 登录用户名
29+ /// </summary>
30+ [ Parameter ]
31+ public string ? UserName { get ; set ; }
32+
33+ /// <summary>
34+ /// 获得/设置 网络摄像机 登录密码
35+ /// </summary>
36+ [ Parameter ]
37+ public string ? Password { get ; set ; }
38+
39+ /// <summary>
40+ /// 获得/设置 网络摄像机 登录类型 默认值 <see cref="LoginType.Http"/>
41+ /// </summary>
42+ [ Parameter ]
43+ public LoginType LoginType { get ; set ; }
44+
45+ /// <summary>
46+ /// 获得/设置 视频图像窗口宽度 默认值 500px
47+ /// </summary>
48+ [ Parameter ]
49+ public string ? Width { get ; set ; }
50+
51+ /// <summary>
52+ /// 获得/设置 视频图像窗口高度 默认值 300px
53+ /// </summary>
54+ [ Parameter ]
55+ public string ? Height { get ; set ; }
1456
1557 private string ? ClassString => CssBuilder . Default ( "bb-hik" )
1658 . AddClassFromAttributes ( AdditionalAttributes )
1759 . Build ( ) ;
60+
61+ private string ? StyleString => CssBuilder . Default ( )
62+ . AddClass ( $ "width: { Width } ;", ! string . IsNullOrEmpty ( Width ) )
63+ . AddClass ( $ "height: { Height } ;", ! string . IsNullOrEmpty ( Height ) )
64+ . AddStyleFromAttributes ( AdditionalAttributes )
65+ . Build ( ) ;
66+
67+ /// <summary>
68+ /// <inheritdoc/>
69+ /// </summary>
70+ protected override void OnParametersSet ( )
71+ {
72+ base . OnParametersSet ( ) ;
73+
74+ Width ??= "500px" ;
75+ Height ??= "300px" ;
76+ }
77+
78+ /// <summary>
79+ /// 登录方法
80+ /// </summary>
81+ /// <param name="ip"></param>
82+ /// <param name="port"></param>
83+ /// <param name="userName"></param>
84+ /// <param name="password"></param>
85+ /// <param name="loginType"></param>
86+ /// <returns></returns>
87+ public async Task Login ( string ip , string port , string userName , string password , LoginType loginType = LoginType . Http )
88+ {
89+ await InvokeVoidAsync ( "login" , Id , ip , port , userName , password , ( int ) loginType ) ;
90+ }
91+
92+ /// <summary>
93+ /// 登出方法
94+ /// </summary>
95+ /// <returns></returns>
96+ public async Task Logout ( )
97+ {
98+ await InvokeVoidAsync ( "logout" , Id ) ;
99+ }
18100}
0 commit comments