Public/Advanced/New-BTText.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
function New-BTText
{
    <#
        .SYNOPSIS
        Creates a new Text Element for Toast Notifications.
 
        .DESCRIPTION
        The New-BTTextElement cmdlet creates a new Text Element for Toast Notifications.
     
        You can specify the text you want displayed in a Toast Notification as a string, or run the cmdlet without a paramter for a blank line.
 
        Each Text Element is the equivalent of one line in on a Toast Notification, long lines will wrap.
 
        .INPUTS
        String
 
        You cannot pipe input to this cmdlet.
 
        .OUTPUTS
        Text
         
        .EXAMPLE
        New-BTTextElement -Content 'This is a line with text!'
 
        Creates a Text Element that will show the string 'This is a line with text!' on a Toast Notification.
 
        .EXAMPLE
        New-BTTextElement
 
        Creates a Text Element that will show a blank line on a Toast Notification.
 
        .NOTES
        TODO: Implement hint-style (https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/06/30/adaptive-tile-templates-schema-and-documentation/)
 
        .LINK
        https://github.com/Windos/BurntToast
    #>


    [CmdletBinding()]
    [OutputType([Microsoft.Toolkit.Uwp.Notifications.AdaptiveText])]
    param
    (
        [Parameter()]
        [alias('Content')]
        [string] $Text,

        [int] $MaxLines,

        [int] $MinLines,

        [switch] $Wrap,

        [Microsoft.Toolkit.Uwp.Notifications.AdaptiveTextAlign] $Align,

        [Microsoft.Toolkit.Uwp.Notifications.AdaptiveTextStyle] $Style,

        [string] $Language
    )

    $TextObj = [Microsoft.Toolkit.Uwp.Notifications.AdaptiveText]::new()

    if ($Text)
    {
        $TextObj.Text = $Text
    }
    
    if ($MaxLines)
    {
        $TextObj.HintMaxLines = $MaxLines
    }

    if ($MinLines)
    {
        $TextObj.HintMinLines = $MinLines
    }

    if ($Wrap)
    {
        $TextObj.HintWrap = $Wrap
    }

    if ($Align)
    {
        $TextObj.HintAlign = $Align
    }

    if ($Style)
    {
        $TextObj.HintStyle = $Style
    }

    if ($Language)
    {
        $TextObj.Language = $Language
    }

    $TextObj
}