Imports System.Drawing
Imports FlexCell

Namespace UTSModule.Project
    Public Class SingleRowGrid
        Public Enum ColNameEnum
            Sn
            ColName
            ColValue
            Max
        End Enum

        Public Enum RowNameEnum
            ColName
            [Step]
            [Label]
            Action
            Command
            Description
            Parameter1
            Parameter2
            Parameter3
            Parameter4
            Parameter5
            Parameter6
            Retry
            RetryInterval
            Record
            RecordName
            PassGoto
            FailGoto
            ErrorCode
            ErrorMessage
            Help
            Max
        End Enum

        ''' <summary>
        ''' 初始化测试站表格
        ''' </summary>
        ''' <param name="grd">表格控件</param>
        Public Shared Sub InitGrid(grd As FlexCell.Grid, Optional commands As String() = Nothing)
            With grd
                .AutoRedraw = False

                .NewFile() '清空表格格式

                .Rows = StationPlanGrid.ColNameEnum.Max + 1
                .Cols = ColNameEnum.Max

                .DisplayRowNumber = True    '首列显示数字
                .ExtendLastCol = True   '最后一列自动扩充
                .MultiSelect = False '是否允许选择多行
                '.BackColorFixed = Color.FromArgb(255, 227, 228, 225)
                '.BackColorFixedSel = Color.FromArgb(255, 201, 226, 244)
                '.BackColorBkg = Color.FromArgb(255, 248, 232, 226)
                '.BackColor1 = Color.FromArgb(255, 225, 246, 236)
                '.BackColor2 = Color.FromArgb(255, 247, 247, 228)
                ' .GridColor = Color.FromArgb(255, 148, 190, 231)
                .BorderStyle = FlexCell.BorderStyleEnum.None
                .DefaultFont = New Font("微软雅黑", 8)
                .Range(0, 0, 0, .Cols - 1).Font = New Font($"幼圆", 8) '首行样式


                For col As Integer = 0 To ColNameEnum.Max - 1
                    .Cell(0, col).Text = [Enum].GetName(GetType(ColNameEnum), col) '设置列名
                Next

                For i As Integer = 0 To RowNameEnum.Max - 1
                    .Cell(i, ColNameEnum.ColName).Text = [Enum].GetName(GetType(RowNameEnum), i) '填充行内容
                Next

                .Column(ColNameEnum.ColName).Locked = True

                .Cell(RowNameEnum.Step, ColNameEnum.ColValue).Locked = True

                .Cell(RowNameEnum.Command, ColNameEnum.ColValue).CellType = CellTypeEnum.ComboBox

                .Cell(RowNameEnum.Action, ColNameEnum.ColValue).CellType = CellTypeEnum.CheckBox
                .Cell(RowNameEnum.Record, ColNameEnum.ColValue).CellType = CellTypeEnum.CheckBox

                .AutoRedraw = True
                .Refresh()
            End With
        End Sub
    End Class
End Namespace