formats/Matrix.Format.ps1xml

<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
    <Controls>
        <Control>
            <Name>Matrix-Header</Name>
            <CustomControl>
                <CustomEntries>
                    <CustomEntry>
                        <CustomItem>
                            <ExpressionBinding>
                                <ScriptBlock>
                                    if (-not $Env:PreludeHideFormatHeaders) {
                                        '' | Write-Color
                                        "{{#cyan $($_.Size[0])}} x {{#cyan $($_.Size[1])}} Matrix" | Write-Title -Template -DarkGray -Indent 2
                                    }
                                </ScriptBlock>
                            </ExpressionBinding>
                        </CustomItem>
                    </CustomEntry>
                </CustomEntries>
            </CustomControl>
        </Control>
        <Control>
            <Name>Matrix-Elements</Name>
            <CustomControl>
                <CustomEntries>
                    <CustomEntry>
                        <CustomItem>
                            <ExpressionBinding>
                                <ScriptBlock>
                                    $Values = $_.Rows
                                    $MaximumLength = $_.Indexes() | ForEach-Object {
                                        $Row, $Col = $_
                                        ($Values[$Row][$Col] | Format-ComplexValue).Length
                                    } | Get-Maximum
                                    $Padding = [Math]::Max(3, $MaximumLength)
                                    $Values | ForEach-Object {
                                        $_ | ForEach-Object {
                                            $Color = if ($_ -eq 0) { 'DarkGray' } else { 'White' }
                                            "$(($_ | Format-ComplexValue).PadLeft($Padding + 1, ' '))" | Write-Color -Color $Color -NoNewLine
                                        }
                                        '' | Write-Color
                                    }
                                </ScriptBlock>
                            </ExpressionBinding>
                        </CustomItem>
                    </CustomEntry>
                </CustomEntries>
            </CustomControl>
        </Control>
    </Controls>
    <ViewDefinitions>
        <View>
            <Name>Matrix</Name>
            <ViewSelectedBy>
                <TypeName>Prelude.Matrix</TypeName>
            </ViewSelectedBy>
            <CustomControl>
                <CustomEntries>
                    <CustomEntry>
                        <CustomItem>
                            <Frame>
                                <CustomItem>
                                    <ExpressionBinding>
                                        <CustomControlName>Matrix-Header</CustomControlName>
                                    </ExpressionBinding>
                                </CustomItem>
                            </Frame>
                            <Frame>
                                <CustomItem>
                                    <ExpressionBinding>
                                        <CustomControlName>Matrix-Elements</CustomControlName>
                                    </ExpressionBinding>
                                </CustomItem>
                            </Frame>
                        </CustomItem>
                    </CustomEntry>
                </CustomEntries>
            </CustomControl>
        </View>
    </ViewDefinitions>
</Configuration>