// 假设 TreeViewListItem 基类定义
class TreeViewListItem {
    // 基类可能的属性和方法
}

// 假设 TextAlignment 枚举定义
enum TextAlignment {
    Left,
    Right,
    Center,
    Justify
}

// 假设 Thickness 类定义
class Thickness {
    constructor(public left: number, public top: number, public right: number, public bottom: number) {}
}

// 假设 IValueConverter 接口定义
interface IValueConverter {
    Convert(o: any, type: any, parameter: any, culture: any): any;
    ConvertBack(o: any, type: any, parameter: any, culture: any): any;
}

class TreeViewListItemLeaf extends TreeViewListItem implements IValueConverter {
    private _treeItemLeafAppendPropertyCollection: TreeViewListItemLeaf[] = [];
    public Width: number;
    public Header: string;
    public BindPropertyName: string;
    public TextAlignment: TextAlignment;
    private static _indentSize: number = 10.0;
    public MenuCode: string;
    public Action: string;
    public Title: string;
    public Tag: string;
    public Rights: string;
    public Key: string;
    public Value: string;

    constructor(header?: string, bindPropertyName?: string, width: number = 100, textAlignment: TextAlignment = TextAlignment.Left) {
        super();
        if (header && bindPropertyName) {
            this.Header = header;
            this.BindPropertyName = bindPropertyName;
            this.Width = width;
            this.TextAlignment = textAlignment;
        }
    }

    public static get IndentSize(): number {
        return TreeViewListItemLeaf._indentSize;
    }

    public static set IndentSize(value: number) {
        TreeViewListItemLeaf._indentSize = value;
    }

    public get TreeItemLeafAppendPropertyCollection(): TreeViewListItemLeaf[] {
        return this._treeItemLeafAppendPropertyCollection;
    }

    public set TreeItemLeafAppendPropertyCollection(value: TreeViewListItemLeaf[]) {
        this._treeItemLeafAppendPropertyCollection = value;
    }

    public getProperty(propertyName: string): string | null {
        return this.GetOrSetProperty(propertyName, null);
    }

    public setProperty(propertyName: string, value: string): void {
        this.GetOrSetProperty(propertyName, value);
    }

    public Convert(o: any, type: any, parameter: any, culture: any): any {
        return new Thickness((o as number) * TreeViewListItemLeaf._indentSize, 0, 0, 0);
    }

    public ConvertBack(o: any, type: any, parameter: any, culture: any): any {
        throw new Error('NotSupportedException');
    }

    private GetOrSetProperty(propertyName: string, value: string | null): string | null {
        switch (propertyName) {
            case "MenuCode":
                if (value === null) {
                    return this.MenuCode;
                } else {
                    this.MenuCode = value;
                }
                break;
            case "Action":
                if (value === null) {
                    return this.Action;
                } else {
                    this.Action = value;
                }
                break;
            case "Title":
                if (value === null) {
                    return this.Title;
                } else {
                    this.Title = value;
                }
                break;
            case "Tag":
                if (value === null) {
                    return this.Tag;
                } else {
                    this.Tag = value;
                }
                break;
            case "Rights":
                if (value === null) {
                    return this.Rights;
                } else {
                    this.Rights = value;
                }
                break;
            default:
                for (const treeItemLeafAppendProperty of this.TreeItemLeafAppendPropertyCollection) {
                    if (treeItemLeafAppendProperty.Key === propertyName) {
                        if (value === null) {
                            return treeItemLeafAppendProperty.Value;
                        } else {
                            treeItemLeafAppendProperty.Value = value;
                        }
                    }
                }
                break;
        }
        return null;
    }
}

export { TreeViewListItemLeaf };