1- // Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
1+ // Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
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
88namespace BootstrapBlazor . Components ;
99
1010/// <summary>
11- /// DockContentItem 配置项子项对标 content 配置项内部 content 配置
11+ /// <para lang="zh">DockView 组件配置项,对应 content 配置项中的组件项</para>
12+ /// <para lang="en">DockView component option corresponding to a component item in the content configuration</para>
1213/// </summary>
1314public partial class DockViewComponent
1415{
1516 /// <summary>
16- /// 获得/设置 组件是否显示 Header 默认 true 显示
17+ /// <para lang="zh">获得/设置 组件是否显示标题栏,默认为 true</para>
18+ /// <para lang="en">Gets or sets whether the component header is displayed. Default is true</para>
1719 /// </summary>
1820 [ Parameter ]
1921 public bool ShowHeader { get ; set ; } = true ;
2022
2123 /// <summary>
22- /// 获得/设置 组件 Title
24+ /// <para lang="zh">获得/设置 组件标题</para>
25+ /// <para lang="en">Gets or sets the component title</para>
2326 /// </summary>
2427 [ Parameter ]
2528 public string ? Title { get ; set ; }
2629
2730 /// <summary>
28- /// 获得/设置 组件 Title 宽度 默认 null 未设置
31+ /// <para lang="zh">获得/设置 组件标题宽度,默认为 null</para>
32+ /// <para lang="en">Gets or sets the component title width. Default is null</para>
2933 /// </summary>
3034 [ Parameter ]
3135 public int ? TitleWidth { get ; set ; }
3236
3337 /// <summary>
34- /// 获得/设置 组件 Title 样式 默认 null 未设置
38+ /// <para lang="zh">获得/设置 组件标题样式类,默认为 null</para>
39+ /// <para lang="en">Gets or sets the component title CSS class. Default is null</para>
3540 /// </summary>
3641 [ Parameter ]
3742 public string ? TitleClass { get ; set ; }
3843
3944 /// <summary>
40- /// 获得/设置 Title 模板 默认 null 未设置
45+ /// <para lang="zh">获得/设置 标题模板,默认为 null</para>
46+ /// <para lang="en">Gets or sets the title template. Default is null</para>
4147 /// </summary>
4248 [ Parameter ]
43- [ JsonIgnore ]
4449 public RenderFragment ? TitleTemplate { get ; set ; }
4550
4651 /// <summary>
47- /// 获得/设置 组件 Class 默认 null 未设置
52+ /// <para lang="zh">获得/设置 组件样式类,默认为 null</para>
53+ /// <para lang="en">Gets or sets the component CSS class. Default is null</para>
4854 /// </summary>
4955 [ Parameter ]
5056 public string ? Class { get ; set ; }
5157
5258 /// <summary>
53- /// 获得/设置 组件是否可见 默认 true 可见
59+ /// <para lang="zh">获得/设置 组件是否可见,默认为 true</para>
60+ /// <para lang="en">Gets or sets whether the component is visible. Default is true</para>
5461 /// </summary>
5562 [ Parameter ]
5663 public bool Visible { get ; set ; } = true ;
5764
5865 /// <summary>
59- /// 获得/设置 组件是否允许关闭 默认 null 使用 DockView 的配置
66+ /// <para lang="zh">获得/设置 组件是否允许关闭,默认为 null,未设置时使用 DockView 的配置</para>
67+ /// <para lang="en">Gets or sets whether the component can be closed. Default is null. When not set, the DockView configuration is used</para>
6068 /// </summary>
6169 [ Parameter ]
6270 public bool ? ShowClose { get ; set ; }
6371
6472 /// <summary>
65- /// 获得/设置 组件唯一标识值 默认 null 未设置时取 Title 作为唯一标识
73+ /// <para lang="zh">获得/设置 组件唯一标识,默认为 null,未设置时使用 Title 作为唯一标识</para>
74+ /// <para lang="en">Gets or sets the unique component identifier. Default is null. When not set, Title is used as the unique identifier</para>
6675 /// </summary>
6776 [ Parameter ]
6877 public string ? Key { get ; set ; }
6978
7079 /// <summary>
71- /// 获得/设置 是否锁定 默认 null 未设置时取 DockView 的配置
80+ /// <para lang="zh">获得/设置 组件是否锁定,默认为 null,未设置时使用 DockView 的配置</para>
81+ /// <para lang="en">Gets or sets whether the component is locked. Default is null. When not set, the DockView configuration is used</para>
7282 /// </summary>
73- /// <remarks>锁定后无法拖动</remarks>
7483 [ Parameter ]
7584 public bool ? IsLock { get ; set ; }
7685
7786 /// <summary>
78- /// 获得/设置 是否显示锁定按钮 默认 null 未设置时取 DockView 的配置
87+ /// <para lang="zh">获得/设置 是否显示锁定按钮,默认为 null,未设置时使用 DockView 的配置</para>
88+ /// <para lang="en">Gets or sets whether the lock button is displayed. Default is null. When not set, the DockView configuration is used</para>
7989 /// </summary>
8090 [ Parameter ]
8191 public bool ? ShowLock { get ; set ; }
8292
8393 /// <summary>
84- /// 获得/设置 是否悬浮 默认 null 未设置时取 DockView 的配置
94+ /// <para lang="zh">获得/设置 是否悬浮,默认为 null,未设置时使用 DockView 的配置</para>
95+ /// <para lang="en">Gets or sets whether the component is floating. Default is null. When not set, the DockView configuration is used</para>
8596 /// </summary>
8697 [ Parameter ]
8798 public bool ? IsFloating { get ; set ; }
8899
89100 /// <summary>
90- /// 获得/设置 是否显示可悬浮按钮 默认 null 未设置时取 DockView 的配置
101+ /// <para lang="zh">获得/设置 是否显示悬浮按钮,默认为 null,未设置时使用 DockView 的配置</para>
102+ /// <para lang="en">Gets or sets whether the float button is displayed. Default is null. When not set, the DockView configuration is used</para>
91103 /// </summary>
92104 [ Parameter ]
93105 public bool ? ShowFloat { get ; set ; }
94106
95107 /// <summary>
96- /// 获得/设置 是否显示最大化按钮 默认 null 未设置时取 DockView 的配置
108+ /// <para lang="zh">获得/设置 是否显示最大化按钮,默认为 null,未设置时使用 DockView 的配置</para>
109+ /// <para lang="en">Gets or sets whether the maximize button is displayed. Default is null. When not set, the DockView configuration is used</para>
97110 /// </summary>
98111 [ Parameter ]
99112 public bool ? ShowMaximize { get ; set ; }
100113
101114 /// <summary>
102- /// 获得/设置 是否一直显示 默认 null 未设置时取 DockView 的配置
115+ /// <para lang="zh">获得/设置 组件渲染模式,默认为 null,未设置时使用 DockView 的配置</para>
116+ /// <para lang="en">Gets or sets the component render mode. Default is null. When not set, the DockView configuration is used</para>
103117 /// </summary>
104118 [ Parameter ]
105- [ JsonIgnore ( Condition = JsonIgnoreCondition . WhenWritingNull ) ]
106119 public string ? Renderer { get ; set ; }
107120
108121 /// <summary>
109- /// 获得/设置 是否显示标题前置图标 默认 false 不显示
122+ /// <para lang="zh">获得/设置 是否显示标题前置图标,默认为 false</para>
123+ /// <para lang="en">Gets or sets whether the leading title icon is displayed. Default is false</para>
110124 /// </summary>
111125 [ Parameter ]
112126 [ JsonIgnore ]
113127 public bool ShowTitleBar { get ; set ; }
114128
115129 /// <summary>
116- /// 获得/设置 标题前置图标 默认 null 未设置使用默认图标
130+ /// <para lang="zh">获得/设置 标题前置图标,默认为 null,未设置时使用默认图标</para>
131+ /// <para lang="en">Gets or sets the leading title icon. Default is null. When not set, the default icon is used</para>
117132 /// </summary>
118133 [ Parameter ]
119134 [ JsonIgnore ]
120135 public string ? TitleBarIcon { get ; set ; }
121136
122137 /// <summary>
123- /// 获得/设置 标题前置图标 Url 默认 null 未设置使用默认图标
138+ /// <para lang="zh">获得/设置 标题前置图标地址,默认为 null,未设置时使用默认图标</para>
139+ /// <para lang="en">Gets or sets the leading title icon URL. Default is null. When not set, the default icon is used</para>
124140 /// </summary>
125141 [ Parameter ]
126142 [ JsonIgnore ]
127143 public string ? TitleBarIconUrl { get ; set ; }
128144
129145 /// <summary>
130- /// 获得/设置 标题前置图标点击回调方法 默认 null
146+ /// <para lang="zh">获得/设置 标题前置图标点击回调方法,默认为 null</para>
147+ /// <para lang="en">Gets or sets the click callback for the leading title icon. Default is null</para>
131148 /// </summary>
132149 [ Parameter ]
133150 [ JsonIgnore ]
134151 public Func < Task > ? OnClickTitleBarCallback { get ; set ; }
135152
153+ [ CascadingParameter ]
154+ [ NotNull ]
155+ private DockViewV2 ? DockView { get ; set ; }
156+
136157 /// <summary>
137158 /// <inheritdoc/>
138159 /// </summary>
@@ -141,6 +162,20 @@ protected override void OnInitialized()
141162 base . OnInitialized ( ) ;
142163
143164 Type = DockViewContentType . Component ;
165+
166+ // 增加组件状态用于序列化
167+ DockView ? . AddComponentState ( new DockViewComponentState ( this ) { Key = Key } ) ;
168+ }
169+
170+ /// <summary>
171+ /// <inheritdoc/>
172+ /// </summary>
173+ protected override void OnParametersSet ( )
174+ {
175+ base . OnParametersSet ( ) ;
176+
177+ // 同步组件状态到缓存
178+ DockView . UpdateComponentState ( Key , Visible , IsLock ) ;
144179 }
145180
146181 private async Task OnClickBar ( )
@@ -151,12 +186,20 @@ private async Task OnClickBar()
151186 }
152187 }
153188
189+ private bool IsRender ( ) => DockView . IsRender ( Key ) ;
190+
191+ internal void SetVisible ( bool visible ) => Visible = visible ;
192+
193+ internal void SetLock ( bool isLock ) => IsLock = isLock ;
194+
154195 /// <summary>
155- /// 设置 Visible 参数方法
196+ /// <inheritdoc/>
156197 /// </summary>
157- /// <param name="visible "></param>
158- public void SetVisible ( bool visible )
198+ /// <param name="disposing "></param>
199+ protected override void Dispose ( bool disposing )
159200 {
160- Visible = visible ;
201+ base . Dispose ( disposing ) ;
202+
203+ DockView . RemoveComponentState ( Key ) ;
161204 }
162205}
0 commit comments