mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 09:21:24 +08:00
300123045f
* delete demo docs * fix tree default value and dnd * fix tree line and keys * fix switcher icon and line * fix line demo * fix switcher * add DirectoryTree demo * fix draggable demo * clean code * clean code * clean up the classmapper call * update docs * fix the docs * fix comment Co-authored-by: James Yeung <shunjiey@hotmail.com>
62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection.Emit;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public partial class TreeNodeSwitcher<TItem> : ComponentBase
|
|
{
|
|
/// <summary>
|
|
/// 树控件本身
|
|
/// </summary>
|
|
[CascadingParameter(Name = "Tree")]
|
|
public Tree<TItem> TreeComponent { get; set; }
|
|
|
|
/// <summary>
|
|
/// 当前节点
|
|
/// </summary>
|
|
[CascadingParameter(Name = "SelfNode")]
|
|
public TreeNode<TItem> SelfNode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 节点是否处于展开状态
|
|
/// </summary>
|
|
private bool IsSwitcherOpen => SelfNode.Expanded && !SelfNode.IsLeaf;
|
|
|
|
/// <summary>
|
|
/// 节点是否处于关闭状态
|
|
/// </summary>
|
|
private bool IsSwitcherClose => !SelfNode.Expanded && !SelfNode.IsLeaf;
|
|
|
|
protected ClassMapper ClassMapper { get; } = new ClassMapper();
|
|
|
|
private void SetClassMap()
|
|
{
|
|
ClassMapper
|
|
.Add("ant-tree-switcher")
|
|
.If("ant-tree-switcher-noop", () => SelfNode.IsLeaf)
|
|
.If("ant-tree-switcher_open", () => IsSwitcherOpen)
|
|
.If("ant-tree-switcher_close", () => IsSwitcherClose);
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
SetClassMap();
|
|
base.OnInitialized();
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<MouseEventArgs> OnSwitcherClick { get; set; }
|
|
|
|
private async Task OnClick(MouseEventArgs args)
|
|
{
|
|
if (OnSwitcherClick.HasDelegate)
|
|
await OnSwitcherClick.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|